Class: SynapseClient::Order
- Inherits:
-
APIResource
- Object
- APIResource
- SynapseClient::Order
- Includes:
- APIOperations::List
- Defined in:
- lib/synapse_client/order.rb
Instance Attribute Summary collapse
-
#account_type ⇒ Object
readonly
Returns the value of attribute account_type.
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#bank_id ⇒ Object
readonly
Returns the value of attribute bank_id.
-
#bank_pay ⇒ Object
readonly
Returns the value of attribute bank_pay.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#date_settled ⇒ Object
readonly
Returns the value of attribute date_settled.
-
#fee ⇒ Object
readonly
Returns the value of attribute fee.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#resource_uri ⇒ Object
readonly
Returns the value of attribute resource_uri.
-
#seller_email ⇒ Object
readonly
Returns the value of attribute seller_email.
-
#seller_id ⇒ Object
readonly
Returns the value of attribute seller_id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#ticket_number ⇒ Object
readonly
Returns the value of attribute ticket_number.
Attributes inherited from APIResource
Class Method Summary collapse
- .all(params = {}) ⇒ Object
- .create(params = {}) ⇒ Object
- .retrieve_endpoint ⇒ Object
- .status_object_for_key(key) ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Order
constructor
A new instance of Order.
- #retrieve_params ⇒ Object
- #status_description ⇒ Object
- #status_label ⇒ Object
- #update_attributes(options) ⇒ Object
Methods included from APIOperations::List
Methods inherited from APIResource
api_resource_name, class_name, #refresh, retrieve, #successful?, #to_hash, url, #url
Constructor Details
#initialize(options = {}) ⇒ Order
Returns a new instance of Order.
20 21 22 23 24 |
# File 'lib/synapse_client/order.rb', line 20 def initialize( = {}) = Map.new() update_attributes() end |
Instance Attribute Details
#account_type ⇒ Object (readonly)
Returns the value of attribute account_type.
17 18 19 |
# File 'lib/synapse_client/order.rb', line 17 def account_type @account_type end |
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
7 8 9 |
# File 'lib/synapse_client/order.rb', line 7 def amount @amount end |
#bank_id ⇒ Object (readonly)
Returns the value of attribute bank_id.
11 12 13 |
# File 'lib/synapse_client/order.rb', line 11 def bank_id @bank_id end |
#bank_pay ⇒ Object (readonly)
Returns the value of attribute bank_pay.
10 11 12 |
# File 'lib/synapse_client/order.rb', line 10 def bank_pay @bank_pay end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
14 15 16 |
# File 'lib/synapse_client/order.rb', line 14 def date @date end |
#date_settled ⇒ Object (readonly)
Returns the value of attribute date_settled.
13 14 15 |
# File 'lib/synapse_client/order.rb', line 13 def date_settled @date_settled end |
#fee ⇒ Object (readonly)
Returns the value of attribute fee.
18 19 20 |
# File 'lib/synapse_client/order.rb', line 18 def fee @fee end |
#note ⇒ Object (readonly)
Returns the value of attribute note.
12 13 14 |
# File 'lib/synapse_client/order.rb', line 12 def note @note end |
#resource_uri ⇒ Object (readonly)
Returns the value of attribute resource_uri.
16 17 18 |
# File 'lib/synapse_client/order.rb', line 16 def resource_uri @resource_uri end |
#seller_email ⇒ Object (readonly)
Returns the value of attribute seller_email.
8 9 10 |
# File 'lib/synapse_client/order.rb', line 8 def seller_email @seller_email end |
#seller_id ⇒ Object (readonly)
Returns the value of attribute seller_id.
9 10 11 |
# File 'lib/synapse_client/order.rb', line 9 def seller_id @seller_id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/synapse_client/order.rb', line 6 def status @status end |
#ticket_number ⇒ Object (readonly)
Returns the value of attribute ticket_number.
15 16 17 |
# File 'lib/synapse_client/order.rb', line 15 def ticket_number @ticket_number end |
Class Method Details
.all(params = {}) ⇒ Object
26 27 28 29 |
# File 'lib/synapse_client/order.rb', line 26 def self.all(params={}) orders = list(params, "recent").orders orders.map{|order| Order.new(order)} end |
.create(params = {}) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/synapse_client/order.rb', line 31 def self.create(params={}) response = SynapseClient.request(:post, url + "add", params) return response unless response.successful? Order.new(response.data.order) end |
.retrieve_endpoint ⇒ Object
38 39 40 |
# File 'lib/synapse_client/order.rb', line 38 def self.retrieve_endpoint "poll" end |
.status_object_for_key(key) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/synapse_client/order.rb', line 42 def self.status_object_for_key(key) case key when -1 {status: "Queued", description: "Order has been queued by SynapsePay and we are currently investigating it."} when 0 {status: "Queued", description: "Order has been queued and is waiting for merchant approval to process."} when 1 {status: "Created", description: "Order created but still needs to be fetched from the bank account."} when 2 {status: "In Progress", description: "The funds are being fetched from the sender’s bank account, in receiver’s Synapse account in 1-2 Business Days."} when 3 {status: "Settled", description: "Transaction completed and the funds have been added to the receiver’s Synapse account."} when 4 {status: "Refunded/Cancelled", description: "The order has been voided."} when 5 {status: "Returned", description: "Received an ACH return from the sender’s bank account. Which means someone is in trouble."} else {status: "Unknown", description: "Unknown status key. The API may have changed."} end end |
Instance Method Details
#retrieve_params ⇒ Object
70 71 72 |
# File 'lib/synapse_client/order.rb', line 70 def retrieve_params {:order_id => @id} end |
#status_description ⇒ Object
66 67 68 |
# File 'lib/synapse_client/order.rb', line 66 def status_description Order.status_object_for_key(status)[:description] end |
#status_label ⇒ Object
63 64 65 |
# File 'lib/synapse_client/order.rb', line 63 def status_label Order.status_object_for_key(status)[:status] end |
#update_attributes(options) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/synapse_client/order.rb', line 74 def update_attributes() @status = [:status] @amount = [:amount] @seller_email = [:seller_email] @bank_pay = [:bank_pay] @bank_id = [:bank_id] @note = [:note] @date_settled = [:date_settled] @date = [:date] @id = [:id] @ticket_number = [:ticket_number] @resource_uri = [:resource_uri] @account_type = [:account_type] @fee = [:fee] @seller_id = [:seller_id] || [:seller].delete("seller_id") rescue nil end |