Class: Straddle::Resources::Customers

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

Overview

Customers are individuals or businesses that send or receive payments through your integration.

Defined Under Namespace

Classes: Review

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Customers

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 Customers.

Parameters:



349
350
351
352
# File 'lib/straddle/resources/customers.rb', line 349

def initialize(client:)
  @client = client
  @review = Straddle::Resources::Customers::Review.new(client: client)
end

Instance Attribute Details

#review ⇒ Straddle::Resources::Customers::Review (readonly)

Customers are individuals or businesses that send or receive payments through your integration.



11
12
13
# File 'lib/straddle/resources/customers.rb', line 11

def review
  @review
end

Instance Method Details

#create(device:, email:, name:, phone:, type:, address: nil, compliance_profile: nil, config: nil, external_id: nil, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::CustomerResponse

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

Creates a customer and starts identity, fraud, and risk assessments.

Parameters:

  • device (Straddle::Models::CustomerDevice) —

    Body param

  • email (String) —

    Body param: Customer email address.

  • name (String) —

    Body param: Full name for an individual customer or business name for a business

  • phone (String) —

    Body param: Customer phone number in E.164 format. A mobile number is preferred.

  • type (Symbol, Straddle::Models::CustomerType) —

    Body param

  • address (Straddle::Models::CustomerAddress, nil) —

    Body param: Customer postal address. When provided, the object must include all

  • compliance_profile (Straddle::Models::UnmaskedComplianceProfile::IndividualComplianceProfile, Straddle::Models::UnmaskedComplianceProfile::BusinessComplianceProfile, nil) —

    Body param: Customer compliance profile. When provided, the object must include

  • config (Straddle::Models::CustomerConfiguration) —

    Body param

  • external_id (String, nil) —

    Body param: Unique identifier for the customer in your system.

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

    Body param: Up to 20 user-defined key-value pairs associated with the customer.

  • 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.

  • straddle_account_id (String) —

    Header param: For platform requests, the embedded account UUID that sets the req

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

Returns:

See Also:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/straddle/resources/customers.rb', line 53

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

#delete(id, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::CustomerResponse

Permanently deletes a customer record. The deletion cannot be undone. Use this endpoint only to meet regulatory or privacy requirements.

Parameters:

  • id (String) —

    Unique identifier for the customer.

  • correlation_id (String) —

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

  • idempotency_key (String) —

    Optional client-generated key for an idempotent request.

  • request_id (String) —

    Optional client-generated identifier for tracing one request.

  • straddle_account_id (String) —

    For platform requests, the embedded account UUID that sets the request scope.

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

Returns:

See Also:



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/straddle/resources/customers.rb', line 257

def delete(id, params = {})
  parsed, options = Straddle::CustomerDeleteParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["v1/customers/%1$s", id],
    headers:
      parsed.transform_keys(
        correlation_id: "correlation-id",
        idempotency_key: "idempotency-key",
        request_id: "request-id",
        straddle_account_id: "straddle-account-id"
      ),
    model: Straddle::CustomerResponse,
    options: options
  )
end

#list(created_from: nil, created_to: nil, email: nil, external_id: nil, name: nil, page_number: nil, page_size: nil, search_text: nil, sort_by: nil, sort_order: nil, status: nil, types: nil, correlation_id: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::CustomerSummaryList

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

Returns a paginated list of customers for the account. Optional query parameters filter, search, and sort the results.

Parameters:

  • created_from (Time) —

    Query param: Start date for filtering by created_at date.

  • created_to (Time) —

    Query param: End date for filtering by created_at date.

  • email (String) —

    Query param: Filter customers by email address.

  • external_id (String) —

    Query param: Filter by your system's external_id.

  • name (String) —

    Query param: Filter customers by name (partial match).

  • page_number (Integer) —

    Query param: Page number for paginated results. Starts at 1.

  • page_size (Integer) —

    Query param: Number of results per page. Maximum: 1000.

  • search_text (String) —

    Query param: General search term to filter customers.

  • sort_by (Symbol, Straddle::Models::CustomerListParams::SortBy) —

    Query param: Field used to sort the results.

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

    Query param: Order in which to sort the results.

  • status (Array<Symbol, Straddle::Models::CustomerStatus>) —

    Query param: Filter customers by their current status.

  • types (Array<Symbol, Straddle::Models::CustomerType>) —

    Query param: Filter by customer type individual or business.

  • 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.

  • straddle_account_id (String) —

    Header param: For platform requests, the embedded account UUID that sets the req

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

