Download the PHP package meiosis-io/amino without Composer
On this page you can find all versions of the php package meiosis-io/amino. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download meiosis-io/amino
More information about meiosis-io/amino
Files in meiosis-io/amino
Package amino
Short Description Meiosis API Library for PHP
License MIT
Homepage https://github.com/meiosis-io/Amino-php
Informations about the package amino
Petri API - PHP SDK
This package will handle integration with the Petri API Services
- Installation
- Common Concepts
- CRMObject Methods
- BaseModel Methods
- Common Exceptions
- Initalization
- Customers
- Organizations
- Transactions
- Content Management - Sites
- Content Management - Pages
- Content Management - Page Types
- Content Management - Page Attributes
- Practical Examples
Installation
Common Concepts
The Meiosis\Amino
class methods will all return instances that extend Meiosis\CRMObject
. These objects interact with their respective API endpoints, and should return items that extend Meiosis\Models\BaseModel
. For example, to fetch a list of Pages out of the content management system that have a name that contains the text "Press Release", our code might look like this:
In this case, $pages
is now an array whose items are instances of the Meiosis\Models\Page
object. Any attributes on these objects are directly available:
CRMObject Methods
The following methods are available on any object that extends the Meiosis\Endpoints\CRMObject
class, such as the objects returned by the methods on the Meiosis\Amino
class.
->find($identifier)
Given an identifier, the find method will return exactly one object that extends Meiosis\Models\BaseModel
->search($searchArray)
Given an array of search parameters in the format ['key' => 'value']
, the search method will return an array of objects that extend Meiosis\Models\BaseModel
->blueprint()
The blueprint method will return a new instance of the appropriate implementation of Meiosis\Models\BaseModel
. For example, a new empty customer would look like:
->save($object)
Passing the save method an implementation of the corresponding Meiosis\Models\BaseModel
will create a new object if it does not yet exist, or will update an existing object. A shortcut to this method exists on each BaseModel
object, via it's own internal ->save()
method. For example, the following two blocks achieve the same thing:
->delete($identifier)
Given an identifier, deletes the record from the system.
->payload($data)
Build the payload needed for the APIClient. This method is mostly used internally, but is publicly available.
BaseModel Methods
The following methods are available on any object that extends the Meiosis\Models\BaseModel
class, such as the objects returned by the classes in Meiosis\Endpoints
::getNativeFields()
The static getNativeFields()
method will return the $native
array on each BaseModel
. This is used when building new methods, or when you want to combine native attributes with custom attributes.
->populate($data)
Populates the object instance with data from the $data
array.
->extract()
Converts the object into an array, extracting the underlying $data
array
->save()
Creates or updates the object and repopulated it with any new fields (id, timestamps, etc)
->refresh()
Reloads the object, fetching fresh data from the api
Common Exceptions
Meiosis\Exceptions\ObjectNotFoundException
- The API returned a 404 / Not Found error.Meiosis\Exceptions\InvalidEndpointException
- A malformed request was sent and the endpoint couldn't be guessed. Check your supplied parameters.Meiosis\Exceptions\ObjectNotPopulatedException
- The SDK tried to save changes to an object, but that object was not populatedMeiosis\Exceptions\ObjectValidationFailedException
- A 422 error was encountered from the API, meanined that arguments supplied are invalid.Meiosis\Exceptions\UseOtherMethodException
- The API endpoint does not support the method you are trying to use (for example, updating an existing transaction).Meiosis\Exceptions\UnknownApiException
- A 500 error was encountered talking with the API. You should try your request again.
Initalization
You'll need to initialize a new instance of the Amino class, giving it an API token and Team ID
If you want to ensure that your server is able to reach the api properly, you can call the remote test function:
Customers
To work with customers, call the customers()
method on the Amino class. Models returned are instances of the Meiosis\Models\Customer
class.
Additional Methods
Aside from the methos mentioned on CRMObject Methods, the following methods also exist:
->trackInteraction($customer, $source, $description, $priority)
Given a Meiosis\Models\Customer
object ($customer
), this method will record an interaction from the source $source
, with the description $description
, with a default $priority
of 5.
Organizations
To work with orgnaizations, call the organizations()
method on the Amino class. Models returned are instances of the Meiosis\Models\Organization
class.
Transactions
To work with transactions, call the transactions()
method on the Amino class. Models returned are instances of the Meiosis\Models\Transaction
class.
Special Cases
->search($searchArray)
Transactions are not searchable. This method will throw a Meiosis\Exceptions\InvalidEndpointException
Exception.
->save()
While new transactions can be saved, existing transactions can not. Transactions can not be updated once recorded, but can be voided.
Content Management - Sites
To work with sites, call the sites()
method on the Amino class. Models returned are instances of the Meiosis\Models\Site
class.
Content Management - Pages
To work with pages, call the pages()
method on the Amino class, passing in a site token / ID. Models returned are instances of the Meiosis\Models\Page
class.
Additional Methods
Aside from the methos mentioned on CRMObject Methods, the following methods also exist:
->getHierarchy($pageID)
The getHierarchy
method accepts an optional $pageID
parameter. Without a $pageID
, it will return an array of simple Meiosis\Models\Page
objects, with their children, starting at the root level of the page hierarchy. If passing a $pageID
, the returned array will have the matching page as the only root page.
->bySlug($slug)
Given a $slug
, the bySlug
method will return an array of pages that match the given slug. The slug should be as specific as possible, including parents as well. For example, a page with the slug my-page
that is a child of a about-us
page could be found with: ->bySlug('about-us/my-page');
->setSiteToken($token)
The setSiteToken
method can be used to change which site the class is using.
Content Management - Page Types
To work with Page Types, call the pageTypes()
method on the Amino class, passing in a site token / ID. Models returned are instances of the Meiosis\Models\PageType
class.
Additional Methods
Aside from the methos mentioned on CRMObject Methods, the following methods also exist:
->setSiteToken($token)
The setSiteToken
method can be used to change which site the class is using.
Content Management - Page Attributes
To work with Page Attributes, call the pageAttributes()
method on the Amino class, passing in a page type ID. Models returned are instances of the Meiosis\Models\PageAttribute
class.
Additional Methods
Aside from the methos mentioned on CRMObject Methods, the following methods also exist:
->all()
Returns an array of all PageAttributes
for the page type.
Practical Examples
Create a new Customer and track an interaction
Record a transaction
Get pages based on custom attributes
Assuming that a custom page attribute has been created with the key attr_category
, we will find all pages in the category 'news':