Skip to content

Commit 8ae91ea

Browse files
committed
Enhanced Documentation and Classification
1 parent 03f2a79 commit 8ae91ea

5 files changed

Lines changed: 232 additions & 6 deletions

File tree

README.md

Lines changed: 211 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,191 @@ Wraps the Ticketmaster API in easy to access functions.
1414
8. Get Classification
1515
9. Get Venue
1616

17-
#### Example:
17+
#### Methods:
18+
For a list of parameters, check http://developer.ticketmaster.com/
19+
20+
| Discovery Methods | Required |
21+
| ---------------------- |:-------------:|
22+
| search_events | |
23+
| get_event | id |
24+
| get_event_images | id |
25+
| search_attractions | |
26+
| get_attraction | id |
27+
| search_classifications | |
28+
| get_classification | id |
29+
| search_venues | |
30+
| get_venue | id |
31+
32+
Pass optional params to the call via options.params:
33+
```
34+
require 'ticketmaster'
35+
36+
params = {page: 5, size: 10, source: 'ticketmaster'}
37+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
38+
response = client.search_events(params: params)
39+
events = response.results
40+
```
41+
42+
##### Search Events(options={})
43+
```
44+
require 'ticketmaster'
45+
46+
params = {page: 5, size: 10, source: 'ticketmaster'}
47+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
48+
response = client.search_events(params: params)
49+
events = response.results
50+
```
51+
52+
##### Get Event (id, options={})
53+
```
54+
require 'ticketmaster'
55+
56+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
57+
response = client.get_event('ID OF EVENT')
58+
events = response.results
59+
```
60+
61+
##### Get Event Images (id, options={})
62+
```
63+
require 'ticketmaster'
64+
65+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
66+
response = client.get_event_images('ID OF EVENT')
67+
events = response.results
68+
```
69+
70+
##### Search Attractions (options={})
71+
```
72+
require 'ticketmaster'
73+
74+
params = {page: 5, size: 10, source: 'ticketmaster'}
75+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
76+
response = client.search_attractions(params: params)
77+
events = response.results
78+
```
79+
80+
##### Get Attraction(id, options={})
81+
```
82+
require 'ticketmaster'
83+
84+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
85+
response = client.get_attraction('ID OF ATTRACTION')
86+
events = response.results
87+
```
88+
89+
##### Search Classifications (options={})
90+
```
91+
require 'ticketmaster'
92+
93+
params = {page: 5, size: 10, source: 'ticketmaster'}
94+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
95+
response = client.search_classifications(params: params)
96+
events = response.results
97+
```
98+
99+
##### Get Classification (id, options={})
100+
```
101+
require 'ticketmaster'
102+
103+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
104+
response = client.get_classification('ID OF CLASSIFICATION')
105+
events = response.results
106+
```
107+
108+
##### Search Venues (options={})
109+
```
110+
require 'ticketmaster'
111+
112+
params = {page: 5, size: 10, source: 'ticketmaster'}
113+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
114+
response = client.search_venues(params: params)
115+
events = response.results
116+
```
117+
118+
##### Get Venue(id, options={})
119+
```
120+
require 'ticketmaster'
121+
122+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
123+
response = client.get_venue('ID OF VENUE')
124+
events = response.results
125+
```
126+
127+
#### Objects:
128+
129+
##### Search Results
130+
Methods:
131+
* results
132+
* current_page
133+
* total_pages
134+
* next_page
135+
* previous_page
136+
* next_result
137+
* previous_result
138+
* reload
139+
140+
##### Event
141+
Methods:
142+
* id
143+
* name
144+
* description
145+
* embedded
146+
* dates
147+
* start
148+
* end
149+
* timezone
150+
* images
151+
* get_images
152+
* classifications
153+
* attractions
154+
* venues
155+
* reload
156+
157+
##### Venue
158+
Methods:
159+
* id
160+
* name
161+
* address
162+
* state
163+
* city
164+
* country
165+
* country_code
166+
* location
167+
* timezone
168+
* postal_code
169+
* url
170+
* reload
171+
172+
##### Image
173+
Methods:
174+
* url
175+
* ratio
176+
* width
177+
* height
178+
* is_fallback?
179+
180+
##### Classification
181+
Methods:
182+
* id
183+
* name
184+
* reload
185+
* genres
186+
* subgenres
187+
* type
188+
189+
##### Attraction
190+
Methods:
191+
* id
192+
* name
193+
* type
194+
* url
195+
* locale
196+
* images
197+
* classifications
198+
* reload
199+
200+
201+
#### Examples:
18202
```
19203
require 'ticketmaster'
20204
@@ -23,3 +207,29 @@ response = client.search_events
23207
event = response.results.first
24208
event.get_images
25209
```
210+
211+
```
212+
require 'ticketmaster'
213+
214+
params = {page: 5, size: 10, source: 'ticketmaster'}
215+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
216+
response = client.search_events(params: params)
217+
events = response.results
218+
```
219+
220+
```
221+
require 'ticketmaster'
222+
223+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
224+
response = client.search_venues
225+
venue = response.results.first
226+
venue.address
227+
```
228+
229+
```
230+
require 'ticketmaster'
231+
232+
client = Ticketmaster.client(apikey: 'YOUR API KEY')
233+
response = client.search_events
234+
next = response.next_result
235+
```

lib/ticketmaster/clients/discovery.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ def search_classifications(options={})
5252
Result.search(response, request, 'classifications')
5353
end
5454

55-
def get_classification(id, options={})
55+
def get_classification(id, type, options={})
5656
options[:version] ||= 'v2'
5757

58-
request = Request.new("discovery/#{options[:version]}/classifications/#{id}", {}, self)
58+
request = Request.new("discovery/#{options[:version]}/#{type}/#{id}", {}, self)
5959
response = request.get
6060
Result.create(response, request, 'Ticketmaster::Classification')
6161
end

lib/ticketmaster/results/classification.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
module Ticketmaster
22
class Classification < Result
33
def id
4-
data['segment']['id']
4+
data['id'] || data['segment']['id']
5+
end
6+
7+
def name
8+
data['name'] || data['segment']['name']
9+
end
10+
11+
def genres
12+
Result.array(data['segment']['_embedded']['genres'], request, 'Ticketmaster::Classification') if data['segment']['_embedded']['genres']
13+
end
14+
15+
def subgenres
16+
Result.array(data['segment']['_embedded']['subgenres'], request, 'Ticketmaster::Classification') if data['segment']['_embedded']['subgenres']
17+
end
18+
19+
def type
20+
data['_links']['self']['href'].match(/(?<=\/discovery\/v\d\/)[a-z\/]+(?=\/)/)[0]
521
end
622

723
def reload
8-
data = request.client.get_classification(id).data
24+
data = request.client.get_classification(id, type).data
925
self
1026
end
1127
end

test/ticketmaster/clients/discovery_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_search_classifications
6767
def test_get_classification
6868
VCR.use_cassette('get_classification') do
6969
client = Ticketmaster::Client.new(apikey: 'TEST')
70-
results = client.get_classification('KZFzniwnSyZfZ7v7nn')
70+
results = client.get_classification('KZFzniwnSyZfZ7v7nn', 'classifications')
7171

7272
assert_equal 'KZFzniwnSyZfZ7v7nn', results.id
7373
end

ticketmaster-sdk-0.0.0.gem

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)