API Relational Model
Build API requests using an ORM-style abstraction layer
The API Relational Model has not been implemented in all libraries yet.
API Relational Model, or ARM, is a software library abstraction of the underlying API resources in much the same way ORMs abstract database requests. ARM combines functionality like the query language, attribute functions, and object attribute selection. The ARM representations are then compiled into API requests and executed.
Example ARM Request
Here's an example ARM request for monthly aging receivables:
The attr Object
The attr object is a dot notation interface for any object attributes. Attribute
functions can be called as methods of the attributes.
Example Usage
Using select to Select Attributes
The select class method can be used to specify what attributes you want in your API response.
Below are the common ways to use select:
Get Additional Attributes
select can be used to request additional attributes that are not included by default for the
object (more details on these additional attributes can be found in the Object Reference). To
request all default attributes for an object, use *pl.Transaction wildcard operator.
Select Specific Attributes
Return a specific set of attributes by passing the desired attributes as parameters to select.
Calling Functions
Use a function to modify the value of an attribute passed to select by calling the method on
the attr representation being passed to select.
Querying with filter_by
To filter the results of an API request, you can construct conditional statements with attr
attributes and pass those to filter_by. filter_by uses lazy-loading and does not execute API
requests immediately letting you chain filter_by calls or other non-terminal methods.
Example Filters
Executing the Request
Requests aren't immediately executed when using select, filter_by, and group_by. Requests
wait for an execution trigger method or are iterated. The ways in which a request execution is
triggered are by using method all, first, update, or delete. Request execution is also
triggered by iterating over the request or slicing the request results.
Execution Methods
-
.all()- Returns all matching results -
.first()- Returns the first matching result -
.update(data)- Updates all matching results -
.delete()- Deletes all matching results
Iteration and Slicing
ARM Method Chaining
ARM supports method chaining to build complex queries: