brownpapertickets 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ require File.join(File.dirname(__FILE__), 'brownpapertickets/base')
5
5
  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
- require File.join(File.dirname(__FILE__), 'brownpapertickets/orderlist')
8
+ require File.join(File.dirname(__FILE__), 'brownpapertickets/eventsales')
9
9
  require File.join(File.dirname(__FILE__), 'brownpapertickets/httpost')
10
10
  module BrownPaperTickets
11
11
 
@@ -20,7 +20,7 @@ module BrownPaperTickets
20
20
  @event = BrownPaperTickets::Event.new(self.id, self.account)
21
21
  @date = BrownPaperTickets::Date.new(self.id, self.account)
22
22
  @price = BrownPaperTickets::Price.new(self.id, self.account)
23
- @orderlist = BrownPaperTickets::Orderlist.new(self.id, self.account)
23
+ @eventsale = BrownPaperTickets::Eventsales.new(self.id, self.account)
24
24
  end
25
25
 
26
26
  # Returns the event
@@ -35,8 +35,8 @@ module BrownPaperTickets
35
35
  def prices
36
36
  @price
37
37
  end
38
- def orderlists
39
- @orderlist
38
+ def eventsales
39
+ @eventsale
40
40
  end
41
41
  end
42
42
 
@@ -0,0 +1,62 @@
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", "title", "link", "event_status", "tickets_sold", "collected_value", "paid_value", "date_id", "price_id"]
12
+
13
+ def initialize(id, account, attributes={})
14
+ @@id = id
15
+ @@account = account
16
+ @attributes = attributes
17
+ end
18
+
19
+ def new(params={})
20
+ Event.new(@@id,@@account, params, event_id)
21
+ end
22
+
23
+ def method_missing(m, *args, &block)
24
+ if ATTRS.include?(m.to_s.gsub("=",""))
25
+ if m.to_s.include?("=")
26
+ self.attributes[m.to_s.gsub("=","")] = *args.to_s
27
+ else
28
+ result = self.attributes[m.to_s]
29
+ end
30
+ else
31
+ raise NoMethodError.new("Method missing #{m}")
32
+ end
33
+ end
34
+
35
+ def validates_required_attr
36
+ missing_field = []
37
+ REQUIRED_ATTR.each do |attr|
38
+ missing_field << attr if self.send(attr,nil,nil).blank?
39
+ end
40
+ unless missing_field.blank?
41
+ @server_response = "The following attributes are missing:"
42
+ missing_field.each{|att| @server_response = @server_response + " " + att }
43
+ return false
44
+ end
45
+ return true
46
+ end
47
+
48
+ def create_report
49
+ body = {"id" => @@id, "account" => @@account, "event_id" => event_id}
50
+ query = self.attributes.merge("id" => @@id, "account" => @@account)
51
+ BrownPaperTickets::Httpost.new(Net::HTTP::Get, "https://www.brownpapertickets.com/api2/eventsales",:query => query)
52
+ end
53
+
54
+ def server_response
55
+ @server_response
56
+ end
57
+
58
+ def attributes
59
+ @attributes
60
+ end
61
+ end
62
+ end
@@ -1,3 +1,3 @@
1
1
  module BrownPaperTickets
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
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: 9
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 11
10
- version: 0.0.11
9
+ - 12
10
+ version: 0.0.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alvaro Insignares
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-02-28 00:00:00 -05:00
20
+ date: 2011-03-01 00:00:00 -05:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -112,8 +112,8 @@ files:
112
112
  - lib/brownpapertickets/base.rb
113
113
  - lib/brownpapertickets/date.rb
114
114
  - lib/brownpapertickets/event.rb
115
+ - lib/brownpapertickets/eventsales.rb
115
116
  - lib/brownpapertickets/httpost.rb
116
- - lib/brownpapertickets/orderlist.rb
117
117
  - lib/brownpapertickets/price.rb
118
118
  - lib/brownpapertickets/version.rb
