README.markdown

Introduction

The Ticket Evolution gem is a toolkit that provides a seamless and total wrapper around the Ticket Evolution APIs. Ticket Evolution uses the gem in-house to build consumer products.

The gem follows an instance based approach to the Restful API. This way multiple credentials can be used within the same environment, avoiding the static nature of ActiveResource. The classes allow you to access all endpoints of the API with a familiar ActiveRecord style -- convenient attribute methods, finders, etc.

Objects

There are four main object types:

Connection objects

Each set of API credentials can be combined with a mode and api version to create a unique connection to Ticket Evolution. A connection object is the basis of any call and must be created before anything else can be done. Your API credentials can be found https://settings.ticketevolution.com/brokerage/credentials. You must have an active brokerage account with Ticket Evolution.

Behind the scenes we use Faraday with the :net_http adapter to process connections. You can change this adapter by setting it on the connection class before you instantiate your connection object.

TicketEvolution::Connection.adapter = :typhoeus

Endpoint objects

These are always (except in the case of Search) pluralized class names and match the endpoints listed at http://developer.ticketevolution.com. To instantiate an endpoint instance, create a connection object and then call the endpoints name, underscored, as a method on the connection object.

@connection.brokerages

Some endpoints are scoped to model objects from other endpoints. One example of this is the Addresses endpoint, which is based off of an instance of TicketEvolution::Client. These endpoints can be called directly off of the model instance.

Calling a create, show or update method will result in the creation of a model object. The type of model object generated matches the endpoint called.

@connection.brokerages.show(1) # => an instance of TicketEvolution::Brokerage with an id of 1

Collection objects

Calls to list and search methods will return TicketEvolution::Collection objects. These are Enumerable objects containing an array of entries. Each object in this array is an type of model object. In addition to the #entries method, #total_entries, #per_page and #current_page can all be called on collections.