Class: TesoteSdk::V2::Batches
- Inherits:
-
Object
- Object
- TesoteSdk::V2::Batches
- Defined in:
- lib/tesote_sdk/v2/batches.rb
Instance Method Summary collapse
-
#approve(account_id, batch_id, opts: {}) ⇒ Object
POST /v2/accounts/id/batches/batch_id/approve.
-
#cancel(account_id, batch_id, opts: {}) ⇒ Object
POST /v2/accounts/id/batches/batch_id/cancel.
-
#create(account_id, orders:, opts: {}) ⇒ Object
POST /v2/accounts/id/batches ‘orders` is an array of order hashes (per spec).
-
#get(account_id, batch_id, opts: {}) ⇒ Object
GET /v2/accounts/id/batches/batch_id.
-
#initialize(transport) ⇒ Batches
constructor
A new instance of Batches.
-
#submit(account_id, batch_id, token: nil, opts: {}) ⇒ Object
POST /v2/accounts/id/batches/batch_id/submit.
Constructor Details
#initialize(transport) ⇒ Batches
Returns a new instance of Batches.
4 5 6 |
# File 'lib/tesote_sdk/v2/batches.rb', line 4 def initialize(transport) @transport = transport end |
Instance Method Details
#approve(account_id, batch_id, opts: {}) ⇒ Object
POST /v2/accounts/id/batches/batch_id/approve
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tesote_sdk/v2/batches.rb', line 29 def approve(account_id, batch_id, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? raise ArgumentError, 'batch_id is required' if batch_id.nil? || batch_id.to_s.empty? body = @transport.request( 'POST', "accounts/#{account_id}/batches/#{batch_id}/approve", body: {}, opts: opts ) Models::BatchApproveResult.from_hash(body) end |
#cancel(account_id, batch_id, opts: {}) ⇒ Object
POST /v2/accounts/id/batches/batch_id/cancel
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/tesote_sdk/v2/batches.rb', line 58 def cancel(account_id, batch_id, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? raise ArgumentError, 'batch_id is required' if batch_id.nil? || batch_id.to_s.empty? body = @transport.request( 'POST', "accounts/#{account_id}/batches/#{batch_id}/cancel", body: {}, opts: opts ) Models::BatchCancelResult.from_hash(body) end |
#create(account_id, orders:, opts: {}) ⇒ Object
POST /v2/accounts/id/batches ‘orders` is an array of order hashes (per spec).
10 11 12 13 14 15 16 17 |
# File 'lib/tesote_sdk/v2/batches.rb', line 10 def create(account_id, orders:, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? raise ArgumentError, 'orders is required' if orders.nil? || orders.empty? payload = { orders: orders } body = @transport.request('POST', "accounts/#{account_id}/batches", body: payload, opts: opts) Models::BatchCreateResult.from_hash(body) end |
#get(account_id, batch_id, opts: {}) ⇒ Object
GET /v2/accounts/id/batches/batch_id
20 21 22 23 24 25 26 |
# File 'lib/tesote_sdk/v2/batches.rb', line 20 def get(account_id, batch_id, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? raise ArgumentError, 'batch_id is required' if batch_id.nil? || batch_id.to_s.empty? body = @transport.request('GET', "accounts/#{account_id}/batches/#{batch_id}", opts: opts) Models::BatchSummary.from_hash(body) end |
#submit(account_id, batch_id, token: nil, opts: {}) ⇒ Object
POST /v2/accounts/id/batches/batch_id/submit
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/tesote_sdk/v2/batches.rb', line 43 def submit(account_id, batch_id, token: nil, opts: {}) raise ArgumentError, 'account_id is required' if account_id.nil? || account_id.to_s.empty? raise ArgumentError, 'batch_id is required' if batch_id.nil? || batch_id.to_s.empty? payload = token.nil? ? {} : { token: token } body = @transport.request( 'POST', "accounts/#{account_id}/batches/#{batch_id}/submit", body: payload, opts: opts ) Models::BatchSubmitResult.from_hash(body) end |