paid_ruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/environment.rb +9 -0
- data/lib/extensions/batch.rb +41 -0
- data/lib/gemconfig.rb +13 -0
- data/lib/paid_ruby/agents/client.rb +543 -0
- data/lib/paid_ruby/contacts/client.rb +437 -0
- data/lib/paid_ruby/customers/client.rb +604 -0
- data/lib/paid_ruby/orders/client.rb +379 -0
- data/lib/paid_ruby/orders/lines/client.rb +99 -0
- data/lib/paid_ruby/types/address.rb +91 -0
- data/lib/paid_ruby/types/agent.rb +109 -0
- data/lib/paid_ruby/types/agent_attribute.rb +74 -0
- data/lib/paid_ruby/types/agent_price_point.rb +81 -0
- data/lib/paid_ruby/types/agent_price_point_tiers.rb +70 -0
- data/lib/paid_ruby/types/agent_update.rb +95 -0
- data/lib/paid_ruby/types/api_error.rb +54 -0
- data/lib/paid_ruby/types/billing_frequency.rb +11 -0
- data/lib/paid_ruby/types/charge_type.rb +12 -0
- data/lib/paid_ruby/types/contact.rb +155 -0
- data/lib/paid_ruby/types/creation_source.rb +12 -0
- data/lib/paid_ruby/types/creation_state.rb +10 -0
- data/lib/paid_ruby/types/customer.rb +142 -0
- data/lib/paid_ruby/types/customer_update.rb +120 -0
- data/lib/paid_ruby/types/error.rb +58 -0
- data/lib/paid_ruby/types/order.rb +172 -0
- data/lib/paid_ruby/types/order_line.rb +158 -0
- data/lib/paid_ruby/types/order_line_attribute.rb +83 -0
- data/lib/paid_ruby/types/order_line_attribute_pricing.rb +93 -0
- data/lib/paid_ruby/types/order_line_create.rb +77 -0
- data/lib/paid_ruby/types/price_point.rb +81 -0
- data/lib/paid_ruby/types/pricing.rb +97 -0
- data/lib/paid_ruby/types/pricing_model_type.rb +11 -0
- data/lib/paid_ruby/types/salutation.rb +14 -0
- data/lib/paid_ruby/types/signal.rb +77 -0
- data/lib/paid_ruby/types/tax_exempt_status.rb +11 -0
- data/lib/paid_ruby/types/tier.rb +70 -0
- data/lib/paid_ruby/usage/client.rb +97 -0
- data/lib/paid_ruby.rb +83 -0
- data/lib/requests.rb +166 -0
- data/lib/types_export.rb +28 -0
- metadata +163 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "pricing"
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Paid
|
7
|
+
class AgentAttribute
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :name
|
10
|
+
# @return [Boolean]
|
11
|
+
attr_reader :active
|
12
|
+
# @return [Paid::Pricing]
|
13
|
+
attr_reader :pricing
|
14
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
15
|
+
attr_reader :additional_properties
|
16
|
+
# @return [Object]
|
17
|
+
attr_reader :_field_set
|
18
|
+
protected :_field_set
|
19
|
+
|
20
|
+
OMIT = Object.new
|
21
|
+
|
22
|
+
# @param name [String]
|
23
|
+
# @param active [Boolean]
|
24
|
+
# @param pricing [Paid::Pricing]
|
25
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
26
|
+
# @return [Paid::AgentAttribute]
|
27
|
+
def initialize(name:, active:, pricing:, additional_properties: nil)
|
28
|
+
@name = name
|
29
|
+
@active = active
|
30
|
+
@pricing = pricing
|
31
|
+
@additional_properties = additional_properties
|
32
|
+
@_field_set = { "name": name, "active": active, "pricing": pricing }
|
33
|
+
end
|
34
|
+
# Deserialize a JSON object to an instance of AgentAttribute
|
35
|
+
#
|
36
|
+
# @param json_object [String]
|
37
|
+
# @return [Paid::AgentAttribute]
|
38
|
+
def self.from_json(json_object:)
|
39
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
40
|
+
parsed_json = JSON.parse(json_object)
|
41
|
+
name = parsed_json["name"]
|
42
|
+
active = parsed_json["active"]
|
43
|
+
unless parsed_json["pricing"].nil?
|
44
|
+
pricing = parsed_json["pricing"].to_json
|
45
|
+
pricing = Paid::Pricing.from_json(json_object: pricing)
|
46
|
+
else
|
47
|
+
pricing = nil
|
48
|
+
end
|
49
|
+
new(
|
50
|
+
name: name,
|
51
|
+
active: active,
|
52
|
+
pricing: pricing,
|
53
|
+
additional_properties: struct
|
54
|
+
)
|
55
|
+
end
|
56
|
+
# Serialize an instance of AgentAttribute to a JSON object
|
57
|
+
#
|
58
|
+
# @return [String]
|
59
|
+
def to_json
|
60
|
+
@_field_set&.to_json
|
61
|
+
end
|
62
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
63
|
+
# hash and check each fields type against the current object's property
|
64
|
+
# definitions.
|
65
|
+
#
|
66
|
+
# @param obj [Object]
|
67
|
+
# @return [Void]
|
68
|
+
def self.validate_raw(obj:)
|
69
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
70
|
+
obj.active.is_a?(Boolean) != false || raise("Passed value for field obj.active is not the expected type, validation failed.")
|
71
|
+
Paid::Pricing.validate_raw(obj: obj.pricing)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "agent_price_point_tiers"
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Paid
|
7
|
+
class AgentPricePoint
|
8
|
+
# @return [Float]
|
9
|
+
attr_reader :unit_price
|
10
|
+
# @return [Float]
|
11
|
+
attr_reader :min_quantity
|
12
|
+
# @return [Float]
|
13
|
+
attr_reader :included_quantity
|
14
|
+
# @return [Array<Paid::AgentPricePointTiers>]
|
15
|
+
attr_reader :tiers
|
16
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
17
|
+
attr_reader :additional_properties
|
18
|
+
# @return [Object]
|
19
|
+
attr_reader :_field_set
|
20
|
+
protected :_field_set
|
21
|
+
|
22
|
+
OMIT = Object.new
|
23
|
+
|
24
|
+
# @param unit_price [Float]
|
25
|
+
# @param min_quantity [Float]
|
26
|
+
# @param included_quantity [Float]
|
27
|
+
# @param tiers [Array<Paid::AgentPricePointTiers>]
|
28
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
29
|
+
# @return [Paid::AgentPricePoint]
|
30
|
+
def initialize(unit_price: OMIT, min_quantity: OMIT, included_quantity: OMIT, tiers: OMIT, additional_properties: nil)
|
31
|
+
@unit_price = unit_price if unit_price != OMIT
|
32
|
+
@min_quantity = min_quantity if min_quantity != OMIT
|
33
|
+
@included_quantity = included_quantity if included_quantity != OMIT
|
34
|
+
@tiers = tiers if tiers != OMIT
|
35
|
+
@additional_properties = additional_properties
|
36
|
+
@_field_set = { "unitPrice": unit_price, "minQuantity": min_quantity, "includedQuantity": included_quantity, "tiers": tiers }.reject do | _k, v |
|
37
|
+
v == OMIT
|
38
|
+
end
|
39
|
+
end
|
40
|
+
# Deserialize a JSON object to an instance of AgentPricePoint
|
41
|
+
#
|
42
|
+
# @param json_object [String]
|
43
|
+
# @return [Paid::AgentPricePoint]
|
44
|
+
def self.from_json(json_object:)
|
45
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
46
|
+
parsed_json = JSON.parse(json_object)
|
47
|
+
unit_price = parsed_json["unitPrice"]
|
48
|
+
min_quantity = parsed_json["minQuantity"]
|
49
|
+
included_quantity = parsed_json["includedQuantity"]
|
50
|
+
tiers = parsed_json["tiers"]&.map do | item |
|
51
|
+
item = item.to_json
|
52
|
+
Paid::AgentPricePointTiers.from_json(json_object: item)
|
53
|
+
end
|
54
|
+
new(
|
55
|
+
unit_price: unit_price,
|
56
|
+
min_quantity: min_quantity,
|
57
|
+
included_quantity: included_quantity,
|
58
|
+
tiers: tiers,
|
59
|
+
additional_properties: struct
|
60
|
+
)
|
61
|
+
end
|
62
|
+
# Serialize an instance of AgentPricePoint to a JSON object
|
63
|
+
#
|
64
|
+
# @return [String]
|
65
|
+
def to_json
|
66
|
+
@_field_set&.to_json
|
67
|
+
end
|
68
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
69
|
+
# hash and check each fields type against the current object's property
|
70
|
+
# definitions.
|
71
|
+
#
|
72
|
+
# @param obj [Object]
|
73
|
+
# @return [Void]
|
74
|
+
def self.validate_raw(obj:)
|
75
|
+
obj.unit_price&.is_a?(Float) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.")
|
76
|
+
obj.min_quantity&.is_a?(Float) != false || raise("Passed value for field obj.min_quantity is not the expected type, validation failed.")
|
77
|
+
obj.included_quantity&.is_a?(Float) != false || raise("Passed value for field obj.included_quantity is not the expected type, validation failed.")
|
78
|
+
obj.tiers&.is_a?(Array) != false || raise("Passed value for field obj.tiers is not the expected type, validation failed.")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "ostruct"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Paid
|
6
|
+
class AgentPricePointTiers
|
7
|
+
# @return [Float]
|
8
|
+
attr_reader :min_quantity
|
9
|
+
# @return [Float]
|
10
|
+
attr_reader :max_quantity
|
11
|
+
# @return [Float]
|
12
|
+
attr_reader :unit_price
|
13
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
14
|
+
attr_reader :additional_properties
|
15
|
+
# @return [Object]
|
16
|
+
attr_reader :_field_set
|
17
|
+
protected :_field_set
|
18
|
+
|
19
|
+
OMIT = Object.new
|
20
|
+
|
21
|
+
# @param min_quantity [Float]
|
22
|
+
# @param max_quantity [Float]
|
23
|
+
# @param unit_price [Float]
|
24
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
25
|
+
# @return [Paid::AgentPricePointTiers]
|
26
|
+
def initialize(min_quantity: OMIT, max_quantity: OMIT, unit_price:, additional_properties: nil)
|
27
|
+
@min_quantity = min_quantity if min_quantity != OMIT
|
28
|
+
@max_quantity = max_quantity if max_quantity != OMIT
|
29
|
+
@unit_price = unit_price
|
30
|
+
@additional_properties = additional_properties
|
31
|
+
@_field_set = { "minQuantity": min_quantity, "maxQuantity": max_quantity, "unitPrice": unit_price }.reject do | _k, v |
|
32
|
+
v == OMIT
|
33
|
+
end
|
34
|
+
end
|
35
|
+
# Deserialize a JSON object to an instance of AgentPricePointTiers
|
36
|
+
#
|
37
|
+
# @param json_object [String]
|
38
|
+
# @return [Paid::AgentPricePointTiers]
|
39
|
+
def self.from_json(json_object:)
|
40
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
41
|
+
parsed_json = JSON.parse(json_object)
|
42
|
+
min_quantity = parsed_json["minQuantity"]
|
43
|
+
max_quantity = parsed_json["maxQuantity"]
|
44
|
+
unit_price = parsed_json["unitPrice"]
|
45
|
+
new(
|
46
|
+
min_quantity: min_quantity,
|
47
|
+
max_quantity: max_quantity,
|
48
|
+
unit_price: unit_price,
|
49
|
+
additional_properties: struct
|
50
|
+
)
|
51
|
+
end
|
52
|
+
# Serialize an instance of AgentPricePointTiers to a JSON object
|
53
|
+
#
|
54
|
+
# @return [String]
|
55
|
+
def to_json
|
56
|
+
@_field_set&.to_json
|
57
|
+
end
|
58
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
59
|
+
# hash and check each fields type against the current object's property
|
60
|
+
# definitions.
|
61
|
+
#
|
62
|
+
# @param obj [Object]
|
63
|
+
# @return [Void]
|
64
|
+
def self.validate_raw(obj:)
|
65
|
+
obj.min_quantity&.is_a?(Float) != false || raise("Passed value for field obj.min_quantity is not the expected type, validation failed.")
|
66
|
+
obj.max_quantity&.is_a?(Float) != false || raise("Passed value for field obj.max_quantity is not the expected type, validation failed.")
|
67
|
+
obj.unit_price.is_a?(Float) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "agent_attribute"
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Paid
|
7
|
+
class AgentUpdate
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :name
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :description
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :external_id
|
14
|
+
# @return [Boolean]
|
15
|
+
attr_reader :active
|
16
|
+
# @return [String]
|
17
|
+
attr_reader :agent_code
|
18
|
+
# @return [Array<Paid::AgentAttribute>]
|
19
|
+
attr_reader :agent_attributes
|
20
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
21
|
+
attr_reader :additional_properties
|
22
|
+
# @return [Object]
|
23
|
+
attr_reader :_field_set
|
24
|
+
protected :_field_set
|
25
|
+
|
26
|
+
OMIT = Object.new
|
27
|
+
|
28
|
+
# @param name [String]
|
29
|
+
# @param description [String]
|
30
|
+
# @param external_id [String]
|
31
|
+
# @param active [Boolean]
|
32
|
+
# @param agent_code [String]
|
33
|
+
# @param agent_attributes [Array<Paid::AgentAttribute>]
|
34
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
35
|
+
# @return [Paid::AgentUpdate]
|
36
|
+
def initialize(name: OMIT, description: OMIT, external_id: OMIT, active: OMIT, agent_code: OMIT, agent_attributes: OMIT, additional_properties: nil)
|
37
|
+
@name = name if name != OMIT
|
38
|
+
@description = description if description != OMIT
|
39
|
+
@external_id = external_id if external_id != OMIT
|
40
|
+
@active = active if active != OMIT
|
41
|
+
@agent_code = agent_code if agent_code != OMIT
|
42
|
+
@agent_attributes = agent_attributes if agent_attributes != OMIT
|
43
|
+
@additional_properties = additional_properties
|
44
|
+
@_field_set = { "name": name, "description": description, "externalId": external_id, "active": active, "agentCode": agent_code, "agentAttributes": agent_attributes }.reject do | _k, v |
|
45
|
+
v == OMIT
|
46
|
+
end
|
47
|
+
end
|
48
|
+
# Deserialize a JSON object to an instance of AgentUpdate
|
49
|
+
#
|
50
|
+
# @param json_object [String]
|
51
|
+
# @return [Paid::AgentUpdate]
|
52
|
+
def self.from_json(json_object:)
|
53
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
54
|
+
parsed_json = JSON.parse(json_object)
|
55
|
+
name = parsed_json["name"]
|
56
|
+
description = parsed_json["description"]
|
57
|
+
external_id = parsed_json["externalId"]
|
58
|
+
active = parsed_json["active"]
|
59
|
+
agent_code = parsed_json["agentCode"]
|
60
|
+
agent_attributes = parsed_json["agentAttributes"]&.map do | item |
|
61
|
+
item = item.to_json
|
62
|
+
Paid::AgentAttribute.from_json(json_object: item)
|
63
|
+
end
|
64
|
+
new(
|
65
|
+
name: name,
|
66
|
+
description: description,
|
67
|
+
external_id: external_id,
|
68
|
+
active: active,
|
69
|
+
agent_code: agent_code,
|
70
|
+
agent_attributes: agent_attributes,
|
71
|
+
additional_properties: struct
|
72
|
+
)
|
73
|
+
end
|
74
|
+
# Serialize an instance of AgentUpdate to a JSON object
|
75
|
+
#
|
76
|
+
# @return [String]
|
77
|
+
def to_json
|
78
|
+
@_field_set&.to_json
|
79
|
+
end
|
80
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
81
|
+
# hash and check each fields type against the current object's property
|
82
|
+
# definitions.
|
83
|
+
#
|
84
|
+
# @param obj [Object]
|
85
|
+
# @return [Void]
|
86
|
+
def self.validate_raw(obj:)
|
87
|
+
obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
88
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
89
|
+
obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
|
90
|
+
obj.active&.is_a?(Boolean) != false || raise("Passed value for field obj.active is not the expected type, validation failed.")
|
91
|
+
obj.agent_code&.is_a?(String) != false || raise("Passed value for field obj.agent_code is not the expected type, validation failed.")
|
92
|
+
obj.agent_attributes&.is_a?(Array) != false || raise("Passed value for field obj.agent_attributes is not the expected type, validation failed.")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "ostruct"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Paid
|
6
|
+
# An API error response from the Paid API
|
7
|
+
class ApiError
|
8
|
+
# @return [String] A human-readable message providing more details about the error.
|
9
|
+
attr_reader :message
|
10
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
11
|
+
attr_reader :additional_properties
|
12
|
+
# @return [Object]
|
13
|
+
attr_reader :_field_set
|
14
|
+
protected :_field_set
|
15
|
+
|
16
|
+
OMIT = Object.new
|
17
|
+
|
18
|
+
# @param message [String] A human-readable message providing more details about the error.
|
19
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
20
|
+
# @return [Paid::ApiError]
|
21
|
+
def initialize(message: OMIT, additional_properties: nil)
|
22
|
+
@message = message if message != OMIT
|
23
|
+
@additional_properties = additional_properties
|
24
|
+
@_field_set = { "message": message }.reject do | _k, v |
|
25
|
+
v == OMIT
|
26
|
+
end
|
27
|
+
end
|
28
|
+
# Deserialize a JSON object to an instance of ApiError
|
29
|
+
#
|
30
|
+
# @param json_object [String]
|
31
|
+
# @return [Paid::ApiError]
|
32
|
+
def self.from_json(json_object:)
|
33
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
34
|
+
parsed_json = JSON.parse(json_object)
|
35
|
+
message = parsed_json["message"]
|
36
|
+
new(message: message, additional_properties: struct)
|
37
|
+
end
|
38
|
+
# Serialize an instance of ApiError to a JSON object
|
39
|
+
#
|
40
|
+
# @return [String]
|
41
|
+
def to_json
|
42
|
+
@_field_set&.to_json
|
43
|
+
end
|
44
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
45
|
+
# hash and check each fields type against the current object's property
|
46
|
+
# definitions.
|
47
|
+
#
|
48
|
+
# @param obj [Object]
|
49
|
+
# @return [Void]
|
50
|
+
def self.validate_raw(obj:)
|
51
|
+
obj.message&.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "salutation"
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Paid
|
7
|
+
class Contact
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :id
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :external_id
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :organization_id
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :customer_id
|
16
|
+
# @return [String]
|
17
|
+
attr_reader :customer_external_id
|
18
|
+
# @return [Paid::Salutation]
|
19
|
+
attr_reader :salutation
|
20
|
+
# @return [String]
|
21
|
+
attr_reader :first_name
|
22
|
+
# @return [String]
|
23
|
+
attr_reader :last_name
|
24
|
+
# @return [String]
|
25
|
+
attr_reader :email
|
26
|
+
# @return [String]
|
27
|
+
attr_reader :phone
|
28
|
+
# @return [String]
|
29
|
+
attr_reader :billing_street
|
30
|
+
# @return [String]
|
31
|
+
attr_reader :billing_city
|
32
|
+
# @return [String]
|
33
|
+
attr_reader :billing_state_province
|
34
|
+
# @return [String]
|
35
|
+
attr_reader :billing_country
|
36
|
+
# @return [String]
|
37
|
+
attr_reader :billing_postal_code
|
38
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
39
|
+
attr_reader :additional_properties
|
40
|
+
# @return [Object]
|
41
|
+
attr_reader :_field_set
|
42
|
+
protected :_field_set
|
43
|
+
|
44
|
+
OMIT = Object.new
|
45
|
+
|
46
|
+
# @param id [String]
|
47
|
+
# @param external_id [String]
|
48
|
+
# @param organization_id [String]
|
49
|
+
# @param customer_id [String]
|
50
|
+
# @param customer_external_id [String]
|
51
|
+
# @param salutation [Paid::Salutation]
|
52
|
+
# @param first_name [String]
|
53
|
+
# @param last_name [String]
|
54
|
+
# @param email [String]
|
55
|
+
# @param phone [String]
|
56
|
+
# @param billing_street [String]
|
57
|
+
# @param billing_city [String]
|
58
|
+
# @param billing_state_province [String]
|
59
|
+
# @param billing_country [String]
|
60
|
+
# @param billing_postal_code [String]
|
61
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
62
|
+
# @return [Paid::Contact]
|
63
|
+
def initialize(id: OMIT, external_id: OMIT, organization_id: OMIT, customer_id: OMIT, customer_external_id: OMIT, salutation: OMIT, first_name: OMIT, last_name: OMIT, email: OMIT, phone: OMIT, billing_street: OMIT, billing_city: OMIT, billing_state_province: OMIT, billing_country: OMIT, billing_postal_code: OMIT, additional_properties: nil)
|
64
|
+
@id = id if id != OMIT
|
65
|
+
@external_id = external_id if external_id != OMIT
|
66
|
+
@organization_id = organization_id if organization_id != OMIT
|
67
|
+
@customer_id = customer_id if customer_id != OMIT
|
68
|
+
@customer_external_id = customer_external_id if customer_external_id != OMIT
|
69
|
+
@salutation = salutation if salutation != OMIT
|
70
|
+
@first_name = first_name if first_name != OMIT
|
71
|
+
@last_name = last_name if last_name != OMIT
|
72
|
+
@email = email if email != OMIT
|
73
|
+
@phone = phone if phone != OMIT
|
74
|
+
@billing_street = billing_street if billing_street != OMIT
|
75
|
+
@billing_city = billing_city if billing_city != OMIT
|
76
|
+
@billing_state_province = billing_state_province if billing_state_province != OMIT
|
77
|
+
@billing_country = billing_country if billing_country != OMIT
|
78
|
+
@billing_postal_code = billing_postal_code if billing_postal_code != OMIT
|
79
|
+
@additional_properties = additional_properties
|
80
|
+
@_field_set = { "id": id, "externalId": external_id, "organizationId": organization_id, "customerId": customer_id, "customerExternalId": customer_external_id, "salutation": salutation, "firstName": first_name, "lastName": last_name, "email": email, "phone": phone, "billingStreet": billing_street, "billingCity": billing_city, "billingStateProvince": billing_state_province, "billingCountry": billing_country, "billingPostalCode": billing_postal_code }.reject do | _k, v |
|
81
|
+
v == OMIT
|
82
|
+
end
|
83
|
+
end
|
84
|
+
# Deserialize a JSON object to an instance of Contact
|
85
|
+
#
|
86
|
+
# @param json_object [String]
|
87
|
+
# @return [Paid::Contact]
|
88
|
+
def self.from_json(json_object:)
|
89
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
90
|
+
parsed_json = JSON.parse(json_object)
|
91
|
+
id = parsed_json["id"]
|
92
|
+
external_id = parsed_json["externalId"]
|
93
|
+
organization_id = parsed_json["organizationId"]
|
94
|
+
customer_id = parsed_json["customerId"]
|
95
|
+
customer_external_id = parsed_json["customerExternalId"]
|
96
|
+
salutation = parsed_json["salutation"]
|
97
|
+
first_name = parsed_json["firstName"]
|
98
|
+
last_name = parsed_json["lastName"]
|
99
|
+
email = parsed_json["email"]
|
100
|
+
phone = parsed_json["phone"]
|
101
|
+
billing_street = parsed_json["billingStreet"]
|
102
|
+
billing_city = parsed_json["billingCity"]
|
103
|
+
billing_state_province = parsed_json["billingStateProvince"]
|
104
|
+
billing_country = parsed_json["billingCountry"]
|
105
|
+
billing_postal_code = parsed_json["billingPostalCode"]
|
106
|
+
new(
|
107
|
+
id: id,
|
108
|
+
external_id: external_id,
|
109
|
+
organization_id: organization_id,
|
110
|
+
customer_id: customer_id,
|
111
|
+
customer_external_id: customer_external_id,
|
112
|
+
salutation: salutation,
|
113
|
+
first_name: first_name,
|
114
|
+
last_name: last_name,
|
115
|
+
email: email,
|
116
|
+
phone: phone,
|
117
|
+
billing_street: billing_street,
|
118
|
+
billing_city: billing_city,
|
119
|
+
billing_state_province: billing_state_province,
|
120
|
+
billing_country: billing_country,
|
121
|
+
billing_postal_code: billing_postal_code,
|
122
|
+
additional_properties: struct
|
123
|
+
)
|
124
|
+
end
|
125
|
+
# Serialize an instance of Contact to a JSON object
|
126
|
+
#
|
127
|
+
# @return [String]
|
128
|
+
def to_json
|
129
|
+
@_field_set&.to_json
|
130
|
+
end
|
131
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
132
|
+
# hash and check each fields type against the current object's property
|
133
|
+
# definitions.
|
134
|
+
#
|
135
|
+
# @param obj [Object]
|
136
|
+
# @return [Void]
|
137
|
+
def self.validate_raw(obj:)
|
138
|
+
obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
139
|
+
obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
|
140
|
+
obj.organization_id&.is_a?(String) != false || raise("Passed value for field obj.organization_id is not the expected type, validation failed.")
|
141
|
+
obj.customer_id&.is_a?(String) != false || raise("Passed value for field obj.customer_id is not the expected type, validation failed.")
|
142
|
+
obj.customer_external_id&.is_a?(String) != false || raise("Passed value for field obj.customer_external_id is not the expected type, validation failed.")
|
143
|
+
obj.salutation&.is_a?(Paid::Salutation) != false || raise("Passed value for field obj.salutation is not the expected type, validation failed.")
|
144
|
+
obj.first_name&.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.")
|
145
|
+
obj.last_name&.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.")
|
146
|
+
obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
|
147
|
+
obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.")
|
148
|
+
obj.billing_street&.is_a?(String) != false || raise("Passed value for field obj.billing_street is not the expected type, validation failed.")
|
149
|
+
obj.billing_city&.is_a?(String) != false || raise("Passed value for field obj.billing_city is not the expected type, validation failed.")
|
150
|
+
obj.billing_state_province&.is_a?(String) != false || raise("Passed value for field obj.billing_state_province is not the expected type, validation failed.")
|
151
|
+
obj.billing_country&.is_a?(String) != false || raise("Passed value for field obj.billing_country is not the expected type, validation failed.")
|
152
|
+
obj.billing_postal_code&.is_a?(String) != false || raise("Passed value for field obj.billing_postal_code is not the expected type, validation failed.")
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|