Skip to content

Latest commit

 

History

History
72 lines (51 loc) · 1.39 KB

quick-start.md

File metadata and controls

72 lines (51 loc) · 1.39 KB



Quick Start



Get up and running in no time.



optimus/php-lib is made to be as easy as possible to pull categories and products; and push enquiries and check their statuses.



Set up

To communicate with the API you'll need to know the BASE URI and an API token. These can be found under System -> API Tokens.

Within the initial script of your application you must set your BASE URI and API token using Optimus\Helpers\Env before attempting to communicate with the API.

<?php

use Optimus\Helpers\Env;

Env::setBaseUri($baseUri);
Env::setToken($token);

// ...

If these are not set before attempting to communicate with the API you will get a EnvironmentVariableNotSetException which will tell you which variable is not set and how to set it.



Communicating with the API

Use entities to communicate with the API, different entities support different actions.

<?php

use Optimus\Entities\Category;
use Optimus\Entities\Enquiry;

// Get all categories
$categories = Category::all();

// Get the details of a specific category
$category = Category::find($categories[0]->id);

// Create an enquiry
$enquiry = Enquiry::create([ /* ... */ ]);

It's that simple!