codesmen/yourmembership-lumen-api

YourMembership.com PHP API for Lumen (Laravel)

This package's canonical repository appears to be gone and the package has been frozen as a result.

dev-master 2019-10-26 15:38 UTC

This package is not auto-updated.

Last update: 2024-01-01 03:48:08 UTC


README

This package in a work in progress, it is based on the code YM-API.

This package implements a PHP wrapper to work with http://www.yourmembership.com/company/api-reference/

Laravel Installation (5.2+)

Require this package with composer by adding the following to your composer file:

"require": {
    "codesmen/yourmembership-lumen-api": "^0.0.1"
},

Then run composer update to download the package.

Or use

composer require codesmen/yourmembership-lumen-api

After updating composer, add the service provider to the providers array in config/app.php

Codesmen\YourMembershipLumenAPI\YourMembershipServiceProvider::class,

Publish the config for the package

php artisan vendor:publish --provider="Codesmen\YourMembershipLumenAPI\YourMembershipServiceProvider"

Fill in your API_KEY, SECRET_API_KEY and SA_PASSCODE inside config/yourmembership-lumen-api.php.

Usage

<?php
...
use Codesmen\YourMembershipLumenAPI\YMLA;

class YourController extends Controller {

    public function index(YMLA $ymla)
    {
        // Array results
        $result = $ymla->call('Auth.Authenticate', [
            'Username' => 'email@examle.com',
            'Password' => 'password',
        ])->toArray();
        
        // JSON/Object result
        $result = $ymla->call('Auth.Authenticate', [
            'Username' => 'email@examle.com',
            'Password' => 'password',
        ])->toJson();
        
        // XML result
        $result = $ymla->call('Auth.Authenticate', [
            'Username' => 'email@examle.com',
            'Password' => 'password',
        ])->toXML();
    }
    ...
}

Notes on YourMembership session

You don't need to generate session for authentication as this package will do it for you. The SessionID is saved inside Lumen\Laravel cache for 15 minutes.

Returning the RAW XML results from YourMembership

This will return the results as XML and set the return header to XML for the browser to properly print valid XML.

...
$result = $ymla->call('Auth.Authenticate', [
    'Username' => 'email@examle.com',
    'Password' => 'password',
])->toXML();

return response()->xml($result);
...