ticketfly_plus 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e655a91b8d779ee510c945be6cc090159779c5b
4
- data.tar.gz: e1617445ae1ad94583fd1420271e9fd9398f4dda
3
+ metadata.gz: 8ea445457d503aec27cf2870793d60f32754ec80
4
+ data.tar.gz: 226d703bbd1704e51b22bb69eff2bf28d50cec32
5
5
  SHA512:
6
- metadata.gz: 5a65e2285a961eb5fa26f69330db99b9616034e302cb16cfa66e159e4332cb43b3ec1289a41221393a4511e623195859121ba6647561edb8b735fa3b7c0052fd
7
- data.tar.gz: c554abdf248cd2b9fef21dc329ec788634cd4e5af087e95cbfb06a2c61cc4cfccc52499aeb9cf13f1b2f9355035f3c1a65106803376cdf2164ea87010bb2277b
6
+ metadata.gz: ca3b2c1f2120722385fc23521d02506aac6866dc272bf77298bb8a895f544a30106c3395e3d888852e7e3afb1c9d6dd3110500669098494d34f71aac1f95d4d2
7
+ data.tar.gz: d10633af6a8dc618df4e1d0e882669527b7dac7b7cbf01b493f8f9b33c5795982cfebc828db0739f02dcec87d29b72c95e59f6a9773ddc7e6f77b5786c4fe041
data/README.md CHANGED
@@ -4,7 +4,7 @@ Get usable ticketfly data.
4
4
 
5
5
  #### Work in progress
6
6
 
7
- Testing, Shareasale url functionality, Standard Location params
7
+ Testing, Standard Location params
8
8
 
9
9
  ### Testing
10
10
 
@@ -34,6 +34,43 @@ Or install it yourself as:
34
34
 
35
35
  data = TicketflyPlus::Responses::Events.new(response)
36
36
 
37
+ ### Shareasale
38
+
39
+ You must have an environment variable to use.
40
+ ENV['SHAREASALE'] must be set to your shareasale id.
41
+
42
+ Example
43
+
44
+ data.events[0].share_a_sale
45
+
46
+ It parses the ticketPurchaseUrl into a ShareASale url.
47
+
48
+ ### Requestors Params
49
+
50
+ Params are passed in when requestor is called. Pass them in as symbols, ie, :artistName => 'your_artist_here'.
51
+
52
+ #### Events
53
+ :artistName
54
+ :fieldGroup
55
+ :fields
56
+ :fromDate
57
+ :maxResults
58
+ :orgId
59
+ :pageNum
60
+ :q
61
+ :skin
62
+ :tflyTicketed
63
+ :thruDate
64
+ :venueId
65
+
66
+ ##### Non standard location params
67
+
68
+ :geo
69
+ :ip
70
+ :clientip
71
+ :distance
72
+
73
+
37
74
  ##### Work in progress...
38
75
 
39
76
  ## Contributing
@@ -1,6 +1,19 @@
1
1
  module TicketflyPlus
2
2
  class Objects
3
- class Event
3
+ class Base
4
+
5
+ private
6
+
7
+ def get_param_info(event_param_items, param_class)
8
+ arr = Array.new
9
+ if !event_param_items.empty?
10
+ event_param_items.each {|item| arr.push param_class.new(item)}
11
+ end
12
+ arr
13
+ end
14
+ end
15
+
16
+ class Event < Base
4
17
  attr_accessor :additionalInfo
5
18
  attr_accessor :additionalTicketText
6
19
  attr_accessor :ageLimit
@@ -48,78 +61,63 @@ module TicketflyPlus
48
61
  @additionalTicketText = event['additionalTicketText']
49
62
  @ageLimit = event['ageLimit']
50
63
  @ageLimitCode = event['ageLimitCode']
