2017 © Pedro Peláez
 

library efapiwrap

Api wrapper for the EventsForce API for PHP

image

jrbarnard/efapiwrap

Api wrapper for the EventsForce API for PHP

  • Wednesday, April 13, 2016
  • by jrbarnard
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

PHP API wrapper for the Events Force API

Build Status, (*1)

An API client package for the Events Force API. For reference to what kind of data you can pass to the API methods refer to the general API documentation. To get a client slug / client account string see here, (*2)

Contents

  1. Requirements
  2. Installation
  3. Initializing
  4. Full usage
  5. Responses
  6. Contributing
  7. Licence

Requirements

Installation

composer require jbarnard/efapiphp

Initializing and basic usage of the client

Note: The follow examples all use the apiexample credentials as shown here, (*3)

// Define a new client, passing in the client slug and api key
$client = new \EventsForce\Client('apiexample', '035E0A65508A4D8FAB63A983F36ACCAC');

Now you are ready to use specific resources and methods The resources are split as shown on the api docs E.g to access events get all you would do the following:, (*4)

$stream = $client->events->getAll();

The response is a \Psr\Http\Message\StreamInterface, (*5)

Usage - Full method map

#### Events - http://docs.eventsforce.apiary.io/#reference/events

Get all - /events.json
$client->events->getAll();
Get single - /events/{event_id}.json
$client->events->get(2); // where 2 is the event id

#### Attendees - http://docs.eventsforce.apiary.io/#reference/attendees

Get all attendees for an event - /events/{event_id}/attendees.json

Available parameters: * lastModifiedAfter * paymentStatus * category * registrationStatus, (*6)

$client->attendees
    ->setEvent(2)
    ->getAll();

// Or you can also pass arguments where it is a key value array as below
$arguments = [
    'lastModifiedAfter' => '2016-04-07 19:43:26', // date('Y-m-d H:i:s');
    'paymentStatus' => 'paid',
    'category' => 'Attendee',
    'registrationStatus' => 'complete'
];

$client->attendees
    ->getAll($arguments);

// this will return a stream for only attendees who have paid, are an Attendee, they have completed their registration and they were last modified after 2016-04-07 19:43:26
// also notice we didn't run 'setEvent' again, this is because until you set an event again it will use the previously set one
// nb: attempting to get a resource which depends on an id prior to setting it will throw an exception
Get a single attendee for an event by their person ID - /events/{event_id}/attendees/{attendee_id}.json
$client->attendees
    ->setEvent(1)
    ->get(103);
Update an attendee - /events/{event_id}/attendees/{attendee_id}.json?_HttpMethod=PATCH

Needs testing with a full access api, not just the example, (*7)

$client->attendees
    ->setEvent(1)
    ->update(103, [
        'customData' => [
            [
                'key' => 'Receive Newsletter',
                'value' => 'false',
            ],
            [
                'key' => 'CRM ID',
                'value' => '123456'
            ]
        ]
    ]);
Authenticate an attendee - /events/{event_id}/attendees/authenticate.json

The value required for userID depends on the attendeeIDMode set for the event., (*8)

$client->attendees
    ->setEvent(1)
    ->auth('aliquet@mauris.co.uk', 'DWS7C6Z');

#### Sessions - http://docs.eventsforce.apiary.io/#reference/sessions

Get all sessions for an event - /events/{event_id}/sessions.json
$client->sessions
    ->setEvent(3)
    ->getAll();
Get a single session for an event - /events/{event_id}/sessions/{session_id}.json
$client->sessions
    ->setEvent(3)
    ->get(17);

#### People - http://docs.eventsforce.apiary.io/#reference/people

Get a single person - /people/{person_id}.json
$client->people
    ->get(99);

#### Invoices - http://docs.eventsforce.apiary.io/#reference/invoices

Get all invoices - /invoices.json

Can have an optional invoiceNumberAfter parameter which will return the items with id's from that point, defaults to 0, (*9)

$client->invoices
    ->getAll();

// or with parameter
$client->invoices
    ->getAll(1);
Get a single invoice - /invoices/{invoice_number}.json
$client->invoices
    ->get(1);
Update an invoice - /invoices/{invoice_number}.json?_HttpMethod=PATCH

Needs testing with a full access api, not just the example, (*10)

$client->invoices
    ->update(1, [
        'externalInvoiceReference' => 'EF123456'
    ]);
// Because EventsForce have only opened one field to be updated on an invoice this method has a helper as below:
$client->invoices
    ->updateExternalRef(1, 'EF123456');

#### Payments - http://docs.eventsforce.apiary.io/#reference/payments

Get all payments for an invoice - /invoices/{invoice_number}/payments.json
$client->payments
    ->setInvoice(2)
    ->getAll();
Post a payment against an invoice /invoices/{invoice_number}/payments.json

Needs testing with a full access api, not just the example, (*11)

$client->payments
    ->setInvoice(2)
    ->setPostDefault('currencyCode', 'GBP') // you can use setPostDefault to set a default payment parameter, this allows you to set default then post multiple payments using similar details
    ->setPostDefault('comment', 'Made by My Application') // set a default comment for all future payments
    ->post(['amount' => 29.99]); // post one payment

$client->payments
    ->post(['amount' => 27.79]); // post another
Get a single payment for an invoice - /invoices/{invoice_number}/payments/{payment_id}.json
$client->payments
    ->setInvoice(2)
    ->get(2);

Return values

The methods return a response object - http://guzzle3.readthedocs.org/http-client/response.html You can get the body of the response by calling:, (*12)

$body = $response->getBody();

You can also get the status code:, (*13)

$status_code = $response->getStatusCode();

There are other helpers that can be seen here: http://guzzle3.readthedocs.org/http-client/response.html, (*14)

Example JSON output: JSON { "responseCode": 200, "systemErrorCode": "", "systemErrorMessage": "", "userErrorMessage": "", "itemCount": 2, "data": [ { "detailsURL": "https://www.eventsforce.net/apiexample/api/v2/events/1.json", "eventID": 1, "eventName": "Test API event", "eventStatus": "notlive", "eventStartDateTime": "2014-01-23T09:00:00Z", "eventEndDateTime": "2014-01-23T17:00:00Z", "venueName": "" }, { "detailsURL": "https://www.eventsforce.net/apiexample/api/v2/events/2.json", "eventID": 2, "eventName": "Test API event with payment", "eventStatus": "notlive", "eventStartDateTime": "2014-01-23T09:00:00Z", "eventEndDateTime": "2014-01-23T17:00:00Z", "venueName": "" } ] }, (*15)

Contributing

Found in CONTRIBUTING.md, (*16)

Licence

Found in LICENSE file, (*17)

The Versions

13/04 2016

dev-master

9999999-dev https://github.com/jrbarnard/efapiphp

Api wrapper for the EventsForce API for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

php api client events force

11/04 2016

v0.9.0

0.9.0.0 https://github.com/jrbarnard/efapiphp

Api wrapper for the EventsForce API for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

php api client events force

10/04 2016

v0.8.0

0.8.0.0 https://github.com/jrbarnard/efapiphp

Api wrapper for the EventsForce API for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

php api client events force