ticketevolution-ruby 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.rdebugrc +1 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +7 -0
- data/LICENSE +23 -0
- data/README.markdown +237 -0
- data/Rakefile +124 -0
- data/examples/events.rb +64 -0
- data/lib/docs/endpoints.markdown +47 -0
- data/lib/docs/installation.markdown +5 -0
- data/lib/docs/introduction.markdown +16 -0
- data/lib/docs/objects.markdown +40 -0
- data/lib/ticket_evolution/account.rb +4 -0
- data/lib/ticket_evolution/accounts.rb +6 -0
- data/lib/ticket_evolution/address.rb +4 -0
- data/lib/ticket_evolution/brokerage.rb +4 -0
- data/lib/ticket_evolution/brokerages.rb +7 -0
- data/lib/ticket_evolution/categories.rb +7 -0
- data/lib/ticket_evolution/category.rb +4 -0
- data/lib/ticket_evolution/client.rb +4 -0
- data/lib/ticket_evolution/clients/addresses.rb +10 -0
- data/lib/ticket_evolution/clients/credit_cards.rb +8 -0
- data/lib/ticket_evolution/clients/email_addresses.rb +10 -0
- data/lib/ticket_evolution/clients/phone_numbers.rb +10 -0
- data/lib/ticket_evolution/clients.rb +8 -0
- data/lib/ticket_evolution/configuration.rb +4 -0
- data/lib/ticket_evolution/configurations.rb +6 -0
- data/lib/ticket_evolution/core/api_error.rb +11 -0
- data/lib/ticket_evolution/core/base.rb +12 -0
- data/lib/ticket_evolution/core/builder.rb +74 -0
- data/lib/ticket_evolution/core/collection.rb +32 -0
- data/lib/ticket_evolution/core/connection.rb +99 -0
- data/lib/ticket_evolution/core/datum.rb +7 -0
- data/lib/ticket_evolution/core/endpoint/request_handler.rb +46 -0
- data/lib/ticket_evolution/core/endpoint.rb +51 -0
- data/lib/ticket_evolution/core/model.rb +64 -0
- data/lib/ticket_evolution/core/models/samples.rb +8 -0
- data/lib/ticket_evolution/core/samples.rb +6 -0
- data/lib/ticket_evolution/core/singular_class.rb +7 -0
- data/lib/ticket_evolution/core/time.rb +19 -0
- data/lib/ticket_evolution/credit_card.rb +4 -0
- data/lib/ticket_evolution/email_address.rb +4 -0
- data/lib/ticket_evolution/errors/connection_not_found.rb +4 -0
- data/lib/ticket_evolution/errors/endpoint_configuration_error.rb +5 -0
- data/lib/ticket_evolution/errors/invalid_configuration.rb +4 -0
- data/lib/ticket_evolution/errors/method_unavailable_error.rb +4 -0
- data/lib/ticket_evolution/event.rb +4 -0
- data/lib/ticket_evolution/events.rb +7 -0
- data/lib/ticket_evolution/modules/create.rb +18 -0
- data/lib/ticket_evolution/modules/deleted.rb +13 -0
- data/lib/ticket_evolution/modules/list.rb +15 -0
- data/lib/ticket_evolution/modules/search.rb +13 -0
- data/lib/ticket_evolution/modules/show.rb +20 -0
- data/lib/ticket_evolution/modules/update.rb +24 -0
- data/lib/ticket_evolution/office.rb +4 -0
- data/lib/ticket_evolution/offices.rb +7 -0
- data/lib/ticket_evolution/order.rb +15 -0
- data/lib/ticket_evolution/orders.rb +30 -0
- data/lib/ticket_evolution/performer.rb +4 -0
- data/lib/ticket_evolution/performers.rb +8 -0
- data/lib/ticket_evolution/phone_number.rb +4 -0
- data/lib/ticket_evolution/quote.rb +4 -0
- data/lib/ticket_evolution/quotes.rb +7 -0
- data/lib/ticket_evolution/search.rb +22 -0
- data/lib/ticket_evolution/shipment.rb +4 -0
- data/lib/ticket_evolution/shipments.rb +8 -0
- data/lib/ticket_evolution/ticket_group.rb +4 -0
- data/lib/ticket_evolution/ticket_groups.rb +6 -0
- data/lib/ticket_evolution/user.rb +4 -0
- data/lib/ticket_evolution/users.rb +7 -0
- data/lib/ticket_evolution/venue.rb +4 -0
- data/lib/ticket_evolution/venues.rb +8 -0
- data/lib/ticket_evolution/version.rb +3 -0
- data/lib/ticket_evolution.rb +108 -0
- data/spec/fixtures/fake.rb +97 -0
- data/spec/fixtures/net/endpoints/accounts.yml +175 -0
- data/spec/fixtures/net/endpoints/brokerages.yml +257 -0
- data/spec/fixtures/net/endpoints/categories.yml +85 -0
- data/spec/fixtures/net/endpoints/clients.yml +243 -0
- data/spec/fixtures/net/endpoints/search.yml +93 -0
- data/spec/lib/ticket_evolution/account_spec.rb +7 -0
- data/spec/lib/ticket_evolution/accounts_spec.rb +45 -0
- data/spec/lib/ticket_evolution/address_spec.rb +7 -0
- data/spec/lib/ticket_evolution/brokerage_spec.rb +7 -0
- data/spec/lib/ticket_evolution/brokerages_spec.rb +50 -0
- data/spec/lib/ticket_evolution/categories_spec.rb +27 -0
- data/spec/lib/ticket_evolution/category_spec.rb +7 -0
- data/spec/lib/ticket_evolution/client_spec.rb +7 -0
- data/spec/lib/ticket_evolution/clients/addresses_spec.rb +13 -0
- data/spec/lib/ticket_evolution/clients/credit_cards_spec.rb +11 -0
- data/spec/lib/ticket_evolution/clients/email_addresses_spec.rb +13 -0
- data/spec/lib/ticket_evolution/clients/phone_numbers_spec.rb +13 -0
- data/spec/lib/ticket_evolution/clients_spec.rb +37 -0
- data/spec/lib/ticket_evolution/configuration_spec.rb +7 -0
- data/spec/lib/ticket_evolution/configurations_spec.rb +10 -0
- data/spec/lib/ticket_evolution/core/api_error_spec.rb +13 -0
- data/spec/lib/ticket_evolution/core/base_spec.rb +29 -0
- data/spec/lib/ticket_evolution/core/builder_spec.rb +95 -0
- data/spec/lib/ticket_evolution/core/collection_spec.rb +23 -0
- data/spec/lib/ticket_evolution/core/connection_spec.rb +220 -0
- data/spec/lib/ticket_evolution/core/datum_spec.rb +15 -0
- data/spec/lib/ticket_evolution/core/endpoint_spec.rb +12 -0
- data/spec/lib/ticket_evolution/core/model_spec.rb +167 -0
- data/spec/lib/ticket_evolution/core/time_spec.rb +28 -0
- data/spec/lib/ticket_evolution/credit_card_spec.rb +7 -0
- data/spec/lib/ticket_evolution/email_address_spec.rb +7 -0
- data/spec/lib/ticket_evolution/errors/connection_not_found_spec.rb +7 -0
- data/spec/lib/ticket_evolution/errors/endpoint_configuration_error_spec.rb +8 -0
- data/spec/lib/ticket_evolution/errors/invalid_configuration_spec.rb +8 -0
- data/spec/lib/ticket_evolution/errors/method_unavailable_error_spec.rb +7 -0
- data/spec/lib/ticket_evolution/event_spec.rb +7 -0
- data/spec/lib/ticket_evolution/events_spec.rb +11 -0
- data/spec/lib/ticket_evolution/office_spec.rb +7 -0
- data/spec/lib/ticket_evolution/offices_spec.rb +11 -0
- data/spec/lib/ticket_evolution/order_spec.rb +44 -0
- data/spec/lib/ticket_evolution/orders_spec.rb +123 -0
- data/spec/lib/ticket_evolution/performer_spec.rb +7 -0
- data/spec/lib/ticket_evolution/performers_spec.rb +12 -0
- data/spec/lib/ticket_evolution/phone_number_spec.rb +7 -0
- data/spec/lib/ticket_evolution/quote_spec.rb +7 -0
- data/spec/lib/ticket_evolution/quotes_spec.rb +11 -0
- data/spec/lib/ticket_evolution/search_spec.rb +31 -0
- data/spec/lib/ticket_evolution/shipment_spec.rb +7 -0
- data/spec/lib/ticket_evolution/shipments_spec.rb +13 -0
- data/spec/lib/ticket_evolution/ticket_group_spec.rb +7 -0
- data/spec/lib/ticket_evolution/ticket_groups_spec.rb +14 -0
- data/spec/lib/ticket_evolution/user_spec.rb +7 -0
- data/spec/lib/ticket_evolution/users_spec.rb +15 -0
- data/spec/lib/ticket_evolution/venue_spec.rb +7 -0
- data/spec/lib/ticket_evolution/venues_spec.rb +12 -0
- data/spec/lib/ticket_evolution_spec.rb +20 -0
- data/spec/shared_examples/endpoints/class.rb +241 -0
- data/spec/shared_examples/endpoints/create.rb +41 -0
- data/spec/shared_examples/endpoints/deleted.rb +41 -0
- data/spec/shared_examples/endpoints/list.rb +41 -0
- data/spec/shared_examples/endpoints/search.rb +42 -0
- data/spec/shared_examples/endpoints/show.rb +38 -0
- data/spec/shared_examples/endpoints/update.rb +59 -0
- data/spec/shared_examples/errors.rb +5 -0
- data/spec/shared_examples/models.rb +29 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/connection.rb +10 -0
- data/spec/support/vcr.rb +12 -0
- data/ticketevolution-ruby.gemspec +33 -0
- metadata +384 -0
data/.gitignore
ADDED
data/.rdebugrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
set autoeval
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2012 Ticket Evolution, Inc. (http://www.ticketevolution.com)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
data/README.markdown
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
Introduction [![Build Status](https://secure.travis-ci.org/ticketevolution/ticketevolution-ruby.png)](http://travis-ci.org/ticketevolution/ticketevolution-ruby)
|
2
|
+
============
|
3
|
+
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.
|
4
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
All API documentation can be found at [http://developer.ticketevolution.com](http://developer.ticketevolution.com/).
|
8
|
+
|
9
|
+
_WARNING: This gem is not ready for prime time. The transactions endpoint has not been added and a few implementation details have yet to be worked out. Known issues and missing functionality are documented in the [Github Issues](https://github.com/ticketevolution/ticketevolution-ruby/issues)._
|
10
|
+
|
11
|
+
**Rubies supported**
|
12
|
+
|
13
|
+
- 1.9.2
|
14
|
+
- 1.8.7
|
15
|
+
- ree
|
16
|
+
|
17
|
+
Installation
|
18
|
+
============
|
19
|
+
# Gemfile
|
20
|
+
gem 'ticketevolution-ruby', :require => 'ticket_evolution'
|
21
|
+
|
22
|
+
Objects
|
23
|
+
=======
|
24
|
+
There are four main object types:
|
25
|
+
|
26
|
+
**Connection objects**
|
27
|
+
|
28
|
+
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](https://settings.ticketevolution.com/brokerage/credentials). You must have an active brokerage account with Ticket Evolution._
|
29
|
+
|
30
|
+
# Example connection configuration (defaults shown)
|
31
|
+
@connection = TicketEvolution::Connection.new({
|
32
|
+
:token => '', # => (required) The API token, used to identify you
|
33
|
+
:secret => '', # => (required) The API secret, used to sign requests
|
34
|
+
# More info: [http://developer.ticketevolution.com/signature_tool](http://developer.ticketevolution.com/signature_tool))
|
35
|
+
:mode => :sandbox, # => (optional) Specifies the server environment to use
|
36
|
+
Valid options: :production or :sandbox
|
37
|
+
:version => 8 # => (optional) API version to use - the only available
|
38
|
+
version at the time of this writing is 8
|
39
|
+
})
|
40
|
+
|
41
|
+
**Endpoint objects**
|
42
|
+
|
43
|
+
These are always (except in the case of Search) pluralized class names and match the endpoints listed at [http://developer.ticketevolution.com](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.
|
44
|
+
|
45
|
+
@connection.brokerages
|
46
|
+
|
47
|
+
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.
|
48
|
+
|
49
|
+
@client = @connection.clients.show(1)
|
50
|
+
@address = @client.addresses.show(1)
|
51
|
+
|
52
|
+
**Model objects**
|
53
|
+
|
54
|
+
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.
|
55
|
+
|
56
|
+
@connection.brokerages.show(1) # => an instance of TicketEvolution::Brokerage with an id of 1
|
57
|
+
|
58
|
+
**Collection objects**
|
59
|
+
|
60
|
+
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.
|
61
|
+
|
62
|
+
Interacting with an endpoint
|
63
|
+
============================
|
64
|
+
|
65
|
+
@connection.brokerages.list # => builds a TicketEvolution::Collection object containing
|
66
|
+
# a collection of TicketEvolution::Brokerage model objects
|
67
|
+
|
68
|
+
@connection.brokerages.show(id) # => builds a TicketEvolution::Brokerage model object
|
69
|
+
|
70
|
+
@connection.brokerages.search(params) # => returns a TicketEvolution::Collection object containing
|
71
|
+
# a collection of TicketEvolution::Brokerage model objects
|
72
|
+
|
73
|
+
Alias methods
|
74
|
+
-------------
|
75
|
+
To more directly match ActiveRecord style, the following aliases exist and can be called on endpoints which include thier equivalent method:
|
76
|
+
|
77
|
+
#find aliases #show
|
78
|
+
|
79
|
+
@connection.brokerages.find(1)
|
80
|
+
# is the same as calling
|
81
|
+
@connection.brokerages.show(1)
|
82
|
+
|
83
|
+
#update_attributes indirectly aliases #update
|
84
|
+
_A call to #update_attributes will update the attributes on the instance as well as calling #update on the endpoint._
|
85
|
+
|
86
|
+
@brokerage = @connection.brokerages.find(1)
|
87
|
+
@brokerage.update_attributes(params)
|
88
|
+
# is an easy way to call
|
89
|
+
TicketEvolution::Brokerages.new({:connection => @connection, :id => 1}).update(params)
|
90
|
+
|
91
|
+
#save indirectly aliases #update
|
92
|
+
|
93
|
+
@brokerage = @connection.brokerages.find(1)
|
94
|
+
@brokerage.attributes = params
|
95
|
+
@brokerage.save
|
96
|
+
# is an easy way to call
|
97
|
+
TicketEvolution::Brokerages.new({:connection => @connection, :id => 1}).update(params)
|
98
|
+
|
99
|
+
#all aliases #list
|
100
|
+
_If you use this, be aware that the list endpoints max out at 100 results, so #all defaultly has the following defined parameter - :limit => 100_
|
101
|
+
|
102
|
+
@connection.brokerages.all
|
103
|
+
# is the same as calling
|
104
|
+
@connection.brokerages.list
|
105
|
+
|
106
|
+
Available endpoints
|
107
|
+
-------------------
|
108
|
+
Click on the links next to each endpoint for more detail.
|
109
|
+
|
110
|
+
**Accounts** - [http://developer.ticketevolution.com/endpoints/accounts](http://developer.ticketevolution.com/endpoints/accounts)
|
111
|
+
|
112
|
+
@account = @connection.accounts.list(params)
|
113
|
+
@account = @connection.accounts.show(id)
|
114
|
+
|
115
|
+
**Addresses** - [http://developer.ticketevolution.com/endpoints/addresses](http://developer.ticketevolution.com/endpoints/addresses)
|
116
|
+
|
117
|
+
@address = @client.addresses.create(params)
|
118
|
+
@address = @client.addresses.list(params)
|
119
|
+
@address = @client.addresses.show(id)
|
120
|
+
@address = @address.update_attributes(params)
|
121
|
+
|
122
|
+
**Brokerages** - [http://developer.ticketevolution.com/endpoints/brokerages](http://developer.ticketevolution.com/endpoints/brokerages)
|
123
|
+
|
124
|
+
@brokerage = @connection.brokerages.list(params)
|
125
|
+
@brokerage = @connection.brokerages.search(params)
|
126
|
+
@brokerage = @connection.brokerages.show(id)
|
127
|
+
|
128
|
+
**Categories** - [http://developer.ticketevolution.com/endpoints/categories](http://developer.ticketevolution.com/endpoints/categories)
|
129
|
+
|
130
|
+
@category = @connection.categories.deleted(params)
|
131
|
+
@category = @connection.categories.list(params)
|
132
|
+
@category = @connection.categories.show(id)
|
133
|
+
|
134
|
+
**Clients** - [http://developer.ticketevolution.com/endpoints/clients](http://developer.ticketevolution.com/endpoints/clients)
|
135
|
+
|
136
|
+
@client = @connection.clients.create(params)
|
137
|
+
@client = @connection.clients.list(params)
|
138
|
+
@client = @connection.clients.show(id)
|
139
|
+
@client = @client.update_attributes(params)
|
140
|
+
|
141
|
+
**Configurations** - [http://developer.ticketevolution.com/endpoints/configurations](http://developer.ticketevolution.com/endpoints/configurations)
|
142
|
+
|
143
|
+
@configuration = @connection.configurations.list(params)
|
144
|
+
@configuration = @connection.configurations.show(id)
|
145
|
+
|
146
|
+
**Credit Cards** - [http://developer.ticketevolution.com/endpoints/credit-cards](http://developer.ticketevolution.com/endpoints/credit-cards)
|
147
|
+
|
148
|
+
@credit_card = @client.credit_cards.create(params)
|
149
|
+
@credit_card = @client.credit_cards.list(params)
|
150
|
+
|
151
|
+
**Email Addresses** - [http://developer.ticketevolution.com/endpoints/email-addresses](http://developer.ticketevolution.com/endpoints/email-addresses)
|
152
|
+
|
153
|
+
@email_address = @client.email_addresses.create(params)
|
154
|
+
@email_address = @client.email_addresses.list(params)
|
155
|
+
@email_address = @client.email_addresses.show(id)
|
156
|
+
@email_address = @email_address.update_attributes(params)
|
157
|
+
|
158
|
+
**Events** - [http://developer.ticketevolution.com/endpoints/events](http://developer.ticketevolution.com/endpoints/events)
|
159
|
+
|
160
|
+
@event = @connection.events.deleted(params)
|
161
|
+
@event = @connection.events.list(params)
|
162
|
+
@event = @connection.events.show(id)
|
163
|
+
|
164
|
+
**Offices** - [http://developer.ticketevolution.com/endpoints/offices](http://developer.ticketevolution.com/endpoints/offices)
|
165
|
+
|
166
|
+
@office = @connection.offices.list(params)
|
167
|
+
@office = @connection.offices.search(params)
|
168
|
+
@office = @connection.offices.show(id)
|
169
|
+
|
170
|
+
**Orders** - [http://developer.ticketevolution.com/endpoints/orders](http://developer.ticketevolution.com/endpoints/orders)
|
171
|
+
|
172
|
+
@order = @order.accept(params)
|
173
|
+
@order = @order.complete
|
174
|
+
@order = @connection.orders.create_brokerage_order(params)
|
175
|
+
@order = @connection.orders.create_customer_order(params)
|
176
|
+
@order = @connection.orders.create_fulfillment_order(params)
|
177
|
+
@order = @connection.orders.list(params)
|
178
|
+
@order = @order.reject(params)
|
179
|
+
@order = @connection.orders.show(id)
|
180
|
+
@order = @order.update_attributes(params)
|
181
|
+
|
182
|
+
**Performers** - [http://developer.ticketevolution.com/endpoints/performers](http://developer.ticketevolution.com/endpoints/performers)
|
183
|
+
|
184
|
+
@performer = @connection.performers.deleted(params)
|
185
|
+
@performer = @connection.performers.list(params)
|
186
|
+
@performer = @connection.performers.search(params)
|
187
|
+
@performer = @connection.performers.show(id)
|
188
|
+
|
189
|
+
**Phone Numbers** - [http://developer.ticketevolution.com/endpoints/phone-numbers](http://developer.ticketevolution.com/endpoints/phone-numbers)
|
190
|
+
|
191
|
+
@phone_number = @client.phone_numbers.create(params)
|
192
|
+
@phone_number = @client.phone_numbers.list(params)
|
193
|
+
@phone_number = @client.phone_numbers.show(id)
|
194
|
+
@phone_number = @phone_number.update_attributes(params)
|
195
|
+
|
196
|
+
**Quotes** - [http://developer.ticketevolution.com/endpoints/quotes](http://developer.ticketevolution.com/endpoints/quotes)
|
197
|
+
|
198
|
+
@quote = @connection.quotes.list(params)
|
199
|
+
@quote = @connection.quotes.search(params)
|
200
|
+
@quote = @connection.quotes.show(id)
|
201
|
+
|
202
|
+
**Search** - [http://developer.ticketevolution.com/endpoints/search](http://developer.ticketevolution.com/endpoints/search)
|
203
|
+
|
204
|
+
@search = @connection.search.list(params)
|
205
|
+
|
206
|
+
**Shipments** - [http://developer.ticketevolution.com/endpoints/shipments](http://developer.ticketevolution.com/endpoints/shipments)
|
207
|
+
|
208
|
+
@shipment = @connection.shipments.create(params)
|
209
|
+
@shipment = @connection.shipments.list(params)
|
210
|
+
@shipment = @connection.shipments.show(id)
|
211
|
+
@shipment = @shipment.update_attributes(params)
|
212
|
+
|
213
|
+
**Ticket Groups** - [http://developer.ticketevolution.com/endpoints/ticket-groups](http://developer.ticketevolution.com/endpoints/ticket-groups)
|
214
|
+
|
215
|
+
@ticket_group = @connection.ticket_groups.list(params)
|
216
|
+
@ticket_group = @connection.ticket_groups.show(id)
|
217
|
+
|
218
|
+
**Transactions** - [http://developer.ticketevolution.com/endpoints/transactions](http://developer.ticketevolution.com/endpoints/transactions)
|
219
|
+
|
220
|
+
@transaction = @account.transactions.list(params)
|
221
|
+
@transaction = @account.transactions.show(id)
|
222
|
+
|
223
|
+
**Users** - [http://developer.ticketevolution.com/endpoints/users](http://developer.ticketevolution.com/endpoints/users)
|
224
|
+
|
225
|
+
@user = @connection.users.list(params)
|
226
|
+
@user = @connection.users.search(params)
|
227
|
+
@user = @connection.users.show(id)
|
228
|
+
|
229
|
+
**Venues** - [http://developer.ticketevolution.com/endpoints/venues](http://developer.ticketevolution.com/endpoints/venues)
|
230
|
+
|
231
|
+
@venue = @connection.venues.deleted(params)
|
232
|
+
@venue = @connection.venues.list(params)
|
233
|
+
@venue = @connection.venues.search(params)
|
234
|
+
@venue = @connection.venues.show(id)
|
235
|
+
|
236
|
+
|
237
|
+
######ticketevolution-ruby v0.5.0
|
data/Rakefile
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task :test => :spec
|
9
|
+
task :default => :spec
|
10
|
+
|
11
|
+
namespace :documentation do
|
12
|
+
desc 'builds README.markdown'
|
13
|
+
task :build do
|
14
|
+
require 'ticket_evolution'
|
15
|
+
require 'nokogiri'
|
16
|
+
|
17
|
+
def load_doc(file)
|
18
|
+
File.read(TicketEvolution.root + "../docs/#{file}.markdown")
|
19
|
+
end
|
20
|
+
|
21
|
+
contents = StringIO.new
|
22
|
+
|
23
|
+
# Introduction
|
24
|
+
contents << load_doc('introduction')
|
25
|
+
|
26
|
+
# Installation
|
27
|
+
contents << load_doc('installation')
|
28
|
+
|
29
|
+
# Connection
|
30
|
+
contents << load_doc('objects')
|
31
|
+
|
32
|
+
# Endpoints
|
33
|
+
contents << load_doc('endpoints')
|
34
|
+
|
35
|
+
endpoints_connection = Curl::Easy.new('http://developer.ticketevolution.com/endpoints.xml')
|
36
|
+
endpoints_connection.http_get
|
37
|
+
endpoints_xml = Nokogiri::XML(endpoints_connection.body_str)
|
38
|
+
|
39
|
+
endpoints_xml.xpath('//endpoint').sort_by{|x| x.xpath('name').children.to_s}.each do |xml|
|
40
|
+
presenter = ThisTask::EndpointPresenter.new(xml)
|
41
|
+
contents << "
|
42
|
+
**#{presenter.name}** - [#{presenter.url}](#{presenter.url})
|
43
|
+
#{presenter.examples}
|
44
|
+
"
|
45
|
+
end
|
46
|
+
contents << "
|
47
|
+
|
48
|
+
######ticketevolution-ruby v#{TicketEvolution::VERSION}"
|
49
|
+
contents.rewind
|
50
|
+
File.open(TicketEvolution.root + '../../README.markdown', 'w+') do |f|
|
51
|
+
f.write contents.read
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
module ThisTask
|
57
|
+
class EndpointPresenter
|
58
|
+
def initialize(xml)
|
59
|
+
@xml = xml
|
60
|
+
end
|
61
|
+
|
62
|
+
def name
|
63
|
+
get(@xml, 'name')
|
64
|
+
end
|
65
|
+
|
66
|
+
def chain_name
|
67
|
+
underscore(name)
|
68
|
+
end
|
69
|
+
|
70
|
+
def examples
|
71
|
+
case chain_name
|
72
|
+
when "addresses", "email_addresses", "phone_numbers", "credit_cards"
|
73
|
+
actions_for("@client")
|
74
|
+
when "transactions"
|
75
|
+
actions_for("@account")
|
76
|
+
else
|
77
|
+
actions_for("@connection")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def actions_for(base)
|
82
|
+
actions.collect do |action|
|
83
|
+
action_name = underscore(get(action, 'name'))
|
84
|
+
"
|
85
|
+
#{variable} = #{formatted_action(base, action_name)}"
|
86
|
+
end.join
|
87
|
+
end
|
88
|
+
|
89
|
+
def formatted_action(base, name)
|
90
|
+
case name
|
91
|
+
when "show"
|
92
|
+
"#{base}.#{chain_name}.#{name}(id)"
|
93
|
+
when "update"
|
94
|
+
"#{variable}.#{name}_attributes(params)"
|
95
|
+
when "accept_order", "reject_order"
|
96
|
+
"#{variable}.#{name.gsub('_order', '')}(params)"
|
97
|
+
when "complete_order"
|
98
|
+
"#{variable}.#{name.gsub('_order', '')}"
|
99
|
+
else
|
100
|
+
"#{base}.#{chain_name}.#{name}(params)"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def url
|
105
|
+
"http://developer.ticketevolution.com/endpoints/#{get(@xml, 'slug')}"
|
106
|
+
end
|
107
|
+
|
108
|
+
def variable
|
109
|
+
"@#{chain_name.singularize}"
|
110
|
+
end
|
111
|
+
|
112
|
+
def underscore(str)
|
113
|
+
str.gsub(' ', '').underscore
|
114
|
+
end
|
115
|
+
|
116
|
+
def get(subject, part)
|
117
|
+
subject.xpath(part).children.to_s
|
118
|
+
end
|
119
|
+
|
120
|
+
def actions
|
121
|
+
@xml.xpath('endpoint-action').xpath('endpoint-action').sort_by{|a| a.xpath('name').children.to_s}
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/examples/events.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'ticket_evolution'
|
4
|
+
|
5
|
+
# Run from project root:
|
6
|
+
# > gem install bundler
|
7
|
+
# > bundle install
|
8
|
+
# > ruby examples/events.rb
|
9
|
+
|
10
|
+
# Fill these with the credentials for consuming the API
|
11
|
+
API_TOKEN = ""
|
12
|
+
API_SECRET = ""
|
13
|
+
|
14
|
+
# Create a client connection to the Ticket Evolution API
|
15
|
+
client = TicketEvolution::Connection.new(
|
16
|
+
:token => API_TOKEN,
|
17
|
+
:secret => API_SECRET
|
18
|
+
)
|
19
|
+
|
20
|
+
# The interface to events can be passed filtering parameters as documented in
|
21
|
+
# (http://developer.ticketevolution.com/endpoints/events#list).
|
22
|
+
# For example, pulling 10 events for a particular category
|
23
|
+
events = client.events.list(:category_id => 24, :per_page => 10)
|
24
|
+
|
25
|
+
# Each call to the API endpoint that returns a collection returns a
|
26
|
+
# TicketEvolution::Collection. This object responds to all Enumerable
|
27
|
+
# methods (each, collect, etc). It will initialize each object in the
|
28
|
+
# collection as a TicketEvolution model instance.
|
29
|
+
|
30
|
+
event_names = events.collect(&:name)
|
31
|
+
puts "These are all the events: #{event_names.join(", ")}"
|
32
|
+
|
33
|
+
# Our events each get initialized as a TicketEvolution::Event
|
34
|
+
# object. They will respond to all the attribute values that the event API
|
35
|
+
# call returned. The model even handles nested associations.
|
36
|
+
# For example, each event is attached to a venue.
|
37
|
+
|
38
|
+
events.each do |event|
|
39
|
+
puts "Event '#{event.name}' is at venue '#{event.venue.name}' and occurs at '#{event.occurs_at}'"
|
40
|
+
end
|
41
|
+
|
42
|
+
# If we want to access a single event, and not just query for a collection,
|
43
|
+
# we can access by ID.
|
44
|
+
|
45
|
+
event = client.events.show(events.first.id)
|
46
|
+
puts "Found a single event: #{event.name}"
|
47
|
+
|
48
|
+
# When you run this, you should see something similar to this output. Please
|
49
|
+
# keep in mind that the events may be different because the events' date may
|
50
|
+
# have already passed.
|
51
|
+
|
52
|
+
# These are all the events: 2012 Ryder Cup Weekly Grounds (Tuesday through Sunday), 2012 Ryder Cup Practice Rounds, 2012 Ryder Cup Practice Rounds, 2012 Ryder Cup Competition Rounds, 2012 Ryder Cup Competition Rounds, 2012 Ryder Cup Competition Rounds, Masters, 2012 Masters - Sunday, 2012 Masters - Monday (Practice Round), 2012 Masters - Friday
|
53
|
+
# Event '2012 Ryder Cup Weekly Grounds (Tuesday through Sunday)' is at venue 'Medinah Country Club' and occurs at '2012-09-25 08:00:00 UTC'
|
54
|
+
# Event '2012 Ryder Cup Practice Rounds' is at venue 'Medinah Country Club' and occurs at '2012-09-26 09:00:00 UTC'
|
55
|
+
# Event '2012 Ryder Cup Practice Rounds' is at venue 'Medinah Country Club' and occurs at '2012-09-27 09:00:00 UTC'
|
56
|
+
# Event '2012 Ryder Cup Competition Rounds' is at venue 'Medinah Country Club' and occurs at '2012-09-28 09:00:00 UTC'
|
57
|
+
# Event '2012 Ryder Cup Competition Rounds' is at venue 'Medinah Country Club' and occurs at '2012-09-29 09:00:00 UTC'
|
58
|
+
# Event '2012 Ryder Cup Competition Rounds' is at venue 'Medinah Country Club' and occurs at '2012-09-30 09:00:00 UTC'
|
59
|
+
# Event 'Masters' is at venue 'Augusta National Golf Club' and occurs at '2012-04-07 07:00:00 UTC'
|
60
|
+
# Event '2012 Masters - Sunday' is at venue 'Augusta National Golf Club' and occurs at '2012-04-08 13:00:00 UTC'
|
61
|
+
# Event '2012 Masters - Monday (Practice Round)' is at venue 'Augusta National Golf Club' and occurs at '2012-04-02 10:00:00 UTC'
|
62
|
+
# Event '2012 Masters - Friday' is at venue 'Augusta National Golf Club' and occurs at '2012-04-06 13:00:00 UTC'
|
63
|
+
# Found a single event: 2012 Ryder Cup Weekly Grounds (Tuesday through Sunday)
|
64
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Interacting with an endpoint
|
2
|
+
============================
|
3
|
+
|
4
|
+
@connection.brokerages.list # => builds a TicketEvolution::Collection object containing
|
5
|
+
# a collection of TicketEvolution::Brokerage model objects
|
6
|
+
|
7
|
+
@connection.brokerages.show(id) # => builds a TicketEvolution::Brokerage model object
|
8
|
+
|
9
|
+
@connection.brokerages.search(params) # => returns a TicketEvolution::Collection object containing
|
10
|
+
# a collection of TicketEvolution::Brokerage model objects
|
11
|
+
|
12
|
+
Alias methods
|
13
|
+
-------------
|
14
|
+
To more directly match ActiveRecord style, the following aliases exist and can be called on endpoints which include thier equivalent method:
|
15
|
+
|
16
|
+
#find aliases #show
|
17
|
+
|
18
|
+
@connection.brokerages.find(1)
|
19
|
+
# is the same as calling
|
20
|
+
@connection.brokerages.show(1)
|
21
|
+
|
22
|
+
#update_attributes indirectly aliases #update
|
23
|
+
_A call to #update_attributes will update the attributes on the instance as well as calling #update on the endpoint._
|
24
|
+
|
25
|
+
@brokerage = @connection.brokerages.find(1)
|
26
|
+
@brokerage.update_attributes(params)
|
27
|
+
# is an easy way to call
|
28
|
+
TicketEvolution::Brokerages.new({:connection => @connection, :id => 1}).update(params)
|
29
|
+
|
30
|
+
#save indirectly aliases #update
|
31
|
+
|
32
|
+
@brokerage = @connection.brokerages.find(1)
|
33
|
+
@brokerage.attributes = params
|
34
|
+
@brokerage.save
|
35
|
+
# is an easy way to call
|
36
|
+
TicketEvolution::Brokerages.new({:connection => @connection, :id => 1}).update(params)
|
37
|
+
|
38
|
+
#all aliases #list
|
39
|
+
_If you use this, be aware that the list endpoints max out at 100 results, so #all defaultly has the following defined parameter - :limit => 100_
|
40
|
+
|
41
|
+
@connection.brokerages.all
|
42
|
+
# is the same as calling
|
43
|
+
@connection.brokerages.list
|
44
|
+
|
45
|
+
Available endpoints
|
46
|
+
-------------------
|
47
|
+
Click on the links next to each endpoint for more detail.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Introduction [![Build Status](https://secure.travis-ci.org/ticketevolution/ticketevolution-ruby.png)](http://travis-ci.org/ticketevolution/ticketevolution-ruby)
|
2
|
+
============
|
3
|
+
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.
|
4
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
All API documentation can be found at [http://developer.ticketevolution.com](http://developer.ticketevolution.com/).
|
8
|
+
|
9
|
+
_WARNING: This gem is not ready for prime time. The transactions endpoint has not been added and a few implementation details have yet to be worked out. Known issues and missing functionality are documented in the [Github Issues](https://github.com/ticketevolution/ticketevolution-ruby/issues)._
|
10
|
+
|
11
|
+
**Rubies supported**
|
12
|
+
|
13
|
+
- 1.9.2
|
14
|
+
- 1.8.7
|
15
|
+
- ree
|
16
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Objects
|
2
|
+
=======
|
3
|
+
There are four main object types:
|
4
|
+
|
5
|
+
**Connection objects**
|
6
|
+
|
7
|
+
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](https://settings.ticketevolution.com/brokerage/credentials). You must have an active brokerage account with Ticket Evolution._
|
8
|
+
|
9
|
+
# Example connection configuration (defaults shown)
|
10
|
+
@connection = TicketEvolution::Connection.new({
|
11
|
+
:token => '', # => (required) The API token, used to identify you
|
12
|
+
:secret => '', # => (required) The API secret, used to sign requests
|
13
|
+
# More info: [http://developer.ticketevolution.com/signature_tool](http://developer.ticketevolution.com/signature_tool))
|
14
|
+
:mode => :sandbox, # => (optional) Specifies the server environment to use
|
15
|
+
Valid options: :production or :sandbox
|
16
|
+
:version => 8 # => (optional) API version to use - the only available
|
17
|
+
version at the time of this writing is 8
|
18
|
+
})
|
19
|
+
|
20
|
+
**Endpoint objects**
|
21
|
+
|
22
|
+
These are always (except in the case of Search) pluralized class names and match the endpoints listed at [http://developer.ticketevolution.com](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.
|
23
|
+
|
24
|
+
@connection.brokerages
|
25
|
+
|
26
|
+
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.
|
27
|
+
|
28
|
+
@client = @connection.clients.show(1)
|
29
|
+
@address = @client.addresses.show(1)
|
30
|
+
|
31
|
+
**Model objects**
|
32
|
+
|
33
|
+
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.
|
34
|
+
|
35
|
+
@connection.brokerages.show(1) # => an instance of TicketEvolution::Brokerage with an id of 1
|
36
|
+
|
37
|
+
**Collection objects**
|
38
|
+
|
39
|
+
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.
|
40
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module TicketEvolution
|
2
|
+
class Clients
|
3
|
+
class Addresses < TicketEvolution::Endpoint
|
4
|
+
include TicketEvolution::Modules::Create
|
5
|
+
include TicketEvolution::Modules::List
|
6
|
+
include TicketEvolution::Modules::Show
|
7
|
+
include TicketEvolution::Modules::Update
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|