51
- @dateCreated = event['dateCreated'] != nil ? DateTime.parse(event['dateCreated']) : event['dateCreated']
52
- @doorsDate = event['doorsDate'] != nil ? DateTime.parse(event['doorsDate']) : event['doorsDate']
53
- @endDate = event['endDate'] != nil ? DateTime.parse(event['endDate']) : event['endDate']
64
+ @dateCreated = !event['dateCreated'].nil? ? DateTime.parse(event['dateCreated']) : event['dateCreated']
65
+ @doorsDate = !event['doorsDate'].nil? ? DateTime.parse(event['doorsDate']) : event['doorsDate']
66
+ @endDate = !event['endDate'].nil? ? DateTime.parse(event['endDate']) : event['endDate']
54
67
  @eventStatus = event['eventStatus']
55
68
  @eventStatusCode = event['eventStatusCode']
56
69
  @eventStatusMessage = event['eventStatusMessage']
57
- @externalTicketingUrls = event['externalTicketingUrls'] != nil ? get_ticketing_urls(event['externalTicketingUrls']) : event['externalTicketingUrls']
70
+ @externalTicketingUrls = !event['externalTicketingUrls'].nil? ? get_param_info(event['externalTicketingUrls'], Objects::TicketingUrl ) : event['externalTicketingUrls']
58
71
  @facebookEventId = event['facebookEventId']
59
72
  @facebookEventIdString = event['facebookEventIdString']
60
73
  @featured = event['featured']
61
- @headliners = event['headliners'] != nil ? get_attractions(event['headliners']) : event['headliners']
74
+ @headliners = !event['headliners'].nil? ? get_param_info(event['headliners'], Objects::Attraction) : event['headliners']
62
75
  @headlinersName = event['headlinersName']
63
76
  @id = event['id']
64
- @image = event['image'] != nil ? Objects::Image.new(event['image']) : event['image']
65
- @lastUpdated = event['lastUpdated'] != nil ? DateTime.parse(event['lastUpdated']) : event['lastUpdated']
77
+ @image = !event['image'].nil? ? Objects::Image.new(event['image']) : event['image']
78
+ @lastUpdated = !event['lastUpdated'].nil? ? DateTime.parse(event['lastUpdated']) : event['lastUpdated']
66
79
  @name = event['name']
67
- @offSaleDate = event['offSaleDate'] != nil ? DateTime.parse(event['offSaleDate']) : event['offSaleDate']
68
- @onSaleDate = event['onSaleDate'] != nil ? DateTime.parse(event['onSaleDate']) : event['onSaleDate']
69
- @onSaleDates = event['onSaleDates'] != nil ? get_on_sale_dates(event['onSaleDates']) : event['onSaleDates']
70
- @org = event['org'] != nil ? Objects::Org.new(event['org']) : event['org']
80
+ @offSaleDate = !event['offSaleDate'].nil? ? DateTime.parse(event['offSaleDate']) : event['offSaleDate']
81
+ @onSaleDate = !event['onSaleDate'].nil? ? DateTime.parse(event['onSaleDate']) : event['onSaleDate']
82
+ @onSaleDates = !event['onSaleDates'].nil? ? get_param_info(event['onSaleDates'], Objects::SaleDate) : event['onSaleDates']
83
+ @org = !event['org'].nil? ? Objects::Org.new(event['org']) : event['org']
71
84
  @promoterName = event['promoterName']
72
- @publishDate = event['publishDate'] != nil ? DateTime.parse(event['publishDate']) : event['publishDate']
85
+ @publishDate = !event['publishDate'].nil? ? DateTime.parse(event['publishDate']) : event['publishDate']
73
86
  @published = event['published']
74
- @purchaseSkin = event['purchaseSkin'] != nil ? Objects::PurchaseSkin.new(event['purchaseSkin']) : event['purchaseSkin']
87
+ @purchaseSkin = !event['purchaseSkin'].nil? ? Objects::PurchaseSkin.new(event['purchaseSkin']) : event['purchaseSkin']
75
88
  @showType = event['showType']
76
89
  @showTypeCode = event['showTypeCode']
77
90
  @slug = event['slug']
