ftven / sdk-common
SDK COMMON Classes
Installs: 7 467
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 19
Forks: 2
Open Issues: 1
Requires
- php: >= 5.3.9
Requires (Dev)
- guzzlehttp/guzzle: 4.*
- phpunit/phpunit: 4.*
- squizlabs/php_codesniffer: 1.*
Suggests
- guzzlehttp/guzzle: http client for API calls
This package is not auto-updated.
Last update: 2024-11-19 04:01:56 UTC
README
PHP SDK COMMON provide foundation for the native PHP API SDK for consuming FTVEN APIs.
Usage
Add the dependency in your composer.json :
...
"require": {
...
"ftven/sdk-common": "1.*"
}
Then update your dependency :
$ ./composer.phar update ftven/sdk-common
Then you can use it directly in your scripts :
<?php
// ...
require_once '/path/to/vendor/autoload.php';
$sdk = new Ftven\Sdk\Sdk();
$result = $sdk->getApi('xyz')->myApiMethod();
// ...
As an alternative, you can use functions :
$result = ftven_sdk_api('xyz', 'methodName', 'arg1', 'arg2', '...');
By default, API are autoloaded from the Ftven\Sdk\Api namespace, but you can add extra namespaces :
$sdk = new Ftven\Sdk\Sdk(['My\\Other\\Namespace']);
$sdk->getApi('xyz')->...
Some APIs require that you set identities before using them :
$sdk->setIdentity(['login' => 'me', 'pass' => 'mypass']);
...
Depending on the APIs you use, multiple identities are supported (only one per APIs) :
$sdk->setIdentity([...], 'identityType1');
$sdk->setIdentity([...], 'identityType2');
By default, API calls are directed to 'prod' environment, but you can change to an other environment :
$sdk->setEnvironment('preprod');
Depending on the APIs you use, multiple environments are supported (only one per APIs) :
$sdk->setEnvironment('preprod', 'api1');
$sdk->setEnvironment('prod'); // fallback
Enjoy !
FTVEN Build Team.