Download the PHP package fulfillment/api-wrapper without Composer
On this page you can find all versions of the php package fulfillment/api-wrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fulfillment/api-wrapper
More information about fulfillment/api-wrapper
Files in fulfillment/api-wrapper
Package api-wrapper
Short Description A barebones wrapper for the FDC api to facailitate easier authentication and communication
License MIT
Informations about the package api-wrapper
api-wrapper-php
A barebones wrapper to ease authentication and low-level communication with FDC API
Example
Installation
Configuration
Authentication Configuration
Minimum requirements for auth -- you must have:
- client id
- client secret
- username
- password
- scope -- To use provide multiple scopes pass each scope delimited by a space EX
oms postage
AND/OR
- access token
Note that if the access token expires re-authentication cannot occur if credentials are not present.
Auth can be parsed using several options:
Array
DotEnv
Use a .env
file compatible with phpdotenv library. Simply specify the absolute path to the folder containing your .env
file as an argument in the constructor.
Environmental Variables
Use environmental variables (available in $_ENV
)
- USERNAME
- PASSWORD
- CLIENT_ID
- CLIENT_SECRET
- ACCESS_TOKEN
- API_ENDPOINT
- SCOPE
NOTE: If an access token is generated the package will store a copy of the token either at __DIR__ . /logs
or the location returned by storage_path('logs/')
Logging Configuration
The package defaults to console output or file if STDOUT is not available. You may use your own logger by passing an object that implements League\CLImate\Util\Writer\WriterInterface
Guzzle Configuration
You may use your own guzzle
instance by passing it into the constructor
If no instance is passed a new one is created.
Usage
If credentials are provided the client can(will) authenticate itself if an access token is not present or invalid.
Basic requests are by using HTTP verbs methods:
- get($url, $queryString = null)
- post($url, $body, $queryString = null)
- patch($url, $body, $queryString = null)
-
delete($url, $queryString = null)
- $url is the relative url from the endpoint, it is concatenated before the request is sent --
$fullURl = $endPoint . '/' . $url;
- $body is an array or object that can be jsonified.
- $queryString is represented as a key/value array --
$queryString = ['myKey' => 'myValue']
is equivalent tohttp://endpoint/url?myKey=myValue
Helpers
Two functions are available to make response parsing more convenient:
parseError
This function will json decode RequestException
thrown by Guzzle and return the error object used by FDC as a standard object.
getErrorCode
This will do the same as above will be only return an error code if one is present on the error.
All versions of api-wrapper with dependencies
vlucas/phpdotenv Version 2.*
league/climate Version ~3.2
foxxmd/php-utilities Version dev-master