ticketfly_plus 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52f062d5b05d7f8365730167462a2d721bd9a495
4
- data.tar.gz: 42667ac83bce6a0db88499a0185f5d061983df20
3
+ metadata.gz: bfb1c1d91eeea9664dc2ce2832e7c84f1d2f6a8e
4
+ data.tar.gz: 7872661f5af56219f5f9e939a8a2c0096ee406e9
5
5
  SHA512:
6
- metadata.gz: c52be0a188663fcf8d4bf4367ed93caf58be2e8aae531a286322eb8d402e111fe588bd2cf23cf0b80ca29d764bd1ee7f127a937e37bba4677d2a7b098d058eb2
7
- data.tar.gz: faa8869e48c2b5e68d42680c942bf1a5c3c4b16d74b7f44fe8e102fd5209bb0543d75c54744c3bc11b907c106de45207bd837b5c32e32f7499a0399ca313fed4
6
+ metadata.gz: c56cab1a2eba25fa86cb23aeb9f735e08240e80275595edf90dd4c407e20f2e39e54fc6fbe4aaeeaf3f857f747169e9a7ddf27f2d187ef9c813d45dd3bad3542
7
+ data.tar.gz: 79993dda6c1f7adb77c7435df8e257f143e6680d495ba248d67ea26963da0372b3c1bc27945395eaa6ea592f3835124a3d0c1fca8831bc8b75c48d3057941df7
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # TicketflyPlus
1
+ # TicketflyPlus V 0.2.0
2
2
 
3
3
  Get usable ticketfly data.
4
4
 
@@ -28,7 +28,7 @@ Or install it yourself as:
28
28
 
29
29
  #### First make a request using the requestors:
30
30
 
31
- response = TicketflyPlus::Requestors::Events.new(:orgId => 1).upcoming
31
+ response = TicketflyPlus::Requestors::Events.new(:orgId => 1).upcoming.data
32
32
 
33
33
  #### Then pass the response to the corresponding TicketflyPlus response:
34
34
 
@@ -0,0 +1,125 @@
1
+ module TicketflyPlus
2
+ class Calls
3
+ class Base
4
+ attr_accessor :data
5
+ def initialize(options={})
6
+ end
7
+
8
+ def next_page
9
+ @data['nextPage'] ? self.class.new(next_page_string: @data['nextPage']) : @data['status']
10
+ end
11
+ end
12
+
13
+ class List < Base
14
+ CALL_STRING = '/list.json?'
15
+
16
+ def initialize(options={})
17
+ if options[:requestor_string]
18
+ @data = TicketflyPlus::Requestors::Base.request(
19
+ options[:requestor_string] +
20
+ CALL_STRING +
21
+ options[:params_list]
22
+ )
23
+ else
24
+ @data = TicketflyPlus::Requestors::Base.next_page_request(options[:next_page_string])
25
+ end
26
+ end
27
+ end
28
+
29
+ class Upcoming < Base
30
+ CALL_STRING = '/upcoming.json?'
31
+
32
+ def initialize(options={})
33
+ if options[:requestor_string]
34
+ @data = TicketflyPlus::Requestors::Base.request(
35
+ options[:requestor_string] +
36
+ CALL_STRING +
37
+ options[:params_list]
38
+ )
39
+ else
40
+ @data = TicketflyPlus::Requestors::Base.next_page_request(options[:next_page_string])
41
+ end
42
+ end
43
+ end
44
+
45
+ class Featured < Base
46
+ CALL_STRING = '/featured.json?'
47
+
48
+ def initialize(options={})
49
+ if options[:requestor_string]
50
+ @data = TicketflyPlus::Requestors::Base.request(
51
+ options[:requestor_string] +
52
+ CALL_STRING +
53
+ options[:params_list]
54
+ )
55
+ else
56
+ @data = TicketflyPlus::Requestors::Base.next_page_request(options[:next_page_string])
57
+ end
58
+ end
59
+ end
60
+
61
+ class JustAnnounced < Base
62
+ CALL_STRING = '/justAnnounced.json?'
63
+
64
+ def initialize(options={})
65
+ if options[:requestor_string]
66
+ @data = TicketflyPlus::Requestors::Base.request(
67
+ options[:requestor_string] +
68
+ CALL_STRING +
69
+ options[:params_list]
70
+ )
71
+ else
72
+ @data = TicketflyPlus::Requestors::Base.next_page_request(options[:next_page_string])
73
+ end
74
+ end
75
+ end
76
+
77
+ class Past < Base
78
+ CALL_STRING = '/past.json?'
79
+
80
+ def initialize(options={})
81
+ if options[:requestor_string]
82
+ @data = TicketflyPlus::Requestors::Base.request(
83
+ options[:requestor_string] +
84
+ CALL_STRING +
85
+ options[:params_list]
86
+ )
87
+ else
88
+ @data = TicketflyPlus::Requestors::Base.next_page_request(options[:next_page_string])
89
+ end
90
+ end
91
+ end
92
+
93
+ class OnSale < Base
94
+ CALL_STRING = '/onsale.json?'
95
+
96
+ def initialize(options={})
97
+ if options[:requestor_string]
98
+ @data = TicketflyPlus::Requestors::Base.request(
99
+ options[:requestor_string] +
100
+ CALL_STRING +
101
+ options[:params_list]
102
+ )
103
+ else
104
+ @data = TicketflyPlus::Requestors::Base.next_page_request(options[:next_page_string])
105
+ end
106
+ end
107
+ end
108
+
109
+ class Event < Base
110
+ CALL_STRING = '/event.json?'
111
+
112
+ def initialize(options={})
113
+ if options[:requestor_string]
114
+ @data = TicketflyPlus::Requestors::Base.request(
115
+ options[:requestor_string] +
116
+ CALL_STRING +
117
+ options[:params_list]
118
+ )
119
+ else
120
+ @data = TicketflyPlus::Requestors::Base.next_page_request(options[:next_page_string])
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
@@ -10,7 +10,7 @@ module TicketflyPlus
10
10
  def initialize(options={})
