Module: Unit::Customer

Defined in:
lib/unit/models/customer/customer.rb,
lib/unit/models/customer/list_customer_params.rb,
lib/unit/models/customer/archive_customer_request.rb,
lib/unit/models/customer/add_authorized_users_request.rb,
lib/unit/models/customer/patch_business_customer_request.rb,
lib/unit/models/customer/remove_authorized_users_request.rb,
lib/unit/models/customer/patch_individual_customer_request.rb

Defined Under Namespace

Classes: AddAuthorizedUsersRequest, ArchiveCustomerRequest, ListCustomerParams, PatchBusinessCustomerRequest, PatchIndividualCustomerRequest, RemoveAuthorizedUsersRequest

Constant Summary collapse

CUSTOMER_LIST_LIMIT =
100
CUSTOMER_LIST_OFFSET =
0

Class Method Summary collapse

Class Method Details

.add_authorized_users(customer_id:, authorized_users:) ⇒ Object

Add authorized users by calling Unit’s API

Parameters:

  • customer_id (String)
  • authorized_users (Array<AuthorizedUser>)

See Also:



81
82
83
84
# File 'lib/unit/models/customer/customer.rb', line 81

def add_authorized_users(customer_id:, authorized_users:)
  request = AddAuthorizedUsersRequest.new(customer_id, authorized_users)
  Unit::Resource::CustomerResource.add_authorized_users(request)
end

.archive_customer(customer_id:, reason: nil) ⇒ Object

Archive customer by calling Unit’s API

Parameters:

  • customer_id (String)
  • reason (String) (defaults to: nil)
    • optional

See Also:



72
73
74
75
# File 'lib/unit/models/customer/customer.rb', line 72

def archive_customer(customer_id:, reason: nil)
  request = ArchiveCustomerRequest.new(customer_id, reason)
  Unit::Resource::CustomerResource.archive(request)
end

.get_customer(customer_id) ⇒ UnitResponse, UnitError

Get customer by calling Unit’s API

Parameters:

  • customer_id (String)

Returns:

See Also:



50
51
52
# File 'lib/unit/models/customer/customer.rb', line 50

def get_customer(customer_id)
  Unit::Resource::CustomerResource.get(customer_id)
end

.list_customers(offset: CUSTOMER_LIST_OFFSET, limit: CUSTOMER_LIST_LIMIT, email: nil, tags: nil, status: nil, query: nil, sort: nil) ⇒ Object

List customers by calling Unit’s API

Parameters:

  • limit (Integer) (defaults to: CUSTOMER_LIST_LIMIT)
    • optional

  • offset (Integer) (defaults to: CUSTOMER_LIST_OFFSET)
    • optional

  • query (String) (defaults to: nil)
    • optional

  • email (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

  • status (String) (defaults to: nil)
    • optional

  • sort (String) (defaults to: nil)
    • optional

See Also:



63
64
65
66
# File 'lib/unit/models/customer/customer.rb', line 63

def list_customers(offset: CUSTOMER_LIST_OFFSET, limit: CUSTOMER_LIST_LIMIT, email: nil, tags: nil, status: nil, query: nil, sort: nil)
  request = ListCustomerParams.new(offset, limit, email, tags, status, query, sort)
  Unit::Resource::CustomerResource.list(request)
end

.remove_authorized_users(customer_id:, authorized_users:) ⇒ Object

Remove authorized users by calling Unit’s API

Parameters:

  • customer_id (String)
  • authorized_users (Array<AuthorizedUser>)

See Also:



90
91
92
93
# File 'lib/unit/models/customer/customer.rb', line 90

def remove_authorized_users(customer_id:, authorized_users:)
  request = RemoveAuthorizedUsersRequest.new(customer_id, authorized_users)
  Unit::Resource::CustomerResource.remove_authorized_users(request)
end

.update_business_customer(customer_id:, address: nil, phone: nil, contact: nil, authorized_users: nil, dba: nil, tags: nil) ⇒ UnitResponse, UnitError

Update business customer by calling Unit’s API

Parameters:

  • customer_id (String)
  • address (Address) (defaults to: nil)
    • optional

  • phone (Phone) (defaults to: nil)
    • optional

  • contact (BusinessContact) (defaults to: nil)
    • optional

  • authorized_users (Array<AuthorizedUser>) (defaults to: nil)
    • optional

  • dba (String) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

Returns:

See Also:



41
42
43
44
# File 'lib/unit/models/customer/customer.rb', line 41

def update_business_customer(customer_id:, address: nil, phone: nil, contact: nil, authorized_users: nil, dba: nil, tags: nil)
  request = PatchBusinessCustomerRequest.new(customer_id, address, phone, contact, authorized_users, dba, tags)
  Unit::Resource::CustomerResource.update(request)
end

.update_individual_customer(customer_id:, address: nil, phone: nil, email: nil, dba: nil, authorized_users: nil, tags: nil, jwt_subject: nil) ⇒ Object

Update individual customer by calling Unit’s API

Parameters:

  • customer_id (String)
  • address (Address) (defaults to: nil)
    • optional

  • phone (Phone) (defaults to: nil)
    • optional

  • email (String) (defaults to: nil)
    • optional

  • dba (String) (defaults to: nil)
    • optional

  • authorized_users (Array<AuthorizedUser>) (defaults to: nil)
    • optional

  • tags (Hash) (defaults to: nil)
    • optional

  • jwt_subject (String) (defaults to: nil)
    • optional

See Also:



26
27
28
29
# File 'lib/unit/models/customer/customer.rb', line 26

def update_individual_customer(customer_id:, address: nil, phone: nil, email: nil, dba: nil, authorized_users: nil, tags: nil, jwt_subject: nil)
  request = PatchIndividualCustomerRequest.new(customer_id, address, phone, email, dba, authorized_users, tags, jwt_subject)
  Unit::Resource::CustomerResource.update(request)
end