Class: TesoteSdk::V2::PaymentMethods

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

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ PaymentMethods

Returns a new instance of PaymentMethods.



4
5
6
# File 'lib/tesote_sdk/v2/payment_methods.rb', line 4

def initialize(transport)
  @transport = transport
end

Instance Method Details

#create(payment_method:, opts: {}) ⇒ Object

POST /v2/payment_methods

Raises:

  • (ArgumentError)


29
30
31
32
33
34
35
# File 'lib/tesote_sdk/v2/payment_methods.rb', line 29

def create(payment_method:, opts: {})
  raise ArgumentError, 'payment_method is required' if payment_method.nil?

  payload = { payment_method: payment_method }
  body = @transport.request('POST', 'payment_methods', body: payload, opts: opts)
  Models::PaymentMethod.from_hash(body)
end

#delete(id, opts: {}) ⇒ Object

DELETE /v2/payment_methods/id → 204 No Content

Raises:

  • (ArgumentError)


48
49
50
51
52
53
# File 'lib/tesote_sdk/v2/payment_methods.rb', line 48

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

  @transport.request('DELETE', "payment_methods/#{id}", opts: opts)
  nil
end

#get(id, opts: {}) ⇒ Object

GET /v2/payment_methods/id

Raises:

  • (ArgumentError)


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

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

  body = @transport.request('GET', "payment_methods/#{id}", opts: opts)
  Models::PaymentMethod.from_hash(body)
end

#list(query = {}, opts: {}) ⇒ Object

GET /v2/payment_methods



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

def list(query = {}, opts: {})
  body = @transport.request('GET', 'payment_methods', query: query, opts: opts)
  items_raw = (body && body['items']) || []
  Models::OffsetPage.new(
    items: Models::PaymentMethod.from_array(items_raw),
    limit: body && body['limit'],
    offset: body && body['offset'],
    has_more: body && body['has_more']
  )
end

#update(id, payment_method:, opts: {}) ⇒ Object

PATCH /v2/payment_methods/id

Raises:

  • (ArgumentError)


38
39
40
41
42
43
44
45
# File 'lib/tesote_sdk/v2/payment_methods.rb', line 38

def update(id, payment_method:, opts: {})
  raise ArgumentError, 'id is required' if id.nil? || id.to_s.empty?
  raise ArgumentError, 'payment_method is required' if payment_method.nil?

  payload = { payment_method: payment_method }
  body = @transport.request('PATCH', "payment_methods/#{id}", body: payload, opts: opts)
  Models::PaymentMethod.from_hash(body)
end