78
- @sponsorImage = event['sponsorImage'] != nil ? Objects::Image.new(event['sponsorImage']) : event['sponsorImage']
91
+ @sponsorImage = !event['sponsorImage'].nil? ? Objects::Image.new(event['sponsorImage']) : event['sponsorImage']
79
92
  @sponsorName = event['sponsorName']
80
- @startDate = event['startDate'] != nil ? DateTime.parse(event['startDate']) : event['startDate']
81
- @supports = event['supports'] != nil ? get_attractions(event['supports']) : event['supports']
93
+ @startDate = !event['startDate'].nil? ? DateTime.parse(event['startDate']) : event['startDate']
94
+ @supports = !event['supports'].nil? ? get_param_info(event['supports'], Objects::Attraction) : event['supports']
82
95
  @supportsName = event['supportsName']
83
96
  @ticketPrice = event['ticketPrice']
84
97
  @ticketPurchaseUrl = event['ticketPurchaseUrl']
85
98
  @topLineInfo = event['topLineInfo']
86
99
  @urlEventDetailsUrl = event['urlEventDetailsUrl']
87
- @venue = event['venue'] != nil ? Objects::Venue.new(event['venue']) : event['venue']
100
+ @venue = !event['venue'].nil? ? Objects::Venue.new(event['venue']) : event['venue']
88
101
  end
89
102
 
90
- private
91
-
92
- def get_on_sale_dates(dates)
93
- arr = Array.new
94
- if dates.length > 0
95
- dates.each do |date|
96
- arr.push Objects::SaleDate.new(date)
97
- end
98
- end
99
- arr
100
- end
101
-
102
- def get_ticketing_urls(urls)
103
- arr = Array.new
104
- if urls.length > 0
105
- urls.each do |url|
106
- arr.push Objects::TicketingUrl.new(url)
107
- end
108
- end
109
- arr
110
- end
111
-
112
- def get_attractions(attractions)
113
- arr = Array.new
114
- if attractions.length > 0
115
- attractions.each do |attraction|
116
- arr.push Objects::Attraction.new(attraction)
117
- end
103
+ def share_a_sale
104
+ if ENV['SHAREASALE']
105
+ s_url = 'http://www.shareasale.com/r.cfm?u=' + ENV['SHAREASALE'].to_s + '&b=234786&m=27601&afftrack=&urllink='
106
+ share_a_sale_url = s_url + @ticketPurchaseUrl.
107
+ gsub('&', '%26').
108
+ gsub('.', '%2E').
109
+ gsub('/', '%2F').
110
+ gsub('=', '%3D').
111
+ gsub('?', '%3F').
112
+ gsub('_', '%5F')
113
+ share_a_sale_url
114
+ else
115
+ url
118
116
  end
119
- arr
120
117
  end
121
118
  end
122
119
 
120
+
123
121
  class Org
124
122
  attr_accessor :id
125
123
  attr_accessor :name
@@ -160,7 +158,7 @@ module TicketflyPlus
160
158
  @city = venue['city']
161
159
  @country = venue['country']
162
160
  @id = venue['id']
163
- @image = venue['image'] != nil ? Objects::Image.new(venue['image']) : venue['image']
161
+ @image = !venue['image'].nil? ? Objects::Image.new(venue['image']) : venue['image']
164
162
  @lat = venue['lat']
165
163
  @lng = venue['lng']
166
164
  @metroCode = venue['metrocode']
@@ -186,7 +184,7 @@ module TicketflyPlus
186
184
  end
187
185
  end
188
186
 
189
- class Attraction
187
+ class Attraction < Base
190
188
  attr_accessor :embedAudio
191
189
  attr_accessor :embedVideo
192
190
  attr_accessor :eventDescription
@@ -208,29 +206,17 @@ module TicketflyPlus
208
206
  @embedVideo = attraction['embedVideo']
209
207
  @eventDescription = attraction['eventDescription']
210
208
  @id = attraction['id']
211
- @image = attraction['image'] != nil ? Objects::Image.new(attraction['image']) : attraction['image']
209
+ @image = !attraction['image'].nil? ? Objects::Image.new(attraction['image']) : attraction['image']
212
210
  @isMobileFriendlyBoolean = attraction['isMobileFriendlyBoolean']