119
119
  - lib/brownpapertickets/xmlparse.rb
@@ -1,143 +0,0 @@
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", "title", "link", "event_status", "tickets_sold", "collected_value", "paid_value", "date_id", "price_id"]
12
-
13
- def initialize(id, account, attributes={})
14
- @@id = id
15
- @@account = account
16
- @attributes = attributes
17
- end
18
-
19
- def new(params={})
20
- Event.new(@@id,@@account, params, event_id)
21
- end
22
-
23
- def method_missing(m, *args, &block)
24
- if ATTRS.include?(m.to_s.gsub("=",""))
25
- if m.to_s.include?("=")
26
- self.attributes[m.to_s.gsub("=","")] = *args.to_s
27
- else
28
- result = self.attributes[m.to_s]
29
- end
30
- else
31
- raise NoMethodError.new("Method missing #{m}")
32
- end
33
- end
34
-
35
- def validates_required_attr
36
- missing_field = []
37
- REQUIRED_ATTR.each do |attr|
38
- missing_field << attr if self.send(attr,nil,nil).blank?
39
- end
40
- unless missing_field.blank?
41
- @server_response = "The following attributes are missing:"
42
- missing_field.each{|att| @server_response = @server_response + " " + att }
43
- return false
44
- end
45
- return true
46
- end
47
-
48
- def create_report
49
- body = {"id" => @@id, "account" => @@account, "event_id" => event_id}
50
- query = self.attributes.merge("id" => @@id, "account" => @@account)
51
- response = BrownPaperTickets::Httpost.new(Net::HTTP::Get, "https://www.brownpapertickets.com/api2/eventsales",:query => query)
52
- p response
53
- response.options[:body] = query
54
- st = response.perform
55
- xml = Hpricot(st.response.body)
56
- p xml
57
- end
58
-
59
- def create(params={})
60
- date = Event.new(@@id,@@account, params)
61
- date.save!
62
- end
63
-
64
- # resultcode
65
- # 300055 - Required variables are missing
66
- # 300056 - Unknown error
67
- # 300057 - Unable to find event
68
- # 300058 - Event does not belong to account
69
- # 300059 - Unknown error
70
- # 300060 - Unable to find date
71
- # 300061 - Required variables are missing
72
- # 300062 - Unable to update date
73
- # 000000 - Success
74
-
75
-
76
- def process_update_response(response)
77
- case response
78
- when "000000" then
79
- @server_response = "Success"
80
- return true
81
- when "300055" then
82
- @server_response = "Required variables are missing"
83
- return false
84
- when "300056" then
85
- @server_response = "Unknown error"
86
- return false
87
- when "300057" then
88
- @server_response = "Unable to find event"
89
- return false
90
- when "300058" then
91
- @server_response = "Event does not belong to account"
92
- return false
93
- when "300059" then
94
- @server_response = "Unknown error"
95
- return false
96
- when "300060" then
97
- @server_response = "Unable to find date"
98
- return false
99
- when "300061" then
100
- @server_response = "Required variables are missing"
101
- return false
102
- when "300062" then
103
- @server_response = "Unable to update date"
104
- return false
105
- else
106
- @server_response = "Unknown error"
107
- return false
108
- end
109
- end
110
-
111
- def process_create_response(response, event_id)
112
- case response
113
- when "0000" then
114
- self.date_id = date_id
115
- @server_response = "success"
116
- return true
117
- when "300038" then
118
- @server_response = "Required variables are missing"
119
- return false
120
- when "300039" then
121
- @server_response = "Unknown error while posting info to DB"
122
- return false
123
- when "300040" then
124
- @server_response = "Event does not belong to user"
125
- return false
126
- when "300041" then
127
- @server_response = "Unable to add date"
128
- return false
129
- else
130
- @server_response = "Unknown error"
131
- return false
132
- end
133
- end
134
-
135
- def server_response
136
- @server_response
137
- end
138
-
139
- def attributes
140
- @attributes
141
- end
142
- end
143
- end