Class: Unit::Customer::PatchBusinessCustomerRequest

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(customer_id, address = nil, phone = nil, contact = nil, authorized_users = nil, dba = nil, tags = nil) ⇒ PatchBusinessCustomerRequest

more information regarding tags: docs.unit.co/#updating-tags

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



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

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

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



8
9
10
# File 'lib/unit/models/customer/patch_business_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_business_customer_request.rb', line 8

def authorized_users
  @authorized_users
end

#contactObject (readonly)

Returns the value of attribute contact.



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

def contact
  @contact
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



8
9
10
# File 'lib/unit/models/customer/patch_business_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_business_customer_request.rb', line 8

def dba
  @dba
end

#phoneObject (readonly)

Returns the value of attribute phone.



8
9
10
# File 'lib/unit/models/customer/patch_business_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_business_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_business_customer_request.rb', line 29

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