213
211
  @name = attraction['name']
214
- @startTime = attraction['startTime'] != nil ? Time.parse(attraction['startTime']) : attraction['startTime']
212
+ @startTime = !attraction['startTime'].nil? ? Time.parse(attraction['startTime']) : attraction['startTime']
215
213
  @twitterScreenName = attraction['twitterScreenName']
216
214
  @urlFacebook = attraction['urlFacebook']
217
215
  @urlMySpace = attraction['urlMySpace']
218
216
  @urlOfficialWebsite = attraction['urlOfficialWebsite']
219
217
  @urlPurchaseMusic = attraction['urlPurchaseMusic']
220
218
  @urlTwitter = attraction['urlTwitter']
221
- @youtubeVideos = attraction['youtubeVideos'] != nil ? get_youtube_videos(attraction['youtubeVideos']) : attraction['youtubeVideos']
222
- end
223
-
224
- private
225
-
226
- def get_youtube_videos(videos)
227
- arr = Array.new
228
- if videos.length > 0
229
- videos.each do |video|
230
- arr.push Objects::YoutubeVideo.new(video)
231
- end
232
- end
233
- arr
219
+ @youtubeVideos = !attraction['youtubeVideos'].nil? ? get_param_info(attraction['youtubeVideos'], Objects::YoutubeVideo) : attraction['youtubeVideos']
234
220
  end
235
221
  end
236
222
 
@@ -284,7 +270,7 @@ module TicketflyPlus
284
270
  private
285
271
 
286
272
  def check_nil(image)
287
- image != nil ? Objects::ImageDetails.new(image) : image
273
+ !image.nil? ? Objects::ImageDetails.new(image) : image
288
274
  end
289
275
  end
290
276
 
@@ -309,6 +295,7 @@ module TicketflyPlus
309
295
  @startDate = date['startDate'] != nil ? DateTime.parse(date['startDate']) : date['startDate']
310
296
  end
311
297
  end
298
+
312
299
  class PurchaseSkin
313
300
  attr_accessor :backgroundColor
314
301
  attr_accessor :backgroundFixed
@@ -6,10 +6,8 @@ module TicketflyPlus
6
6
 
7
7
  class Base
8
8
  BASE_STRING = 'http://www.ticketfly.com/api'
9
- attr_accessor :params
10
9
 
11
10
  def initialize(options={})
12
- @params = Array.new
13
11
  end
14
12
 
15
13
  def request(string)
@@ -24,6 +22,10 @@ module TicketflyPlus
24
22
 
25
23
  private
26
24
 
25
+ def get_params_list
26
+ self.instance_variables.map {|var| self.instance_variable_get(var)}
27
+ end
28
+
27
29
  def stringify(prefix, value)
28
30
  value != nil ? ("&" + prefix + fill_spaces(value)) : ''
29
31
  end
@@ -66,52 +68,52 @@ module TicketflyPlus
66
68
 
67
69
  def initialize(options={})
68
70
  super
