Class: StraddlePay::Resources::Customers

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

Overview

Manage customers and their identity reviews.

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

#create(name:, type:, email:, phone:, device:, **options) ⇒ Hash

Create a new customer.

Parameters:

  • name (String)

    customer full name

  • type (String)

    "individual" or "business"

  • email (String)

    customer email

  • phone (String)

    phone in E.164 format (e.g. "+15551234567")

  • device (Hash)

    device info (must include :ip_address)

Returns:

  • (Hash)

    created customer



18
19
20
21
22
# File 'lib/straddle_pay/resources/customers.rb', line 18

def create(name:, type:, email:, phone:, device:, **options)
  payload = { name: name, type: type, email: email, phone: phone, device: device, **options }.compact
  headers = extract_headers(payload)
  @client.post("v1/customers", payload, headers: headers)
end

#delete(id, **options) ⇒ Hash

Delete a customer.

Parameters:

  • id (String)

    customer ID

Returns:

  • (Hash)

    deletion confirmation



55
56
57
58
# File 'lib/straddle_pay/resources/customers.rb', line 55

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

#get(id, **options) ⇒ Hash

Retrieve a customer by ID.

Parameters:

  • id (String)

    customer ID

Returns:

  • (Hash)

    customer details



28
29
30
31
# File 'lib/straddle_pay/resources/customers.rb', line 28

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

#list(**options) ⇒ Hash

List customers with optional pagination.

Parameters:

  • options (Hash)

    filter/pagination params (page_number, page_size, etc.)

Returns:

  • (Hash)

    paginated customer list



37
38
39
40
# File 'lib/straddle_pay/resources/customers.rb', line 37

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

#reviewsCustomerReviews

Returns customer identity review sub-resource.

Returns:



8
# File 'lib/straddle_pay/resources/customers.rb', line 8

def reviews = @reviews ||= CustomerReviews.new(@client)

#unmasked(id, **options) ⇒ Hash

Retrieve unmasked customer details.

Parameters:

  • id (String)

    customer ID

Returns:

  • (Hash)

    unmasked customer details



64
65
66
67
# File 'lib/straddle_pay/resources/customers.rb', line 64

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

#update(id, **options) ⇒ Hash

Update a customer.

Parameters:

  • id (String)

    customer ID

Returns:

  • (Hash)

    updated customer



46
47
48
49
# File 'lib/straddle_pay/resources/customers.rb', line 46

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