Class: Unit::Customer::PatchIndividualCustomerRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/models/customer/patch_individual_customer_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(customer_id, address = nil, phone = nil, email = nil, dba = nil, authorized_users = nil, tags = nil, jwt_subject = nil) ⇒ PatchIndividualCustomerRequest

Returns a new instance of PatchIndividualCustomerRequest.

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



18
19
20
21
22
23
24
25
26
27
# File 'lib/unit/models/customer/patch_individual_customer_request.rb', line 18

def initialize(customer_id, address = nil, phone = nil, email = nil, dba = nil, authorized_users = nil, tags = nil, jwt_subject = nil)
  @customer_id = customer_id
  @address = address
  @phone = phone
  @email = email
  @dba = dba
  @authorized_users = authorized_users
  @tags = tags
  @jwt_subject = jwt_subject
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



8
9
10
# File 'lib/unit/models/customer/patch_individual_customer_request.rb', line 8

def address
  @address
end

#authorized_usersObject (readonly)

Returns the value of attribute authorized_users.



8
9
10
# File 'lib/unit/models/customer/patch_individual_customer_request.rb', line 8

def authorized_users
  @authorized_users
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



8
9
10
# File 'lib/unit/models/customer/patch_individual_customer_request.rb', line 8

def customer_id
  @customer_id
end

#dbaObject (readonly)

Returns the value of attribute dba.



8
9
10
# File 'lib/unit/models/customer/patch_individual_customer_request.rb', line 8

def dba
  @dba
end

#emailObject (readonly)

Returns the value of attribute email.



8
9
10
# File 'lib/unit/models/customer/patch_individual_customer_request.rb', line 8

def email
  @email
end

#jwt_subjectObject (readonly)

Returns the value of attribute jwt_subject.



8
9
10
# File 'lib/unit/models/customer/patch_individual_customer_request.rb', line 8

def jwt_subject
  @jwt_subject
end

#phoneObject (readonly)

Returns the value of attribute phone.



8
9
10
# File 'lib/unit/models/customer/patch_individual_customer_request.rb', line 8

def phone
  @phone
end

#tagsObject (readonly)

Returns the value of attribute tags.



8
9
10
# File 'lib/unit/models/customer/patch_individual_customer_request.rb', line 8

def tags
  @tags
end

Instance Method Details

#to_json_apiObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/unit/models/customer/patch_individual_customer_request.rb', line 29

def to_json_api
  payload = {
    data: {
      type: "individualCustomer",
      attributes: {
        address: address&.represent,
        phone: phone&.represent,
        email: email,
        dba: dba,
        authorizedUsers: authorized_users&.map(&:represent),
        tags: tags
      }
    }
  }
  payload[:data][:attributes].compact!
  payload.to_json
end