Returns:

See Also:



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/straddle/resources/customers.rb', line 205

def list(params = {})
  query_params = %i[
    created_from
    created_to
    email
    external_id
    name
    page_number
    page_size
    search_text
    sort_by
    sort_order
    status
    types
  ]
  parsed, options = Straddle::CustomerListParams.dump_request(params)
  query = Straddle::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "v1/customers",
    query: query,
    headers:
      parsed.except(*query_params).transform_keys(
        correlation_id: "correlation-id",
        request_id: "request-id",
        straddle_account_id: "straddle-account-id"
      ),
    model: Straddle::CustomerSummaryList,
    options: options
  )
end

#list_unmasked(id, correlation_id: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::UnmaskedCustomerResponse

Returns unmasked details for a customer, including personally identifiable information. Straddle must enable this endpoint for your account. Use this endpoint only when unmasked data is necessary.

Parameters:

  • id (String) —

    Unique identifier for the customer.

  • 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.

  • straddle_account_id (String) —

    For platform requests, the embedded account UUID that sets the request scope.

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

Returns:

See Also:



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/straddle/resources/customers.rb', line 293

def list_unmasked(id, params = {})
  parsed, options = Straddle::CustomerListUnmaskedParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v1/customers/%1$s/unmasked", id],
    headers:
      parsed.transform_keys(
        correlation_id: "correlation-id",
        request_id: "request-id",
        straddle_account_id: "straddle-account-id"
      ),
    model: Straddle::UnmaskedCustomerResponse,
    options: options
  )
end

#refresh_review(id, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::CustomerResponse

Starts a new identity review for a customer. The review runs asynchronously. Webhooks and the customer review endpoint return updated results.

Parameters:

  • id (String) —

    Unique identifier for the customer.

  • correlation_id (String) —

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

  • idempotency_key (String) —

    Optional client-generated key for an idempotent request.

  • request_id (String) —

    Optional client-generated identifier for tracing one request.

  • straddle_account_id (String) —

    For platform requests, the embedded account UUID that sets the request scope.

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

Returns:

See Also:



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/straddle/resources/customers.rb', line 329

def refresh_review(id, params = {})
  parsed, options = Straddle::CustomerRefreshReviewParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["v1/customers/%1$s/refresh_review", id],
    headers:
      parsed.transform_keys(
        correlation_id: "correlation-id",
        idempotency_key: "idempotency-key",
        request_id: "request-id",
        straddle_account_id: "straddle-account-id"
      ),
    model: Straddle::CustomerResponse,
    options: options
  )
end

#retrieve(id, correlation_id: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::CustomerResponse

Returns a customer by id.

Parameters:

  • id (String) —

    Unique identifier for the customer.

  • 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.

  • straddle_account_id (String) —

    For platform requests, the embedded account UUID that sets the request scope.

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

Returns:

See Also:



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/straddle/resources/customers.rb', line 88

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

#update(id, device:, email:, name:, phone:, status:, address: nil, compliance_profile: nil, external_id: nil, metadata: nil, correlation_id: nil, idempotency_key: nil, request_id: nil, straddle_account_id: nil, request_options: {}) ⇒ Straddle::Models::CustomerResponse

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

Updates an existing customer's profile, status, and metadata.

Parameters:

  • id (String) —

    Path param: Unique identifier for the customer.

  • device (Straddle::Models::CustomerDevice) —

    Body param

  • email (String) —

    Body param: Customer email address.

  • name (String) —

    Body param: Full name for an individual customer or business name for a business

  • phone (String) —

    Body param: Customer phone number in E.164 format.

  • status (Symbol, Straddle::Models::CustomerStatus) —

    Body param

  • address (Straddle::Models::CustomerAddress, nil) —

    Body param: Customer postal address. When provided, the object must include all

  • compliance_profile (Straddle::Models::UnmaskedComplianceProfile::IndividualComplianceProfile, Straddle::Models::UnmaskedComplianceProfile::BusinessComplianceProfile, nil) —

    Body param

  • external_id (String, nil) —

    Body param: Unique identifier for the customer in your system.

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

    Body param: Up to 20 user-defined key-value pairs associated with the customer.

  • 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.

  • straddle_account_id (String) —

    Header param: For platform requests, the embedded account UUID that sets the req

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

Returns:

See Also:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/straddle/resources/customers.rb', line 144

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