Class: Modulr::API::AccountsService

Inherits:
Service
  • Object
show all
Defined in:
lib/modulr/api/accounts_service.rb

Instance Attribute Summary

Attributes inherited from Service

#client

Instance Method Summary collapse

Methods inherited from Service

#format_datetime, #initialize

Constructor Details

This class inherits a constructor from Modulr::API::Service

Instance Method Details

#close(account_id:) ⇒ Object



26
27
28
29
30
# File 'lib/modulr/api/accounts_service.rb', line 26

def close(account_id:)
  client.post("/accounts/#{account_id}/close")

  nil
end

#create(customer_id:, currency:, product_code:, **opts) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/modulr/api/accounts_service.rb', line 15

def create(customer_id:, currency:, product_code:, **opts)
  payload = {
    currency: currency,
    productCode: product_code,
  }
  payload[:externalReference] = opts[:external_reference] if opts[:external_reference]

  response = client.post("/customers/#{customer_id}/accounts", payload)
  Resources::Accounts::.new(response.env[:raw_body], response.body)
end

#find(id:) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/modulr/api/accounts_service.rb', line 6

def find(id:)
  response = client.get("/accounts/#{id}")
  Resources::Accounts::.new(
    response.env[:raw_body],
    response.body,
    { requested_at: response.headers["date"] }
  )
end