Class: Paid::Customer

Inherits:
Object
  • Object
show all
Defined in:
lib/paid_ruby/types/customer.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, organization_id:, name:, external_id: OMIT, phone: OMIT, employee_count: OMIT, annual_revenue: OMIT, tax_exempt_status: OMIT, creation_source: OMIT, creation_state: OMIT, website: OMIT, billing_address: OMIT, additional_properties: nil) ⇒ Paid::Customer

Parameters:

  • id (String)
  • organization_id (String)
  • name (String)
  • external_id (String) (defaults to: OMIT)
  • phone (String) (defaults to: OMIT)
  • employee_count (Float) (defaults to: OMIT)
  • annual_revenue (Float) (defaults to: OMIT)
  • tax_exempt_status (Paid::TaxExemptStatus) (defaults to: OMIT)
  • creation_source (Paid::CreationSource) (defaults to: OMIT)
  • creation_state (Paid::CreationState) (defaults to: OMIT)
  • website (String) (defaults to: OMIT)
  • billing_address (Paid::Address) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/paid_ruby/types/customer.rb', line 57

def initialize(id:, organization_id:, name:, external_id: OMIT, phone: OMIT, employee_count: OMIT, annual_revenue: OMIT, tax_exempt_status: OMIT, creation_source: OMIT, creation_state: OMIT, website: OMIT, billing_address: OMIT, additional_properties: nil)
  @id = id
  @organization_id = organization_id
  @name = name
  @external_id = external_id if external_id != OMIT
  @phone = phone if phone != OMIT
  @employee_count = employee_count if employee_count != OMIT
  @annual_revenue = annual_revenue if annual_revenue != OMIT
  @tax_exempt_status = tax_exempt_status if tax_exempt_status != OMIT
  @creation_source = creation_source if creation_source != OMIT
  @creation_state = creation_state if creation_state != OMIT
  @website = website if website != OMIT
  @billing_address = billing_address if billing_address != OMIT
  @additional_properties = additional_properties
  @_field_set = { "id": id, "organizationId": organization_id, "name": name, "externalId": external_id, "phone": phone, "employeeCount": employee_count, "annualRevenue": annual_revenue, "taxExemptStatus": tax_exempt_status, "creationSource": creation_source, "creationState": creation_state, "website": website, "billingAddress": billing_address }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



36
37
38
# File 'lib/paid_ruby/types/customer.rb', line 36

def additional_properties
  @additional_properties
end

#annual_revenueFloat (readonly)

Returns:

  • (Float)


24
25
26
# File 'lib/paid_ruby/types/customer.rb', line 24

def annual_revenue
  @annual_revenue
end

#billing_addressPaid::Address (readonly)

Returns:



34
35
36
# File 'lib/paid_ruby/types/customer.rb', line 34

def billing_address
  @billing_address
end

#creation_sourcePaid::CreationSource (readonly)



28
29
30
# File 'lib/paid_ruby/types/customer.rb', line 28

def creation_source
  @creation_source
end

#creation_statePaid::CreationState (readonly)

Returns:



30
31
32
# File 'lib/paid_ruby/types/customer.rb', line 30

def creation_state
  @creation_state
end

#employee_countFloat (readonly)

Returns:

  • (Float)


22
23
24
# File 'lib/paid_ruby/types/customer.rb', line 22

def employee_count
  @employee_count
end

#external_idString (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/paid_ruby/types/customer.rb', line 18

def external_id
  @external_id
end

#idString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/paid_ruby/types/customer.rb', line 12

def id
  @id
end

#nameString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/paid_ruby/types/customer.rb', line 16

def name
  @name
end

#organization_idString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/paid_ruby/types/customer.rb', line 14

def organization_id
  @organization_id
end

#phoneString (readonly)

Returns:

  • (String)


20
21
22
# File 'lib/paid_ruby/types/customer.rb', line 20

def phone
  @phone
end

#tax_exempt_statusPaid::TaxExemptStatus (readonly)



26
27
28
# File 'lib/paid_ruby/types/customer.rb', line 26

def tax_exempt_status
  @tax_exempt_status
end

#websiteString (readonly)

Returns:

  • (String)


32
33
34
# File 'lib/paid_ruby/types/customer.rb', line 32

def website
  @website
end

Class Method Details

.from_json(json_object:) ⇒ Paid::Customer

Parameters:

  • json_object (String)

Returns:



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/paid_ruby/types/customer.rb', line 79

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  organization_id = parsed_json["organizationId"]
  name = parsed_json["name"]
  external_id = parsed_json["externalId"]
  phone = parsed_json["phone"]
  employee_count = parsed_json["employeeCount"]
  annual_revenue = parsed_json["annualRevenue"]
  tax_exempt_status = parsed_json["taxExemptStatus"]
  creation_source = parsed_json["creationSource"]
  creation_state = parsed_json["creationState"]
  website = parsed_json["website"]
  unless parsed_json["billingAddress"].nil?
    billing_address = parsed_json["billingAddress"].to_json
    billing_address = Paid::Address.from_json(json_object: billing_address)
  else
    billing_address = nil
  end
  new(
    id: id,
    organization_id: organization_id,
    name: name,
    external_id: external_id,
    phone: phone,
    employee_count: employee_count,
    annual_revenue: annual_revenue,
    tax_exempt_status: tax_exempt_status,
    creation_source: creation_source,
    creation_state: creation_state,
    website: website,
    billing_address: billing_address,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/paid_ruby/types/customer.rb', line 127

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.organization_id.is_a?(String) != false || raise("Passed value for field obj.organization_id is not the expected type, validation failed.")
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
  obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.")
  obj.employee_count&.is_a?(Float) != false || raise("Passed value for field obj.employee_count is not the expected type, validation failed.")
  obj.annual_revenue&.is_a?(Float) != false || raise("Passed value for field obj.annual_revenue is not the expected type, validation failed.")
  obj.tax_exempt_status&.is_a?(Paid::TaxExemptStatus) != false || raise("Passed value for field obj.tax_exempt_status is not the expected type, validation failed.")
  obj.creation_source&.is_a?(Paid::CreationSource) != false || raise("Passed value for field obj.creation_source is not the expected type, validation failed.")
  obj.creation_state&.is_a?(Paid::CreationState) != false || raise("Passed value for field obj.creation_state is not the expected type, validation failed.")
  obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.")
  obj.billing_address.nil? || Paid::Address.validate_raw(obj: obj.billing_address)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


118
119
120
# File 'lib/paid_ruby/types/customer.rb', line 118

def to_json
  @_field_set&.to_json
end