69
- @params.push(@artistName = stringify('artistName=', options[:artistName]))
70
- @params.push(@fields = stringify('fields=', options[:fields]))
71
- @params.push(@fieldsGroup = stringify('fieldsGroup=', options[:fieldsGroup]))
72
- @params.push(@fromDate = stringify('fromDate=', options[:fromDate]))
73
- @params.push(@maxResults = stringify('maxResults=', options[:maxResults]))
74
- @params.push(@orgId = stringify('orgId=', options[:orgId]))
75
- @params.push(@pageNum = stringify('pageNum=', options[:pageNum]))
76
- @params.push(@q = stringify('q=', options[:q]))
77
- @params.push(@skin = stringify('skin=', options[:skin]))
78
- @params.push(@tflyTicketed = stringify('tflyTicketed=', options[:tflyTicketed]))
79
- @params.push(@thruDate = stringify('thruDate=', options[:thruDate]))
80
- @params.push(@venueId = stringify('venueId=', options[:venueId]))
81
- @params.push(@geo = stringify('location=geo:', options[:geo]))
82
- @params.push(@ip = stringify('location=ip:', options[:ip]))
83
- @params.push(@clientip = stringify('location=clientip', options[:clientip]))
84
- @params.push(@distance = stringify('distance=', options[:distance]))
71
+ @artistName = stringify('artistName=', options[:artistName])
72
+ @fields = stringify('fields=', options[:fields])
73
+ @fieldsGroup = stringify('fieldsGroup=', options[:fieldsGroup])
74
+ @fromDate = stringify('fromDate=', options[:fromDate])
75
+ @maxResults = stringify('maxResults=', options[:maxResults])
76
+ @orgId = stringify('orgId=', options[:orgId])
77
+ @pageNum = stringify('pageNum=', options[:pageNum])
78
+ @q = stringify('q=', options[:q])
79
+ @skin = stringify('skin=', options[:skin])
80
+ @tflyTicketed = stringify('tflyTicketed=', options[:tflyTicketed])
81
+ @thruDate = stringify('thruDate=', options[:thruDate])
82
+ @venueId = stringify('venueId=', options[:venueId])
83
+ @geo = stringify('location=geo:', options[:geo])
84
+ @ip = stringify('location=ip:', options[:ip])
85
+ @clientip = stringify('location=clientip', options[:clientip])
86
+ @distance = stringify('distance=', options[:distance])
85
87
 
86
88
  end
87
89
 
88
90
  def list
89
- string = EVENTS_STRING + '/list.json?' + @params.join.to_s
91
+ string = EVENTS_STRING + '/list.json?' + get_params_list.join.to_s
90
92
  request(string)
91
93
  end
92
94
 
93
95
  def upcoming
94
- string = EVENTS_STRING + '/upcoming.json?' + @params.join.to_s
96
+ string = EVENTS_STRING + '/upcoming.json?' + get_params_list.join.to_s
95
97
  request(string)
96
98
  end
97
99
 
98
100
  def featured
99
- string = EVENTS_STRING + '/featured.json?' + @params.join.to_s
101
+ string = EVENTS_STRING + '/featured.json?' + get_params_lists.join.to_s
100
102
  request(string)
101
103
  end
102
104
 
103
105
  def just_announced
104
- string = EVENTS_STRING + '/justAnnounced.json?' + @params.join.to_s
106
+ string = EVENTS_STRING + '/justAnnounced.json?' + get_params_list.join.to_s
105
107
  request(string)
106
108
  end
107
109
 
108
110
  def past
109
- string = EVENTS_STRING + '/past.json?' + @params.join.to_s
111
+ string = EVENTS_STRING + '/past.json?' + get_params_list.join.to_s
110
112
  request(string)
111
113
  end
112
114
 
113
115
  def on_sale
114
- string = EVENTS_STRING + '/onsale.json?' + @params.join.to_s
116
+ string = EVENTS_STRING + '/onsale.json?' + get_params_list.join.to_s
115
117
  request(string)
116
118
  end
117
119
  end
@@ -126,15 +128,15 @@ module TicketflyPlus
126
128
 
127
129
  def initialize(options = {})
128
130
  super
129
- @params.push(@eventId = stringify('eventId=', options[:eventId]))
130
- @params.push(@fields = stringify('fields=', options[:fields]))
131
- @params.push(@fieldsGroup = stringify('fieldsGroup=', options[:fieldsGroup]))
132
- @params.push(@showRelatedEvents = stringify('showRelatedEvents=', options[:showRelatedEvents]))
133
- @params.push(@skin = stringify('skin=', options[:skin]))
131
+ @eventId = stringify('eventId=', options[:eventId])
132
+ @fields = stringify('fields=', options[:fields])
133
+ @fieldsGroup = stringify('fieldsGroup=', options[:fieldsGroup])
134
+ @showRelatedEvents = stringify('showRelatedEvents=', options[:showRelatedEvents])
135
+ @skin = stringify('skin=', options[:skin])
134
136
  end
135
137
 
136
138
  def event
