Class: CoinGate::Merchant::Order
- Inherits:
-
Object
- Object
- CoinGate::Merchant::Order
- Defined in:
- lib/coingate/merchant/order.rb
Constant Summary collapse
- STATUSES =
%w(new pending confirming paid invalid canceled expired failed)
Class Method Summary collapse
- .create(params, authentication = {}, options = {}) ⇒ Object
- .create!(params, authentication = {}, options = {}) ⇒ Object
- .find(order_id, authentication = {}, options = {}) ⇒ Object
- .find!(order_id, authentication = {}, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(params) ⇒ Order
constructor
A new instance of Order.
- #to_hash ⇒ Object
Constructor Details
#initialize(params) ⇒ Order
4 5 6 7 8 9 10 11 12 |
# File 'lib/coingate/merchant/order.rb', line 4 def initialize(params) @order = params @order.each do |name, value| self.define_singleton_method name do value end end end |
Class Method Details
.create(params, authentication = {}, options = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/coingate/merchant/order.rb', line 46 def self.create(params, authentication={}, ={}) create!(params, authentication, ) rescue CoinGate::OrderIsNotValid false end |
.create!(params, authentication = {}, options = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/coingate/merchant/order.rb', line 38 def self.create!(params, authentication={}, ={}) response_code, order = CoinGate.api_request('/orders', :post, params, authentication) if response_code == 200 self.new(order) end end |
.find(order_id, authentication = {}, options = {}) ⇒ Object
32 33 34 35 36 |
# File 'lib/coingate/merchant/order.rb', line 32 def self.find(order_id, authentication={}, ={}) find!(order_id, authentication, ) rescue CoinGate::OrderNotFound false end |
.find!(order_id, authentication = {}, options = {}) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/coingate/merchant/order.rb', line 24 def self.find!(order_id, authentication={}, ={}) response_code, order = CoinGate.api_request("/orders/#{order_id}", :get, {}, authentication) if response_code == 200 self.new(order) end end |
Instance Method Details
#to_hash ⇒ Object
20 21 22 |
# File 'lib/coingate/merchant/order.rb', line 20 def to_hash @order end |