Download the PHP package myoperator/transport without Composer
On this page you can find all versions of the php package myoperator/transport. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download myoperator/transport
More information about myoperator/transport
Files in myoperator/transport
Package transport
Short Description Guzzle wrapper for making GET or POST or any network requests
License GPL-3.0-or-later
Informations about the package transport
MyOperator Transport
This is a package that uses guzzle http transport and can be used to make network requests. This internally uses Guzzle library to make requests.
Quick Start
To make a GET
or POST
requests:
Using Responses
Responses are the main part of making any responses. Since responses can be of any type (i.e. json, xml, text etc) this library takes cares of automatically converting any json encodeable responses.
Responses are part of MyOperator\Transport\Response
. Hence any response have three available methods:
json()
which returns array if response is valid json. Else the response is returned as istext()
returns the text response as isgetStatus()
returns the response HTTP Status code
Setting headers
Sometime, you may wish to add headers, which can be easily done using setHeaders
method.
OAuth
Many uses OAuth in day to day process. This library takes care of refreshing your access token. Please note that this library does not generate your access token but only refreshes it automatically, if some unauthorized status code is encountered.
Please read more here: Oauth.md
Mocking network requests
This library aims at making writing unit tests and mocks a breeze. This library provides a fluent Guzzle mock api to make mocking easy.
To mock a network request, you can easily create a mock using MyOperator\Transport\TransportMock
. Then can you queue some responses to it.
You can then call your apis and the mock will replay the queues responses in order.
For instance, to mock a 200 SUCCESS
response from any api, you can do:
TODO
- Handling public and private APIs
Setting basic authentication process