11
11
  end
12
12
 
13
- def request(string)
13
+ def self.request(string)
14
14
  url = URI.parse(BASE_STRING + string)
15
15
  request = Net::HTTP::Get.new(url.request_uri)
16
16
  http = Net::HTTP.new(url.host, url.port)
@@ -20,6 +20,16 @@ module TicketflyPlus
20
20
  response = JSON.parse(result.body)
21
21
  end
22
22
 
23
+ def self.next_page_request(string)
24
+ url = URI.parse(string)
25
+ request = Net::HTTP::Get.new(url.request_uri)
26
+ http = Net::HTTP.new(url.host, url.port)
27
+ result = http.start do |ht|
28
+ ht.request(request)
29
+ end
30
+ response = JSON.parse(result.body)
31
+ end
32
+
23
33
  private
24
34
 
25
35
  def get_params_list
@@ -87,52 +97,29 @@ module TicketflyPlus
87
97
  end
88
98
 
89
99
  def list
90
- string = EVENTS_STRING + '/list.json?' + get_params_list.join.to_s
91
- request(string)
100
+ TicketflyPlus::Calls::List.new(requestor_string: EVENTS_STRING, params_list: get_params_list.join.to_s)
92
101
  end
93
102
 
94
103
  def upcoming
95
- string = EVENTS_STRING + '/upcoming.json?' + get_params_list.join.to_s
96
- request(string)
104
+ TicketflyPlus::Calls::Upcoming.new(requestor_string: EVENTS_STRING, params_list: get_params_list.join.to_s)
97
105
  end
98
106
 
99
107
  def featured
100
- string = EVENTS_STRING + '/featured.json?' + get_params_list.join.to_s
101
- request(string)
102
- end
103
-
104
- def all_upcoming
105
- string = EVENTS_STRING + '/upcoming.json?' + get_params_list.join.to_s
106
- req = request(string)
107
- (2..req['totalPages']).count do |page_num|
108
- puts page_num
109
- update_page_number(page_num)
110
- string = EVENTS_STRING + '/upcoming.json?' + get_params_list.join.to_s
111
- req['events'] = req['events'] + request(string)['events']
112
- end
113
- req
108
+ TicketflyPlus::Calls::Featured.new(requestor_string: EVENTS_STRING, params_list: get_params_list.join.to_s)
114
109
  end
115
110
 
116
111
  def just_announced
117
- string = EVENTS_STRING + '/justAnnounced.json?' + get_params_list.join.to_s
118
- request(string)
112
+ TicketflyPlus::Calls::JustAnnounced.new(requestor_string: EVENTS_STRING, params_list: get_params_list.join.to_s)
119
113
  end
120
114
 
121
115
  def past
122
- string = EVENTS_STRING + '/past.json?' + get_params_list.join.to_s
123
- request(string)
116
+ TicketflyPlus::Calls::Past.new(requestor_string: EVENTS_STRING, params_list: get_params_list.join.to_s)
124
117
  end
125
118
 
126
119
  def on_sale
127
- string = EVENTS_STRING + '/onsale.json?' + get_params_list.join.to_s
128
- request(string)
120
+ TicketflyPlus::Calls::OnSale.new(requestor_string: EVENTS_STRING, params_list: get_params_list.join.to_s)
129
121
  end
130
122
 
131
- private
132
-
133
- def update_page_number(num)
134
- @pageNum = stringify("pageNum=", num)
135
- end
136
123
  end
137
124
 
138
125
  class Event < Requestors::Base
@@ -153,7 +140,7 @@ module TicketflyPlus
153
140
  end
154
141
 
155
142
  def event
156
- string = EVENT_STRING + '/event.json?' + get_params_list.join.to_s
143
+ TicketflyPlus::Calls::OnSale.new(requestor_string: EVENTS_STRING, params_list: get_params_list.join.to_s)
157
144
  end
158
145
 
159
146
  end
@@ -174,8 +161,7 @@ module TicketflyPlus
174
161
  end
175
162
 
176
163
  def list
177
- string = VENUES_STRING + '/list.json?' + get_params_list.join.to_s
178
- request(string)
164
+ TicketflyPlus::Calls::OnSale.new(requestor_string: EVENTS_STRING, params_list: get_params_list.join.to_s)
179
165
  end
180
166
  end
181
167
 
@@ -193,8 +179,7 @@ module TicketflyPlus
193
179
  end
194
180
 
195
181
  def list()
196
- string = ORGS_STRING + '/list.json?' + get_params_list.join.to_s
197
- request(string)
182
+ TicketflyPlus::Calls::OnSale.new(requestor_string: EVENTS_STRING, params_list: get_params_list.join.to_s)
198
183
  end
199
184
  end
200
185
  end
@@ -1,3 +1,3 @@
1
1
  module TicketflyPlus
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.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.1.1
4
+ version: 0.2.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-08-02 00:00:00.000000000 Z
11
+ date: 2014-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,6 +150,7 @@ files:
150
150
  - README.md
151
151
  - Rakefile
152
152
  - lib/ticketfly_plus.rb
153
+ - lib/ticketfly_plus/calls.rb
153
154
  - lib/ticketfly_plus/objects.rb
154
155
  - lib/ticketfly_plus/requestors.rb
155
156
  - lib/ticketfly_plus/responses.rb