Class: StraddlePay::Resources::EmbedAccounts

Inherits:
Base
  • Object
show all
Defined in:
lib/straddle_pay/resources/embed_accounts.rb

Overview

Manage embedded accounts for platform/marketplace use. Accessed via StraddlePay::Resources::Embed#accounts.

Constant Summary

Constants inherited from Base

Base::HEADER_KEYS

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from StraddlePay::Resources::Base

Instance Method Details

#capability_requestsAccountCapabilityRequests



9
# File 'lib/straddle_pay/resources/embed_accounts.rb', line 9

def capability_requests = @capability_requests ||= AccountCapabilityRequests.new(@client)

#create(organization_id:, account_type:, business_profile:, access_level:, **options) ⇒ Hash

Create an embedded account.

Parameters:

  • organization_id (String)

    parent organization ID

  • account_type (String)

    account type (e.g. "standard")

  • business_profile (Hash)

    business details (must include :name)

  • access_level (String)

    access level (e.g. "standard")

Returns:

  • (Hash)

    created account



18
19
20
21
22
23
24
25
# File 'lib/straddle_pay/resources/embed_accounts.rb', line 18

def create(organization_id:, account_type:, business_profile:, access_level:, **options)
  payload = {
    organization_id: organization_id, account_type: ,
    business_profile: business_profile, access_level: access_level, **options
  }.compact
  headers = extract_headers(payload)
  @client.post("v1/accounts", payload, headers: headers)
end

#get(id, **options) ⇒ Hash

Retrieve an account by ID.

Parameters:

  • id (String)

    account ID

Returns:

  • (Hash)

    account details



31
32
33
34
# File 'lib/straddle_pay/resources/embed_accounts.rb', line 31

def get(id, **options)
  headers = extract_headers(options)
  @client.get("v1/accounts/#{id}", headers: headers)
end

#list(**options) ⇒ Hash

List accounts with optional filters.

Returns:

  • (Hash)

    paginated account list



39
40
41
42
# File 'lib/straddle_pay/resources/embed_accounts.rb', line 39

def list(**options)
  headers = extract_headers(options)
  @client.get("v1/accounts", params: options, headers: headers)
end

#onboard(id, terms_of_service:, **options) ⇒ Hash

Onboard an account (accept terms of service).

Parameters:

  • id (String)

    account ID

  • terms_of_service (Hash)

    ToS acceptance (must include accepted: true)

Returns:

  • (Hash)

    onboarded account



58
59
60
61
62
# File 'lib/straddle_pay/resources/embed_accounts.rb', line 58

def onboard(id, terms_of_service:, **options)
  payload = { terms_of_service: terms_of_service, **options }.compact
  headers = extract_headers(payload)
  @client.post("v1/accounts/#{id}/onboard", payload, headers: headers)
end

#simulate(id, final_status:, **options) ⇒ Hash

Simulate account status change (sandbox only).

Parameters:

  • id (String)

    account ID

  • final_status (String)

    target status to simulate

Returns:

  • (Hash)

    simulated account



69
70
71
72
73
# File 'lib/straddle_pay/resources/embed_accounts.rb', line 69

def simulate(id, final_status:, **options)
  payload = { final_status: final_status, **options }.compact
  headers = extract_headers(payload)
  @client.post("v1/accounts/#{id}/simulate", payload, headers: headers)
end

#update(id, **options) ⇒ Hash

Update an account.

Parameters:

  • id (String)

    account ID

Returns:

  • (Hash)

    updated account



48
49
50
51
# File 'lib/straddle_pay/resources/embed_accounts.rb', line 48

def update(id, **options)
  headers = extract_headers(options)
  @client.put("v1/accounts/#{id}", options, headers: headers)
end