afosto / api-client
Afosto API client
Installs: 27 141
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 4
Open Issues: 2
Type:package
Requires
- doctrine/inflector: ^1.1
- league/oauth2-client: ^1.3
Requires (Dev)
- filp/whoops: ^2.1
- mustache/mustache: ^2.10
- symfony/console: ^3.0
- symfony/var-dumper: ^3.0
This package is auto-updated.
Last update: 2024-12-11 11:53:43 UTC
README
This is the official API client for the Afosto API. This client, written in PHP should make your work when it comes to interacting with the API a lot easier.
Code Example
Connect to the API using your OAUTH2 client and secret, use a cache driver to store the credentials and start interacting.
$storage = new SessionStorage(); App::run($storage, CLIENT_ID, CLIENT_SECRET);
For example store new customer data and use the newly assigned id right away for a new sale.
$customer = Customer::model(); $customer->email = 'support@afosto.com'; $customer->name = 'Peter Bakker'; $customer->is_female = false; $customer->save();
$sale = new Sale::model(); $sale->customer_id = $customer->id;
Also it is possible to paginate and then traverse through objects that are connected based on relations.
foreach (Product::model()->paginate(50) as $page => $products) { foreach ($products as $product) { foreach ($product->collections as $collection) { echo $collection->name; } } }
Installation
You should use Composer to install this client, using the following command:
composer require afosto/api-client
After this create a new file config.php in the base dir of the project and set the values accordingly as specified in config.example.php.
API Reference
Visit the docs for the full list of documentation and use the inline documentation.
Tests
Todo.
Contributors
You are welcome to contribute to this library, any questions can asked directly at the lead API developer Sjoerd. Moreso you are encouraged to do pull-requests if you find your code complementairy to the client.
License
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.