137
- string = EVENT_STRING + '/event.json?' + @params.join.to_s
139
+ string = EVENT_STRING + '/event.json?' + get_params_list.join.to_s
138
140
  end
139
141
 
140
142
  end
@@ -148,14 +150,14 @@ module TicketflyPlus
148
150
 
149
151
  def initialize(options={})
150
152
  super
151
- @params.push(@maxResults = stringify('maxResults=', options[:maxResults]))
152
- @params.push(@orgId = stringify('orgId=', options[:orgId]))
153
- @params.push(@pageNum = stringify('pageNum=', options[:pageNum]))
154
- @params.push(@venueId = stringify('venueId=', options[:venueId]))
153
+ @maxResults = stringify('maxResults=', options[:maxResults])
154
+ @orgId = stringify('orgId=', options[:orgId])
155
+ @pageNum = stringify('pageNum=', options[:pageNum])
156
+ @venueId = stringify('venueId=', options[:venueId])
155
157
  end
156
158
 
157
159
  def list
158
- string = VENUES_STRING + '/list.json?' + @params.join.to_s
160
+ string = VENUES_STRING + '/list.json?' + get_params_list.join.to_s
159
161
  request(string)
160
162
  end
161
163
  end
@@ -168,13 +170,13 @@ module TicketflyPlus
168
170
 
169
171
  def initialize(options={})
170
172
  super
171
- @params.push(@maxResults = stringify('maxResults=', options[:maxResults]))
172
- @params.push(@orgId = stringify('orgId=', options[:orgId]))
173
- @params.push(@pageNum = stringify('pageNum=', options[:pageNum]))
173
+ @maxResults = stringify('maxResults=', options[:maxResults])
174
+ @orgId = stringify('orgId=', options[:orgId])
175
+ @pageNum = stringify('pageNum=', options[:pageNum])
174
176
  end
175
177
 
176
178
  def list()
177
- string = ORGS_STRING + '/list.json?' + @params.join.to_s
179
+ string = ORGS_STRING + '/list.json?' + get_params_list.join.to_s
178
180
  request(string)
179
181
  end
180
182
  end
@@ -25,7 +25,7 @@ module TicketflyPlus
25
25
  private
26
26
 
27
27
  def check_nil(response)
28
- response != nil ? response : nil
28
+ !response.nil? ? response : nil
29
29
  end
30
30
  end
31
31
 
@@ -35,8 +35,8 @@ module TicketflyPlus
35
35
 
36
36
  def initialize(response)
37
37
  super
38
- @events = check_nil(response['events']) != nil ? get_events(response['events']) : response['events']
39
- @org = response['org'] != nil ? TicketflyPlus::Objects::Org.new(response['org']) : response['org']
38
+ @events = !check_nil(response['events']).nil? ? get_events(response['events']) : response['events']
39
+ @org = !response['org'].nil? ? TicketflyPlus::Objects::Org.new(response['org']) : response['org']
40
40
  end
41
41
 
42
42
  def get_events(events)
@@ -55,7 +55,7 @@ module TicketflyPlus
55
55
 
56
56
  def initialize
57
57
  super
58
- @orgs = check_nil(response['orgs']) != nil ? get_orgs(response['orgs']) : response['orgs']
58
+ @orgs = !check_nil(response['orgs']).nil? ? get_orgs(response['orgs']) : response['orgs']
59
59
  end
60
60
 
61
61
  def get_orgs(orgs)
@@ -74,7 +74,7 @@ module TicketflyPlus
74
74
 
75
75
  def initialize
76
76
  super
77
- @venues = check_nil(response['venues']) != nil ? get_venues(response['venues']) : response['venues']
77
+ @venues = !check_nil(response['venues']).nil? ? get_venues(response['venues']) : response['venues']
78
78
  end
79
79
 
80
80
  def get_venues(venues)
@@ -1,3 +1,3 @@
1
1
  module TicketflyPlus
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ticketfly_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Nathaniel Miller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-10 00:00:00.000000000 Z
11
+ date: 2014-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler