Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • ActionMetaData
  • ActionText
  • Admin
  • AmorphousModel
  • ApiHook
  • APIModel
  • ChartSetting
  • ContactForm
  • ContactList
  • Credentials
  • Criteria
  • Dropdowns
  • Events
  • EventsData
  • Fields
  • FormLayout
  • Imports
  • InlineEmail
  • LeadRouting
  • Locations
  • LoginForm
  • Maps
  • Modules
  • Notes
  • Notification
  • PhoneNumber
  • Profile
  • Record
  • Relationships
  • Roles
  • RoleToPermission
  • RoleToUser
  • RoleToWorkflow
  • Rules
  • Session
  • SessionLog
  • Social
  • Tags
  • TempFile
  • Tips
  • Tours
  • TrackEmail
  • TriggerLog
  • URL
  • ViewLog
  • Widgets
  • X2List
  • X2ListCriterion
  • X2ListItem
  • X2Model
  • Overview
  • Package
  • Class
  • Tree

Class APIModel

Standalone model class for interaction with X2Engine's API

Remote data insertion & lookup API model. Has multiple magic methods and automatically makes cURL requests to API controller for ease of use. For each kind of request, see the method in ApiController that corresponds to it. To view this reference, look at the URL path for the method. For example 'api/create' corresponds to actionCreate in ApiController.

Package: application\models
Author: Jake Houser <jake@x2engine.com>, Demitri Morgan <demitri@x2engine.com>
Located at x2engine/protected/models/APIModel.php
Methods summary
public
# __construct( string $user = null, string $userKey = null, string $baseUrl = null )

Constructs a new API model and sets private variables.

Constructs a new API model and sets private variables.

Parameters

$user
string
$user The username to authenticate with
$userKey
string
$userKey The user key to authenticate with
$baseUrl
string
$baseUrl The base path of the server for the API to connect to (i.e. www.yourserver.com/x2engine)
public type
# getModelErrors( )

Getter method for modelErrors

Getter method for modelErrors

Returns

type
public
# setResponseObject( type $response )

Setter for responseObject

Setter for responseObject

Parameters

$response
type
$response
public type
# getResponseObject( )

Magic getter for responseObject

Magic getter for responseObject

Returns

type
public type
# getResponseCode( )

Magic getter for responseCode

Magic getter for responseCode

Returns

type
public type
# getTags( type $modelName, type $modelId )

Obtain the list of tags associated with the model

Obtain the list of tags associated with the model

Parameters

$modelName
type
$modelName
$modelId
type
$modelId

Returns

type
public type
# addTags( type $modelName, type $modelId, type $tags )

Tag the model record

Tag the model record

Parameters

$modelName
type
$modelName
$modelId
type
$modelId
$tags
type
$tags

Returns

type
A
public type
# removeTag( type $modelName, type $modelId, type $tag )

Delete a tag from the model record

Delete a tag from the model record

Parameters

$modelName
type
$modelName
$modelId
type
$modelId
$tag
type
$tag

Returns

type
public
# processResponse( boolean $responseIsModel = false )

Sets the model's attributes equal to those of the model contained in the response from the API, if any, and returns true or false based on how the API request returned (success or failure).

Sets the model's attributes equal to those of the model contained in the response from the API, if any, and returns true or false based on how the API request returned (success or failure).

Parameters

$responseIsModel
boolean
$responseIsModel The response object is the attributes of the model
public boolean
# modelCreateUpdate( type $modelName, mixed $action, mixed $attributes = array() )

Creates or updates a model of a given type name using the current attributes.

Creates or updates a model of a given type name using the current attributes.

Parameters

$modelName
type
$modelName
$action
$attributes

Returns

boolean
public
# modelLookup( mixed $modelName )

Generic find-by-attributes method

Generic find-by-attributes method

public string
# contactCreate( boolean $leadRouting = true )

Creates a contact with attributes specified in the APIModel's attributes property.

Creates a contact with attributes specified in the APIModel's attributes property.

Parameters

$leadRouting
boolean
$leadRouting Boolean whether or not to use lead routing rules for contact assigned to.

Returns

string
Response code from API request.
public string
# contactUpdate( integer $id = null )

Updates a contact with the specified attributes.

Updates a contact with the specified attributes.

Parameters

$id
integer
$id Optional ID of the contact, will be used if the id attribute is not set.

Returns

string
Response code from the API request.
public string
# contactLookup( )

Looks up a contact with the attributes set on the model.

Looks up a contact with the attributes set on the model.

Returns

string
Response code from the API request. JSON string of attributes on success.
public string
# contactDelete( integer $id = null )

Deletes a contact with the specified ID.

Deletes a contact with the specified ID.

Parameters

$id
integer
$id Optional ID of the contact, will be used if id attribute is not set.

Returns

string
Response code of the API request.
public
# clearAttributes( )

Clears the attributes set on the model.

Clears the attributes set on the model.

public type
# checkAccess( type $action )

Parameters

$action
type
$action

Returns

type
public
# __set( string $name, string $value )

Magic method that handles setting attributes of the model.

Magic method that handles setting attributes of the model.

Parameters

$name
string
$name Attribute name.
$value
string
$value Attribute value.
public The
# __get( string $name )

Magic method that handles getting of an attribute of the model.

Magic method that handles getting of an attribute of the model.

Parameters

$name
string
$name The name of the attribute.

Returns

The
value of the attribute if set, else null .
public boolean
# __isset( type $name )

Magic method to check if an attribute is set.

Magic method to check if an attribute is set.

Parameters

$name
type
$name Name of the attribute

Returns

boolean
Whether or not the attribute is set.
Properties summary
public array $attributes
#

Attributes to be used for creating/updating models.

Attributes to be used for creating/updating models.

public array $errors
#

Errors generated by API calls.

Errors generated by API calls.

Magic properties summary
public mixed $responseObject
#

Response data from the server

Response data from the server

public array $modelErrors
#

Validation errors, if any, from the server.

Validation errors, if any, from the server.

public integer $responseCode
#

(read-only) The most recent HTTP response code sent back from the server

(read-only) The most recent HTTP response code sent back from the server

X2CRM Documentation API documentation generated by ApiGen 2.8.0