Download the PHP package teamzac/openzac-api-php without Composer
On this page you can find all versions of the php package teamzac/openzac-api-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package openzac-api-php
OpenZac API PHP Client
This is the PHP client for the OpenZac API.
Getting Started
You'll need an API key. Get one at https://openzac.com.
Creating an instance of the client
In Laravel
Include the service provider in your config/app.php file:
Publish the package's config file:
Add your API token, preferably to your .env file:
Or set it directly in the config file:
The service provider binds a singleton instance of to the IoC container, which you can access using the key 'OpenZac':
Using the client
The remainder of the documentation will assume you're using Laravel. If not, you can replace with a normal instance of .
We're fleshing out a fluent interface to the API, but for now you can just use the method on the client, providing a URI path and optionally any parameters or headers you wish to pass along:
Retreiving Entities
We do have a minimally developed interface for accessing 'entity' resources. You can access this interface using the attribute on the OpenZac instance:
There are two public methods on this resource: and .
all()
is the same as calling . You can pass an array of query parameters as the lone argument:
find()
The method takes an entity ID as its lone parameter, and will retrieve a single entity record.
Resources and Collections
API calls return either an instance of or .
TeamZac\OpenZac\Support\Resource
Right now this is just a simple wrapper for the response which allows you to access data as properties on the Resource object.
The infrastructure is in place to provide more helpful functionality by using this as a base class. Future development plans include each resource having it's own subclass. This will allow for casting attributes to certain data types and potentially other valuable features.
TeamZac\OpenZac\Support\ResourceCollection
This is a simple wrapper around responses that return more than a single resource. It has a couple of public methods which may be useful:
returns the resources, which are subclasses of .
returns any metadata associated with the response. Typically this will just be information related to pagination where applicable.
returns the next page number or if it does not exist.
returns the previous page number or if it does not exist.
All versions of openzac-api-php with dependencies
nesbot/carbon Version ~1.20
guzzlehttp/guzzle Version ~6.0
illuminate/support Version 5.4.*