Class: Kitely::Order
- Inherits:
-
Object
- Object
- Kitely::Order
- Defined in:
- lib/kitely/order.rb
Instance Attribute Summary collapse
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#jobs ⇒ Object
Returns the value of attribute jobs.
Instance Method Summary collapse
- #add(job) ⇒ Object
- #attributes ⇒ Object
- #http ⇒ Object
-
#initialize(customer:) {|jobs| ... } ⇒ Order
constructor
A new instance of Order.
- #order! ⇒ Object
Constructor Details
#initialize(customer:) {|jobs| ... } ⇒ Order
Returns a new instance of Order.
7 8 9 10 11 |
# File 'lib/kitely/order.rb', line 7 def initialize(customer:) self.customer = customer self.jobs = [] yield jobs if block_given? end |
Instance Attribute Details
#customer ⇒ Object
Returns the value of attribute customer.
5 6 7 |
# File 'lib/kitely/order.rb', line 5 def customer @customer end |
#jobs ⇒ Object
Returns the value of attribute jobs.
5 6 7 |
# File 'lib/kitely/order.rb', line 5 def jobs @jobs end |
Instance Method Details
#add(job) ⇒ Object
13 14 15 |
# File 'lib/kitely/order.rb', line 13 def add(job) self.jobs.push(job) end |
#attributes ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/kitely/order.rb', line 17 def attributes { shipping_address: self.customer.shipping_address, customer_phone: self.customer.phone, customer_email: self.customer.email, jobs: self.jobs.map(&:attributes) } end |
#http ⇒ Object
30 31 32 |
# File 'lib/kitely/order.rb', line 30 def http @http ||= HTTP.auth("ApiKey #{Kitely.public_key}:#{Kitely.secret_key}") end |