Class: Straddle::Resources::Accounts

Inherits:
Object
  • Object
show all
Defined in:
lib/straddle/resources/accounts.rb,
sig/straddle/resources/accounts.rbs

Overview

Accounts represent businesses that use Straddle through a platform.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Accounts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Accounts.

Parameters:



263
264
265
# File 'lib/straddle/resources/accounts.rb', line 263

def initialize(client:)
  @client = client
end

Instance Method Details

#create(access_level:, account_type:, business_profile:, organization_id:, external_id: nil, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::AccountResponse

Some parameter documentations has been truncated, see Models::AccountCreateParams for more details.

Creates a business account in the specified organization and returns the account.

Parameters:

  • access_level (Symbol, Straddle::Models::AccountCreateParams::AccessLevel) —

    Body param: The account access level. standard provides normal account access,

  • account_type (Symbol, Straddle::Models::AccountCreateParams::AccountType) —

    Body param: Account type. The only accepted value is business.

  • business_profile (Straddle::Models::AccountBusinessProfile) —

    Body param

  • organization_id (String) —

    Body param: ID of the organization that will own the account.

  • external_id (String, nil) —

    Body param: Your unique ID for the account.

  • metadata (Hash{Symbol=>String, nil}, nil) —

    Body param: Up to 20 user-defined key-value pairs.

  • correlation_id (String) —

    Header param: Optional client-generated identifier for tracing a series of relat

  • idempotency_key (String) —

    Header param: Optional client-generated key for an idempotent request.

  • request_id (String) —

    Header param: Optional client-generated identifier for tracing one request.

  • request_options (Straddle::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/straddle/resources/accounts.rb', line 38

def create(params)
  parsed, options = Straddle::AccountCreateParams.dump_request(params)
  header_params = {
    correlation_id: "correlation-id",
    idempotency_key: "idempotency-key",
    request_id: "request-id"
  }
  @client.request(
    method: :post,
    path: "v1/accounts",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Straddle::AccountResponse,
    options: options
  )
end

#list(external_id: nil, page_number: nil, page_size: nil, search_text: nil, sort_by: nil, sort_order: nil, status: nil, type: nil, correlation_id: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::AccountList

Some parameter documentations has been truncated, see Models::AccountListParams for more details.

Returns a paginated list of accounts for your platform. Filter the list by status, type, external ID, or text search.

Parameters:

  • external_id (String) —

    Query param: Your external ID for the account.

  • page_number (Integer) —

    Query param: Page number. Defaults to 1.

  • page_size (Integer) —

    Query param: Number of results per page. Defaults to 100. Maximum 1000.

  • search_text (String) —

    Query param: Text to search for across account fields.

  • sort_by (String) —

    Query param: Field used to sort results. Defaults to id.

  • sort_order (Symbol, Straddle::Models::AccountListParams::SortOrder) —

    Query param: Sort direction. Defaults to asc.

  • status (Symbol, Straddle::Models::AccountListParams::Status) —

    Query param: Account status to return.

  • type (Symbol, Straddle::Models::AccountListParams::Type) —

    Query param: Account type to return.

  • correlation_id (String) —

    Header param: Optional client-generated identifier for tracing a series of relat

  • request_id (String) —

    Header param: Optional client-generated identifier for tracing one request.

  • request_options (Straddle::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/straddle/resources/accounts.rb', line 158

def list(params = {})
  query_params = %i[external_id page_number page_size search_text sort_by sort_order status type]
  parsed, options = Straddle::AccountListParams.dump_request(params)
  query = Straddle::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "v1/accounts",
    query: query,
    headers:
      parsed.except(*query_params).transform_keys(
        correlation_id: "correlation-id",
        request_id: "request-id"
      ),
    model: Straddle::AccountList,
    options: options
  )
end

#onboard(account_id, terms_of_service:, correlation_id: nil, idempotency_key: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::AccountResponse

Some parameter documentations has been truncated, see Models::AccountOnboardParams for more details.

Starts onboarding and records the account's acceptance of Straddle's Terms of Service. The account must have at least one representative and one linked bank account. This operation also moves all associated representatives and linked bank accounts to onboarding.

Parameters:

  • account_id (String) —

    Path param: The ID of the account.

  • terms_of_service (Straddle::Models::TermsOfService) —

    Body param

  • correlation_id (String) —

    Header param: Optional client-generated identifier for tracing a series of relat

  • idempotency_key (String) —

    Header param: Optional client-generated key for an idempotent request.

  • request_id (String) —

    Header param: Optional client-generated identifier for tracing one request.

  • request_options (Straddle::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/straddle/resources/accounts.rb', line 201

def onboard(, params)
  parsed, options = Straddle::AccountOnboardParams.dump_request(params)
  header_params = {
    correlation_id: "correlation-id",
    idempotency_key: "idempotency-key",
    request_id: "request-id"
  }
  @client.request(
    method: :post,
    path: ["v1/accounts/%1$s/onboard", ],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Straddle::AccountResponse,
    options: options
  )
end

#retrieve(account_id, correlation_id: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::AccountResponse

Returns the account with the specified ID.

Parameters:

  • account_id (String) —

    The ID of the account.

  • correlation_id (String) —

    Optional client-generated identifier for tracing a series of related requests.

  • request_id (String) —

    Optional client-generated identifier for tracing one request.

  • request_options (Straddle::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



70
71
72
73
74
75
76
77
78
79
# File 'lib/straddle/resources/accounts.rb', line 70

def retrieve(, params = {})
  parsed, options = Straddle::AccountRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v1/accounts/%1$s", ],
    headers: parsed.transform_keys(correlation_id: "correlation-id", request_id: "request-id"),
    model: Straddle::AccountResponse,
    options: options
  )
end

#simulate_onboarding(account_id, final_status: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::AccountResponse

Some parameter documentations has been truncated, see Models::AccountSimulateOnboardingParams for more details.

Simulates an account status transition to onboarding or active in the sandbox and returns the account.

Parameters:

  • account_id (String) —

    Path param: The ID of the account.

  • final_status (Symbol, Straddle::Models::AccountSimulateOnboardingParams::FinalStatus) —

    Query param: Final account status to produce in the sandbox simulation.

  • correlation_id (String) —

    Header param: Optional client-generated identifier for tracing a series of relat

  • idempotency_key (String) —

    Header param: Optional client-generated key for an idempotent request.

  • request_id (String) —

    Header param: Optional client-generated identifier for tracing one request.

  • request_options (Straddle::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/straddle/resources/accounts.rb', line 241

def simulate_onboarding(, params = {})
  query_params = [:final_status]
  parsed, options = Straddle::AccountSimulateOnboardingParams.dump_request(params)
  query = Straddle::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :post,
    path: ["v1/accounts/%1$s/simulate", ],
    query: query,
    headers:
      parsed.except(*query_params).transform_keys(
        correlation_id: "correlation-id",
        idempotency_key: "idempotency-key",
        request_id: "request-id"
      ),
    model: Straddle::AccountResponse,
    options: options
  )
end

#update(account_id, business_profile:, external_id: nil, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, request_options: {}) ⇒ Straddle::Models::AccountResponse

Some parameter documentations has been truncated, see Models::AccountUpdateParams for more details.

Updates an account's business profile, metadata, and external ID, then returns the account.

Parameters:

  • account_id (String) —

    Path param: The ID of the account.

  • business_profile (Straddle::Models::AccountBusinessProfile) —

    Body param

  • external_id (String, nil) —

    Body param: Your unique ID for the account.

  • metadata (Hash{Symbol=>String, nil}, nil) —

    Body param: Up to 20 user-defined key-value pairs.

  • correlation_id (String) —

    Header param: Optional client-generated identifier for tracing a series of relat

  • idempotency_key (String) —

    Header param: Optional client-generated key for an idempotent request.

  • request_id (String) —

    Header param: Optional client-generated identifier for tracing one request.

  • request_options (Straddle::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/straddle/resources/accounts.rb', line 108

def update(, params)
  parsed, options = Straddle::AccountUpdateParams.dump_request(params)
  header_params = {
    correlation_id: "correlation-id",
    idempotency_key: "idempotency-key",
    request_id: "request-id"
  }
  @client.request(
    method: :put,
    path: ["v1/accounts/%1$s", ],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Straddle::AccountResponse,
    options: options
  )
end