Class: TesoteSdk::V2::TransactionOrders
- Inherits:
-
Object
- Object
- TesoteSdk::V2::TransactionOrders
- Defined in:
- lib/tesote_sdk/v2/transaction_orders.rb
Instance Method Summary collapse
-
#cancel(account_id, order_id, opts: {}) ⇒ Object
POST /v2/accounts/id/transaction_orders/order_id/cancel.
-
#create(account_id, order:, opts: {}) ⇒ Object
POST /v2/accounts/id/transaction_orders ‘order` is a hash matching the spec’s ‘transaction_order` body field.
-
#get(account_id, order_id, opts: {}) ⇒ Object
GET /v2/accounts/id/transaction_orders/order_id.
-
#initialize(transport) ⇒ TransactionOrders
constructor
A new instance of TransactionOrders.
-
#list(account_id, query = {}, opts: {}) ⇒ Object
GET /v2/accounts/id/transaction_orders Returns OffsetPage with TransactionOrder items.
-
#submit(account_id, order_id, token: nil, opts: {}) ⇒ Object
POST /v2/accounts/id/transaction_orders/order_id/submit.
Constructor Details
#initialize(transport) ⇒ TransactionOrders
Returns a new instance of TransactionOrders.
4 5 6 |
# File 'lib/tesote_sdk/v2/transaction_orders.rb', line 4 def initialize(transport) @transport = transport end |
Instance Method Details
#cancel(account_id, order_id, opts: {}) ⇒ Object
POST /v2/accounts/id/transaction_orders/order_id/cancel
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/tesote_sdk/v2/transaction_orders.rb', line 59 def cancel(account_id, order_id, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? raise ArgumentError, 'order_id is required' if order_id.nil? || order_id.to_s.empty? body = @transport.request( 'POST', "accounts/#{account_id}/transaction_orders/#{order_id}/cancel", body: {}, opts: opts ) Models::TransactionOrder.from_hash(body) end |
#create(account_id, order:, opts: {}) ⇒ Object
POST /v2/accounts/id/transaction_orders ‘order` is a hash matching the spec’s ‘transaction_order` body field.
34 35 36 37 38 39 40 41 |
# File 'lib/tesote_sdk/v2/transaction_orders.rb', line 34 def create(account_id, order:, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? raise ArgumentError, 'order is required' if order.nil? payload = { transaction_order: order } body = @transport.request('POST', "accounts/#{account_id}/transaction_orders", body: payload, opts: opts) Models::TransactionOrder.from_hash(body) end |
#get(account_id, order_id, opts: {}) ⇒ Object
GET /v2/accounts/id/transaction_orders/order_id
24 25 26 27 28 29 30 |
# File 'lib/tesote_sdk/v2/transaction_orders.rb', line 24 def get(account_id, order_id, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? raise ArgumentError, 'order_id is required' if order_id.nil? || order_id.to_s.empty? body = @transport.request('GET', "accounts/#{account_id}/transaction_orders/#{order_id}", opts: opts) Models::TransactionOrder.from_hash(body) end |
#list(account_id, query = {}, opts: {}) ⇒ Object
GET /v2/accounts/id/transaction_orders Returns OffsetPage with TransactionOrder items.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tesote_sdk/v2/transaction_orders.rb', line 10 def list(account_id, query = {}, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? body = @transport.request('GET', "accounts/#{account_id}/transaction_orders", query: query, opts: opts) items_raw = (body && body['items']) || [] Models::OffsetPage.new( items: Models::TransactionOrder.from_array(items_raw), limit: body && body['limit'], offset: body && body['offset'], has_more: body && body['has_more'] ) end |
#submit(account_id, order_id, token: nil, opts: {}) ⇒ Object
POST /v2/accounts/id/transaction_orders/order_id/submit
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/tesote_sdk/v2/transaction_orders.rb', line 44 def submit(account_id, order_id, token: nil, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? raise ArgumentError, 'order_id is required' if order_id.nil? || order_id.to_s.empty? payload = token.nil? ? {} : { token: token } body = @transport.request( 'POST', "accounts/#{account_id}/transaction_orders/#{order_id}/submit", body: payload, opts: opts ) Models::TransactionOrder.from_hash(body) end |