Class: BrownPaperTickets::Orderlist
- Inherits:
-
Object
- Object
- BrownPaperTickets::Orderlist
- Includes:
- HTTParty
- Defined in:
- lib/brownpapertickets/orderlist.rb
Constant Summary collapse
- REQUIRED_ATTR =
["event_id"]
- ATTRS =
["event_id", "order_time", "quantity", "fname", "lname", "address", "city", "state", "zip", "country", "email", "phone","cc","shipping_method","order_notes","ticket_number", "section", "row","seat", "date_id", "price_id"]
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#server_response ⇒ Object
readonly
Returns the value of attribute server_response.
Instance Method Summary collapse
- #create_report ⇒ Object
-
#initialize(id, account, attributes = {}) ⇒ Orderlist
constructor
A new instance of Orderlist.
- #method_missing(m, *args, &block) ⇒ Object
- #new(params = {}) ⇒ Object
- #validates_required_attr ⇒ Object
Constructor Details
#initialize(id, account, attributes = {}) ⇒ Orderlist
Returns a new instance of Orderlist.
15 16 17 18 19 |
# File 'lib/brownpapertickets/orderlist.rb', line 15 def initialize(id, account, attributes={}) @@id = id @@account = account @attributes = attributes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/brownpapertickets/orderlist.rb', line 25 def method_missing(m, *args, &block) if ATTRS.include?(m.to_s.gsub("=","")) if m.to_s.include?("=") self.attributes[m.to_s.gsub("=","")] = *args.to_s else result = self.attributes[m.to_s] end else raise NoMethodError.new("Method missing #{m}") end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/brownpapertickets/orderlist.rb', line 7 def attributes @attributes end |
#server_response ⇒ Object (readonly)
Returns the value of attribute server_response.
7 8 9 |
# File 'lib/brownpapertickets/orderlist.rb', line 7 def server_response @server_response end |
Instance Method Details
#create_report ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/brownpapertickets/orderlist.rb', line 50 def create_report body = {"id" => @@id, "account" => @@account, "event_id" => event_id} query = self.attributes.merge("id" => @@id, "account" => @@account) response = BrownPaperTickets::Httpost.new(Net::HTTP::Get, "https://www.brownpapertickets.com/api2/orderlist",:query => query) response.[:body] = query st = response.perform xml = st.response.body end |
#new(params = {}) ⇒ Object
21 22 23 |
# File 'lib/brownpapertickets/orderlist.rb', line 21 def new(params={}) Event.new(@@id,@@account, params, event_id) end |
#validates_required_attr ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/brownpapertickets/orderlist.rb', line 37 def validates_required_attr missing_field = [] REQUIRED_ATTR.each do |attr| missing_field << attr if self.send(attr,nil,nil).blank? end unless missing_field.blank? @server_response = "The following attributes are missing:" missing_field.each{|att| @server_response = @server_response + " " + att } return false end return true end |