Class: TesoteSdk::V2::Batches

Inherits:
Object
  • Object
show all
Defined in:
lib/tesote_sdk/v2/batches.rb

Instance Method Summary collapse

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

Raises:

  • (ArgumentError)


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tesote_sdk/v2/batches.rb', line 29

def approve(, batch_id, opts: {})
  raise ArgumentError, 'account_id is required' if .nil? || .to_s.empty?
  raise ArgumentError, 'batch_id is required' if batch_id.nil? || batch_id.to_s.empty?

  body = @transport.request(
    'POST',
    "accounts/#{}/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

Raises:

  • (ArgumentError)


58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/tesote_sdk/v2/batches.rb', line 58

def cancel(, batch_id, opts: {})
  raise ArgumentError, 'account_id is required' if .nil? || .to_s.empty?
  raise ArgumentError, 'batch_id is required' if batch_id.nil? || batch_id.to_s.empty?

  body = @transport.request(
    'POST',
    "accounts/#{}/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).

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
# File 'lib/tesote_sdk/v2/batches.rb', line 10

def create(, orders:, opts: {})
  raise ArgumentError, 'account_id is required' if .nil? || .to_s.empty?
  raise ArgumentError, 'orders is required' if orders.nil? || orders.empty?

  payload = { orders: orders }
  body = @transport.request('POST', "accounts/#{}/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

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
# File 'lib/tesote_sdk/v2/batches.rb', line 20

def get(, batch_id, opts: {})
  raise ArgumentError, 'account_id is required' if .nil? || .to_s.empty?
  raise ArgumentError, 'batch_id is required' if batch_id.nil? || batch_id.to_s.empty?

  body = @transport.request('GET', "accounts/#{}/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

Raises:

  • (ArgumentError)


43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/tesote_sdk/v2/batches.rb', line 43

def submit(, batch_id, token: nil, opts: {})
  raise ArgumentError, 'account_id is required' if .nil? || .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/#{}/batches/#{batch_id}/submit",
    body: payload,
    opts: opts
  )
  Models::BatchSubmitResult.from_hash(body)
end