brownpapertickets 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
module BrownPaperTickets
|
10
10
|
class Base
|
11
|
-
attr_reader :id, :account, :event, :date, :price, :orderlist
|
11
|
+
attr_reader :id, :account, :event, :date, :price, :orderlist, :eventsale
|
12
12
|
|
13
13
|
# Needs the brownpapersticker's credentials (id and account),
|
14
14
|
# creates a new instance of event, date and price
|
@@ -21,6 +21,7 @@ module BrownPaperTickets
|
|
21
21
|
@date = BrownPaperTickets::Date.new(self.id, self.account)
|
22
22
|
@price = BrownPaperTickets::Price.new(self.id, self.account)
|
23
23
|
@eventsale = BrownPaperTickets::Eventsales.new(self.id, self.account)
|
24
|
+
@orderlist = BrownPaperTickets::Orderlist.new(self.id, self.account)
|
24
25
|
end
|
25
26
|
|
26
27
|
# Returns the event
|
@@ -38,6 +39,9 @@ module BrownPaperTickets
|
|
38
39
|
def eventsales
|
39
40
|
@eventsale
|
40
41
|
end
|
42
|
+
def orderlists
|
43
|
+
@orderlist
|
44
|
+
end
|
41
45
|
end
|
42
46
|
|
43
47
|
end
|
@@ -49,7 +49,9 @@ module BrownPaperTickets
|
|
49
49
|
body = {"id" => @@id, "account" => @@account, "event_id" => event_id}
|
50
50
|
query = self.attributes.merge("id" => @@id, "account" => @@account)
|
51
51
|
response = BrownPaperTickets::Httpost.new(Net::HTTP::Get, "https://www.brownpapertickets.com/api2/eventsales",:query => query)
|
52
|
-
response
|
52
|
+
response.options[:body] = query
|
53
|
+
st = response.perform
|
54
|
+
xml = st.response.body
|
53
55
|
end
|
54
56
|
|
55
57
|
def server_response
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'hpricot'
|
2
|
+
module BrownPaperTickets
|
3
|
+
class Orderlist
|
4
|
+
include HTTParty
|
5
|
+
base_uri "https://www.brownpapertickets.com/api2"
|
6
|
+
|
7
|
+
attr_reader :attributes, :server_response
|
8
|
+
|
9
|
+
REQUIRED_ATTR=["event_id"]
|
10
|
+
|
11
|
+
ATTRS=["event_id", "order_time", "quantity", "fname", "lname", "address", "city", "state", "zip",
|
12
|
+
"country", "email", "phone","cc","shipping_method","order_notes","ticket_number", "section", "row","seat",
|
13
|
+
"date_id", "price_id"]
|
14
|
+
|
15
|
+
def initialize(id, account, attributes={})
|
16
|
+
@@id = id
|
17
|
+
@@account = account
|
18
|
+
@attributes = attributes
|
19
|
+
end
|
20
|
+
|
21
|
+
def new(params={})
|
22
|
+
Event.new(@@id,@@account, params, event_id)
|
23
|
+
end
|
24
|
+
|
25
|
+
def method_missing(m, *args, &block)
|
26
|
+
if ATTRS.include?(m.to_s.gsub("=",""))
|
27
|
+
if m.to_s.include?("=")
|
28
|
+
self.attributes[m.to_s.gsub("=","")] = *args.to_s
|
29
|
+
else
|
30
|
+
result = self.attributes[m.to_s]
|
31
|
+
end
|
32
|
+
else
|
33
|
+
raise NoMethodError.new("Method missing #{m}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def validates_required_attr
|
38
|
+
missing_field = []
|
39
|
+
REQUIRED_ATTR.each do |attr|
|
40
|
+
missing_field << attr if self.send(attr,nil,nil).blank?
|
41
|
+
end
|
42
|
+
unless missing_field.blank?
|
43
|
+
@server_response = "The following attributes are missing:"
|
44
|
+
missing_field.each{|att| @server_response = @server_response + " " + att }
|
45
|
+
return false
|
46
|
+
end
|
47
|
+
return true
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_report
|
51
|
+
body = {"id" => @@id, "account" => @@account, "event_id" => event_id}
|
52
|
+
query = self.attributes.merge("id" => @@id, "account" => @@account)
|
53
|
+
response = BrownPaperTickets::Httpost.new(Net::HTTP::Get, "https://www.brownpapertickets.com/api2/orderlist",:query => query)
|
54
|
+
response.options[:body] = query
|
55
|
+
st = response.perform
|
56
|
+
xml = st.response.body
|
57
|
+
end
|
58
|
+
|
59
|
+
def server_response
|
60
|
+
@server_response
|
61
|
+
end
|
62
|
+
|
63
|
+
def attributes
|
64
|
+
@attributes
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/brownpapertickets.rb
CHANGED
@@ -6,6 +6,7 @@ require File.join(File.dirname(__FILE__), 'brownpapertickets/event')
|
|
6
6
|
require File.join(File.dirname(__FILE__), 'brownpapertickets/date')
|
7
7
|
require File.join(File.dirname(__FILE__), 'brownpapertickets/price')
|
8
8
|
require File.join(File.dirname(__FILE__), 'brownpapertickets/eventsales')
|
9
|
+
require File.join(File.dirname(__FILE__), 'brownpapertickets/orderlist')
|
9
10
|
require File.join(File.dirname(__FILE__), 'brownpapertickets/httpost')
|
10
11
|
module BrownPaperTickets
|
11
12
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brownpapertickets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 16
|
10
|
+
version: 0.0.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alvaro Insignares
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/brownpapertickets/event.rb
|
115
115
|
- lib/brownpapertickets/eventsales.rb
|
116
116
|
- lib/brownpapertickets/httpost.rb
|
117
|
+
- lib/brownpapertickets/orderlist.rb
|
117
118
|
- lib/brownpapertickets/price.rb
|
118
119
|
- lib/brownpapertickets/version.rb
|
119
120
|
- lib/brownpapertickets/xmlparse.rb
|