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,142 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "tax_exempt_status"
|
3
|
+
require_relative "creation_source"
|
4
|
+
require_relative "creation_state"
|
5
|
+
require_relative "address"
|
6
|
+
require "ostruct"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
module Paid
|
10
|
+
class Customer
|
11
|
+
# @return [String]
|
12
|
+
attr_reader :id
|
13
|
+
# @return [String]
|
14
|
+
attr_reader :organization_id
|
15
|
+
# @return [String]
|
16
|
+
attr_reader :name
|
17
|
+
# @return [String]
|
18
|
+
attr_reader :external_id
|
19
|
+
# @return [String]
|
20
|
+
attr_reader :phone
|
21
|
+
# @return [Float]
|
22
|
+
attr_reader :employee_count
|
23
|
+
# @return [Float]
|
24
|
+
attr_reader :annual_revenue
|
25
|
+
# @return [Paid::TaxExemptStatus]
|
26
|
+
attr_reader :tax_exempt_status
|
27
|
+
# @return [Paid::CreationSource]
|
28
|
+
attr_reader :creation_source
|
29
|
+
# @return [Paid::CreationState]
|
30
|
+
attr_reader :creation_state
|
31
|
+
# @return [String]
|
32
|
+
attr_reader :website
|
33
|
+
# @return [Paid::Address]
|
34
|
+
attr_reader :billing_address
|
35
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
36
|
+
attr_reader :additional_properties
|
37
|
+
# @return [Object]
|
38
|
+
attr_reader :_field_set
|
39
|
+
protected :_field_set
|
40
|
+
|
41
|
+
OMIT = Object.new
|
42
|
+
|
43
|
+
# @param id [String]
|
44
|
+
# @param organization_id [String]
|
45
|
+
# @param name [String]
|
46
|
+
# @param external_id [String]
|
47
|
+
# @param phone [String]
|
48
|
+
# @param employee_count [Float]
|
49
|
+
# @param annual_revenue [Float]
|
50
|
+
# @param tax_exempt_status [Paid::TaxExemptStatus]
|
51
|
+
# @param creation_source [Paid::CreationSource]
|
52
|
+
# @param creation_state [Paid::CreationState]
|
53
|
+
# @param website [String]
|
54
|
+
# @param billing_address [Paid::Address]
|
55
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
56
|
+
# @return [Paid::Customer]
|
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)
|
58
|
+
@id = id
|
59
|
+
@organization_id = organization_id
|
60
|
+
@name = name
|
61
|
+
@external_id = external_id if external_id != OMIT
|
62
|
+
@phone = phone if phone != OMIT
|
63
|
+
@employee_count = employee_count if employee_count != OMIT
|
64
|
+
@annual_revenue = annual_revenue if annual_revenue != OMIT
|
65
|
+
@tax_exempt_status = tax_exempt_status if tax_exempt_status != OMIT
|
66
|
+
@creation_source = creation_source if creation_source != OMIT
|
67
|
+
@creation_state = creation_state if creation_state != OMIT
|
68
|
+
@website = website if website != OMIT
|
69
|
+
@billing_address = billing_address if billing_address != OMIT
|
70
|
+
@additional_properties = additional_properties
|
71
|
+
@_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 |
|
72
|
+
v == OMIT
|
73
|
+
end
|
74
|
+
end
|
75
|
+
# Deserialize a JSON object to an instance of Customer
|
76
|
+
#
|
77
|
+
# @param json_object [String]
|
78
|
+
# @return [Paid::Customer]
|
79
|
+
def self.from_json(json_object:)
|
80
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
81
|
+
parsed_json = JSON.parse(json_object)
|
82
|
+
id = parsed_json["id"]
|
83
|
+
organization_id = parsed_json["organizationId"]
|
84
|
+
name = parsed_json["name"]
|
85
|
+
external_id = parsed_json["externalId"]
|
86
|
+
phone = parsed_json["phone"]
|
87
|
+
employee_count = parsed_json["employeeCount"]
|
88
|
+
annual_revenue = parsed_json["annualRevenue"]
|
89
|
+
tax_exempt_status = parsed_json["taxExemptStatus"]
|
90
|
+
creation_source = parsed_json["creationSource"]
|
91
|
+
creation_state = parsed_json["creationState"]
|
92
|
+
website = parsed_json["website"]
|
93
|
+
unless parsed_json["billingAddress"].nil?
|
94
|
+
billing_address = parsed_json["billingAddress"].to_json
|
95
|
+
billing_address = Paid::Address.from_json(json_object: billing_address)
|
96
|
+
else
|
97
|
+
billing_address = nil
|
98
|
+
end
|
99
|
+
new(
|
100
|
+
id: id,
|
101
|
+
organization_id: organization_id,
|
102
|
+
name: name,
|
103
|
+
external_id: external_id,
|
104
|
+
phone: phone,
|
105
|
+
employee_count: employee_count,
|
106
|
+
annual_revenue: annual_revenue,
|
107
|
+
tax_exempt_status: tax_exempt_status,
|
108
|
+
creation_source: creation_source,
|
109
|
+
creation_state: creation_state,
|
110
|
+
website: website,
|
111
|
+
billing_address: billing_address,
|
112
|
+
additional_properties: struct
|
113
|
+
)
|
114
|
+
end
|
115
|
+
# Serialize an instance of Customer to a JSON object
|
116
|
+
#
|
117
|
+
# @return [String]
|
118
|
+
def to_json
|
119
|
+
@_field_set&.to_json
|
120
|
+
end
|
121
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
122
|
+
# hash and check each fields type against the current object's property
|
123
|
+
# definitions.
|
124
|
+
#
|
125
|
+
# @param obj [Object]
|
126
|
+
# @return [Void]
|
127
|
+
def self.validate_raw(obj:)
|
128
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
129
|
+
obj.organization_id.is_a?(String) != false || raise("Passed value for field obj.organization_id is not the expected type, validation failed.")
|
130
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
131
|
+
obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
|
132
|
+
obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.")
|
133
|
+
obj.employee_count&.is_a?(Float) != false || raise("Passed value for field obj.employee_count is not the expected type, validation failed.")
|
134
|
+
obj.annual_revenue&.is_a?(Float) != false || raise("Passed value for field obj.annual_revenue is not the expected type, validation failed.")
|
135
|
+
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.")
|
136
|
+
obj.creation_source&.is_a?(Paid::CreationSource) != false || raise("Passed value for field obj.creation_source is not the expected type, validation failed.")
|
137
|
+
obj.creation_state&.is_a?(Paid::CreationState) != false || raise("Passed value for field obj.creation_state is not the expected type, validation failed.")
|
138
|
+
obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.")
|
139
|
+
obj.billing_address.nil? || Paid::Address.validate_raw(obj: obj.billing_address)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "tax_exempt_status"
|
3
|
+
require_relative "creation_source"
|
4
|
+
require_relative "address"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module Paid
|
9
|
+
class CustomerUpdate
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :name
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :external_id
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :phone
|
16
|
+
# @return [Float]
|
17
|
+
attr_reader :employee_count
|
18
|
+
# @return [Float]
|
19
|
+
attr_reader :annual_revenue
|
20
|
+
# @return [Paid::TaxExemptStatus]
|
21
|
+
attr_reader :tax_exempt_status
|
22
|
+
# @return [Paid::CreationSource]
|
23
|
+
attr_reader :creation_source
|
24
|
+
# @return [String]
|
25
|
+
attr_reader :website
|
26
|
+
# @return [Paid::Address]
|
27
|
+
attr_reader :billing_address
|
28
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
29
|
+
attr_reader :additional_properties
|
30
|
+
# @return [Object]
|
31
|
+
attr_reader :_field_set
|
32
|
+
protected :_field_set
|
33
|
+
|
34
|
+
OMIT = Object.new
|
35
|
+
|
36
|
+
# @param name [String]
|
37
|
+
# @param external_id [String]
|
38
|
+
# @param phone [String]
|
39
|
+
# @param employee_count [Float]
|
40
|
+
# @param annual_revenue [Float]
|
41
|
+
# @param tax_exempt_status [Paid::TaxExemptStatus]
|
42
|
+
# @param creation_source [Paid::CreationSource]
|
43
|
+
# @param website [String]
|
44
|
+
# @param billing_address [Paid::Address]
|
45
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
46
|
+
# @return [Paid::CustomerUpdate]
|
47
|
+
def initialize(name: OMIT, external_id: OMIT, phone: OMIT, employee_count: OMIT, annual_revenue: OMIT, tax_exempt_status: OMIT, creation_source: OMIT, website: OMIT, billing_address: OMIT, additional_properties: nil)
|
48
|
+
@name = name if name != OMIT
|
49
|
+
@external_id = external_id if external_id != OMIT
|
50
|
+
@phone = phone if phone != OMIT
|
51
|
+
@employee_count = employee_count if employee_count != OMIT
|
52
|
+
@annual_revenue = annual_revenue if annual_revenue != OMIT
|
53
|
+
@tax_exempt_status = tax_exempt_status if tax_exempt_status != OMIT
|
54
|
+
@creation_source = creation_source if creation_source != OMIT
|
55
|
+
@website = website if website != OMIT
|
56
|
+
@billing_address = billing_address if billing_address != OMIT
|
57
|
+
@additional_properties = additional_properties
|
58
|
+
@_field_set = { "name": name, "externalId": external_id, "phone": phone, "employeeCount": employee_count, "annualRevenue": annual_revenue, "taxExemptStatus": tax_exempt_status, "creationSource": creation_source, "website": website, "billingAddress": billing_address }.reject do | _k, v |
|
59
|
+
v == OMIT
|
60
|
+
end
|
61
|
+
end
|
62
|
+
# Deserialize a JSON object to an instance of CustomerUpdate
|
63
|
+
#
|
64
|
+
# @param json_object [String]
|
65
|
+
# @return [Paid::CustomerUpdate]
|
66
|
+
def self.from_json(json_object:)
|
67
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
68
|
+
parsed_json = JSON.parse(json_object)
|
69
|
+
name = parsed_json["name"]
|
70
|
+
external_id = parsed_json["externalId"]
|
71
|
+
phone = parsed_json["phone"]
|
72
|
+
employee_count = parsed_json["employeeCount"]
|
73
|
+
annual_revenue = parsed_json["annualRevenue"]
|
74
|
+
tax_exempt_status = parsed_json["taxExemptStatus"]
|
75
|
+
creation_source = parsed_json["creationSource"]
|
76
|
+
website = parsed_json["website"]
|
77
|
+
unless parsed_json["billingAddress"].nil?
|
78
|
+
billing_address = parsed_json["billingAddress"].to_json
|
79
|
+
billing_address = Paid::Address.from_json(json_object: billing_address)
|
80
|
+
else
|
81
|
+
billing_address = nil
|
82
|
+
end
|
83
|
+
new(
|
84
|
+
name: name,
|
85
|
+
external_id: external_id,
|
86
|
+
phone: phone,
|
87
|
+
employee_count: employee_count,
|
88
|
+
annual_revenue: annual_revenue,
|
89
|
+
tax_exempt_status: tax_exempt_status,
|
90
|
+
creation_source: creation_source,
|
91
|
+
website: website,
|
92
|
+
billing_address: billing_address,
|
93
|
+
additional_properties: struct
|
94
|
+
)
|
95
|
+
end
|
96
|
+
# Serialize an instance of CustomerUpdate to a JSON object
|
97
|
+
#
|
98
|
+
# @return [String]
|
99
|
+
def to_json
|
100
|
+
@_field_set&.to_json
|
101
|
+
end
|
102
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
103
|
+
# hash and check each fields type against the current object's property
|
104
|
+
# definitions.
|
105
|
+
#
|
106
|
+
# @param obj [Object]
|
107
|
+
# @return [Void]
|
108
|
+
def self.validate_raw(obj:)
|
109
|
+
obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
110
|
+
obj.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
|
111
|
+
obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.")
|
112
|
+
obj.employee_count&.is_a?(Float) != false || raise("Passed value for field obj.employee_count is not the expected type, validation failed.")
|
113
|
+
obj.annual_revenue&.is_a?(Float) != false || raise("Passed value for field obj.annual_revenue is not the expected type, validation failed.")
|
114
|
+
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.")
|
115
|
+
obj.creation_source&.is_a?(Paid::CreationSource) != false || raise("Passed value for field obj.creation_source is not the expected type, validation failed.")
|
116
|
+
obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.")
|
117
|
+
obj.billing_address.nil? || Paid::Address.validate_raw(obj: obj.billing_address)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "api_error"
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Paid
|
7
|
+
# An error response from the Paid API
|
8
|
+
class Error
|
9
|
+
# @return [Paid::ApiError]
|
10
|
+
attr_reader :error
|
11
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
12
|
+
attr_reader :additional_properties
|
13
|
+
# @return [Object]
|
14
|
+
attr_reader :_field_set
|
15
|
+
protected :_field_set
|
16
|
+
|
17
|
+
OMIT = Object.new
|
18
|
+
|
19
|
+
# @param error [Paid::ApiError]
|
20
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
21
|
+
# @return [Paid::Error]
|
22
|
+
def initialize(error:, additional_properties: nil)
|
23
|
+
@error = error
|
24
|
+
@additional_properties = additional_properties
|
25
|
+
@_field_set = { "error": error }
|
26
|
+
end
|
27
|
+
# Deserialize a JSON object to an instance of Error
|
28
|
+
#
|
29
|
+
# @param json_object [String]
|
30
|
+
# @return [Paid::Error]
|
31
|
+
def self.from_json(json_object:)
|
32
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
33
|
+
parsed_json = JSON.parse(json_object)
|
34
|
+
unless parsed_json["error"].nil?
|
35
|
+
error = parsed_json["error"].to_json
|
36
|
+
error = Paid::ApiError.from_json(json_object: error)
|
37
|
+
else
|
38
|
+
error = nil
|
39
|
+
end
|
40
|
+
new(error: error, additional_properties: struct)
|
41
|
+
end
|
42
|
+
# Serialize an instance of Error to a JSON object
|
43
|
+
#
|
44
|
+
# @return [String]
|
45
|
+
def to_json
|
46
|
+
@_field_set&.to_json
|
47
|
+
end
|
48
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
49
|
+
# hash and check each fields type against the current object's property
|
50
|
+
# definitions.
|
51
|
+
#
|
52
|
+
# @param obj [Object]
|
53
|
+
# @return [Void]
|
54
|
+
def self.validate_raw(obj:)
|
55
|
+
Paid::ApiError.validate_raw(obj: obj.error)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "creation_state"
|
3
|
+
require_relative "order_line"
|
4
|
+
require_relative "customer"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module Paid
|
9
|
+
class Order
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :id
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :name
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :description
|
16
|
+
# @return [String]
|
17
|
+
attr_reader :customer_id
|
18
|
+
# @return [String]
|
19
|
+
attr_reader :organization_id
|
20
|
+
# @return [String]
|
21
|
+
attr_reader :start_date
|
22
|
+
# @return [String]
|
23
|
+
attr_reader :end_date
|
24
|
+
# @return [Float]
|
25
|
+
attr_reader :total_amount
|
26
|
+
# @return [Float]
|
27
|
+
attr_reader :estimated_tax
|
28
|
+
# @return [Float]
|
29
|
+
attr_reader :billed_amount_no_tax
|
30
|
+
# @return [Float]
|
31
|
+
attr_reader :billed_tax
|
32
|
+
# @return [Float]
|
33
|
+
attr_reader :total_billed_amount
|
34
|
+
# @return [Float]
|
35
|
+
attr_reader :pending_billing_amount
|
36
|
+
# @return [Paid::CreationState]
|
37
|
+
attr_reader :creation_state
|
38
|
+
# @return [Array<Paid::OrderLine>]
|
39
|
+
attr_reader :order_lines
|
40
|
+
# @return [Paid::Customer]
|
41
|
+
attr_reader :customer
|
42
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
43
|
+
attr_reader :additional_properties
|
44
|
+
# @return [Object]
|
45
|
+
attr_reader :_field_set
|
46
|
+
protected :_field_set
|
47
|
+
|
48
|
+
OMIT = Object.new
|
49
|
+
|
50
|
+
# @param id [String]
|
51
|
+
# @param name [String]
|
52
|
+
# @param description [String]
|
53
|
+
# @param customer_id [String]
|
54
|
+
# @param organization_id [String]
|
55
|
+
# @param start_date [String]
|
56
|
+
# @param end_date [String]
|
57
|
+
# @param total_amount [Float]
|
58
|
+
# @param estimated_tax [Float]
|
59
|
+
# @param billed_amount_no_tax [Float]
|
60
|
+
# @param billed_tax [Float]
|
61
|
+
# @param total_billed_amount [Float]
|
62
|
+
# @param pending_billing_amount [Float]
|
63
|
+
# @param creation_state [Paid::CreationState]
|
64
|
+
# @param order_lines [Array<Paid::OrderLine>]
|
65
|
+
# @param customer [Paid::Customer]
|
66
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
67
|
+
# @return [Paid::Order]
|
68
|
+
def initialize(id: OMIT, name: OMIT, description: OMIT, customer_id: OMIT, organization_id: OMIT, start_date: OMIT, end_date: OMIT, total_amount: OMIT, estimated_tax: OMIT, billed_amount_no_tax: OMIT, billed_tax: OMIT, total_billed_amount: OMIT, pending_billing_amount: OMIT, creation_state: OMIT, order_lines: OMIT, customer: OMIT, additional_properties: nil)
|
69
|
+
@id = id if id != OMIT
|
70
|
+
@name = name if name != OMIT
|
71
|
+
@description = description if description != OMIT
|
72
|
+
@customer_id = customer_id if customer_id != OMIT
|
73
|
+
@organization_id = organization_id if organization_id != OMIT
|
74
|
+
@start_date = start_date if start_date != OMIT
|
75
|
+
@end_date = end_date if end_date != OMIT
|
76
|
+
@total_amount = total_amount if total_amount != OMIT
|
77
|
+
@estimated_tax = estimated_tax if estimated_tax != OMIT
|
78
|
+
@billed_amount_no_tax = billed_amount_no_tax if billed_amount_no_tax != OMIT
|
79
|
+
@billed_tax = billed_tax if billed_tax != OMIT
|
80
|
+
@total_billed_amount = total_billed_amount if total_billed_amount != OMIT
|
81
|
+
@pending_billing_amount = pending_billing_amount if pending_billing_amount != OMIT
|
82
|
+
@creation_state = creation_state if creation_state != OMIT
|
83
|
+
@order_lines = order_lines if order_lines != OMIT
|
84
|
+
@customer = customer if customer != OMIT
|
85
|
+
@additional_properties = additional_properties
|
86
|
+
@_field_set = { "id": id, "name": name, "description": description, "customerId": customer_id, "organizationId": organization_id, "startDate": start_date, "endDate": end_date, "totalAmount": total_amount, "estimatedTax": estimated_tax, "billedAmountNoTax": billed_amount_no_tax, "billedTax": billed_tax, "totalBilledAmount": total_billed_amount, "pendingBillingAmount": pending_billing_amount, "creationState": creation_state, "orderLines": order_lines, "customer": customer }.reject do | _k, v |
|
87
|
+
v == OMIT
|
88
|
+
end
|
89
|
+
end
|
90
|
+
# Deserialize a JSON object to an instance of Order
|
91
|
+
#
|
92
|
+
# @param json_object [String]
|
93
|
+
# @return [Paid::Order]
|
94
|
+
def self.from_json(json_object:)
|
95
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
96
|
+
parsed_json = JSON.parse(json_object)
|
97
|
+
id = parsed_json["id"]
|
98
|
+
name = parsed_json["name"]
|
99
|
+
description = parsed_json["description"]
|
100
|
+
customer_id = parsed_json["customerId"]
|
101
|
+
organization_id = parsed_json["organizationId"]
|
102
|
+
start_date = parsed_json["startDate"]
|
103
|
+
end_date = parsed_json["endDate"]
|
104
|
+
total_amount = parsed_json["totalAmount"]
|
105
|
+
estimated_tax = parsed_json["estimatedTax"]
|
106
|
+
billed_amount_no_tax = parsed_json["billedAmountNoTax"]
|
107
|
+
billed_tax = parsed_json["billedTax"]
|
108
|
+
total_billed_amount = parsed_json["totalBilledAmount"]
|
109
|
+
pending_billing_amount = parsed_json["pendingBillingAmount"]
|
110
|
+
creation_state = parsed_json["creationState"]
|
111
|
+
order_lines = parsed_json["orderLines"]&.map do | item |
|
112
|
+
item = item.to_json
|
113
|
+
Paid::OrderLine.from_json(json_object: item)
|
114
|
+
end
|
115
|
+
unless parsed_json["customer"].nil?
|
116
|
+
customer = parsed_json["customer"].to_json
|
117
|
+
customer = Paid::Customer.from_json(json_object: customer)
|
118
|
+
else
|
119
|
+
customer = nil
|
120
|
+
end
|
121
|
+
new(
|
122
|
+
id: id,
|
123
|
+
name: name,
|
124
|
+
description: description,
|
125
|
+
customer_id: customer_id,
|
126
|
+
organization_id: organization_id,
|
127
|
+
start_date: start_date,
|
128
|
+
end_date: end_date,
|
129
|
+
total_amount: total_amount,
|
130
|
+
estimated_tax: estimated_tax,
|
131
|
+
billed_amount_no_tax: billed_amount_no_tax,
|
132
|
+
billed_tax: billed_tax,
|
133
|
+
total_billed_amount: total_billed_amount,
|
134
|
+
pending_billing_amount: pending_billing_amount,
|
135
|
+
creation_state: creation_state,
|
136
|
+
order_lines: order_lines,
|
137
|
+
customer: customer,
|
138
|
+
additional_properties: struct
|
139
|
+
)
|
140
|
+
end
|
141
|
+
# Serialize an instance of Order to a JSON object
|
142
|
+
#
|
143
|
+
# @return [String]
|
144
|
+
def to_json
|
145
|
+
@_field_set&.to_json
|
146
|
+
end
|
147
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
148
|
+
# hash and check each fields type against the current object's property
|
149
|
+
# definitions.
|
150
|
+
#
|
151
|
+
# @param obj [Object]
|
152
|
+
# @return [Void]
|
153
|
+
def self.validate_raw(obj:)
|
154
|
+
obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
155
|
+
obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
156
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
157
|
+
obj.customer_id&.is_a?(String) != false || raise("Passed value for field obj.customer_id is not the expected type, validation failed.")
|
158
|
+
obj.organization_id&.is_a?(String) != false || raise("Passed value for field obj.organization_id is not the expected type, validation failed.")
|
159
|
+
obj.start_date&.is_a?(String) != false || raise("Passed value for field obj.start_date is not the expected type, validation failed.")
|
160
|
+
obj.end_date&.is_a?(String) != false || raise("Passed value for field obj.end_date is not the expected type, validation failed.")
|
161
|
+
obj.total_amount&.is_a?(Float) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.")
|
162
|
+
obj.estimated_tax&.is_a?(Float) != false || raise("Passed value for field obj.estimated_tax is not the expected type, validation failed.")
|
163
|
+
obj.billed_amount_no_tax&.is_a?(Float) != false || raise("Passed value for field obj.billed_amount_no_tax is not the expected type, validation failed.")
|
164
|
+
obj.billed_tax&.is_a?(Float) != false || raise("Passed value for field obj.billed_tax is not the expected type, validation failed.")
|
165
|
+
obj.total_billed_amount&.is_a?(Float) != false || raise("Passed value for field obj.total_billed_amount is not the expected type, validation failed.")
|
166
|
+
obj.pending_billing_amount&.is_a?(Float) != false || raise("Passed value for field obj.pending_billing_amount is not the expected type, validation failed.")
|
167
|
+
obj.creation_state&.is_a?(Paid::CreationState) != false || raise("Passed value for field obj.creation_state is not the expected type, validation failed.")
|
168
|
+
obj.order_lines&.is_a?(Array) != false || raise("Passed value for field obj.order_lines is not the expected type, validation failed.")
|
169
|
+
obj.customer.nil? || Paid::Customer.validate_raw(obj: obj.customer)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "creation_state"
|
3
|
+
require_relative "agent"
|
4
|
+
require_relative "order_line_attribute"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module Paid
|
9
|
+
class OrderLine
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :id
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :order_id
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :agent_id
|
16
|
+
# @return [String]
|
17
|
+
attr_reader :name
|
18
|
+
# @return [String]
|
19
|
+
attr_reader :description
|
20
|
+
# @return [String]
|
21
|
+
attr_reader :start_date
|
22
|
+
# @return [String]
|
23
|
+
attr_reader :end_date
|
24
|
+
# @return [Float]
|
25
|
+
attr_reader :total_amount
|
26
|
+
# @return [Float]
|
27
|
+
attr_reader :billed_amount_without_tax
|
28
|
+
# @return [Float]
|
29
|
+
attr_reader :billed_tax
|
30
|
+
# @return [Float]
|
31
|
+
attr_reader :total_billed_amount
|
32
|
+
# @return [Paid::CreationState]
|
33
|
+
attr_reader :creation_state
|
34
|
+
# @return [Paid::Agent]
|
35
|
+
attr_reader :agent
|
36
|
+
# @return [Array<Paid::OrderLineAttribute>]
|
37
|
+
attr_reader :order_line_attributes
|
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 order_id [String]
|
48
|
+
# @param agent_id [String]
|
49
|
+
# @param name [String]
|
50
|
+
# @param description [String]
|
51
|
+
# @param start_date [String]
|
52
|
+
# @param end_date [String]
|
53
|
+
# @param total_amount [Float]
|
54
|
+
# @param billed_amount_without_tax [Float]
|
55
|
+
# @param billed_tax [Float]
|
56
|
+
# @param total_billed_amount [Float]
|
57
|
+
# @param creation_state [Paid::CreationState]
|
58
|
+
# @param agent [Paid::Agent]
|
59
|
+
# @param order_line_attributes [Array<Paid::OrderLineAttribute>]
|
60
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
61
|
+
# @return [Paid::OrderLine]
|
62
|
+
def initialize(id: OMIT, order_id: OMIT, agent_id: OMIT, name: OMIT, description: OMIT, start_date: OMIT, end_date: OMIT, total_amount: OMIT, billed_amount_without_tax: OMIT, billed_tax: OMIT, total_billed_amount: OMIT, creation_state: OMIT, agent: OMIT, order_line_attributes: OMIT, additional_properties: nil)
|
63
|
+
@id = id if id != OMIT
|
64
|
+
@order_id = order_id if order_id != OMIT
|
65
|
+
@agent_id = agent_id if agent_id != OMIT
|
66
|
+
@name = name if name != OMIT
|
67
|
+
@description = description if description != OMIT
|
68
|
+
@start_date = start_date if start_date != OMIT
|
69
|
+
@end_date = end_date if end_date != OMIT
|
70
|
+
@total_amount = total_amount if total_amount != OMIT
|
71
|
+
@billed_amount_without_tax = billed_amount_without_tax if billed_amount_without_tax != OMIT
|
72
|
+
@billed_tax = billed_tax if billed_tax != OMIT
|
73
|
+
@total_billed_amount = total_billed_amount if total_billed_amount != OMIT
|
74
|
+
@creation_state = creation_state if creation_state != OMIT
|
75
|
+
@agent = agent if agent != OMIT
|
76
|
+
@order_line_attributes = order_line_attributes if order_line_attributes != OMIT
|
77
|
+
@additional_properties = additional_properties
|
78
|
+
@_field_set = { "id": id, "orderId": order_id, "agentId": agent_id, "name": name, "description": description, "startDate": start_date, "endDate": end_date, "totalAmount": total_amount, "billedAmountWithoutTax": billed_amount_without_tax, "billedTax": billed_tax, "totalBilledAmount": total_billed_amount, "creationState": creation_state, "agent": agent, "orderLineAttributes": order_line_attributes }.reject do | _k, v |
|
79
|
+
v == OMIT
|
80
|
+
end
|
81
|
+
end
|
82
|
+
# Deserialize a JSON object to an instance of OrderLine
|
83
|
+
#
|
84
|
+
# @param json_object [String]
|
85
|
+
# @return [Paid::OrderLine]
|
86
|
+
def self.from_json(json_object:)
|
87
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
88
|
+
parsed_json = JSON.parse(json_object)
|
89
|
+
id = parsed_json["id"]
|
90
|
+
order_id = parsed_json["orderId"]
|
91
|
+
agent_id = parsed_json["agentId"]
|
92
|
+
name = parsed_json["name"]
|
93
|
+
description = parsed_json["description"]
|
94
|
+
start_date = parsed_json["startDate"]
|
95
|
+
end_date = parsed_json["endDate"]
|
96
|
+
total_amount = parsed_json["totalAmount"]
|
97
|
+
billed_amount_without_tax = parsed_json["billedAmountWithoutTax"]
|
98
|
+
billed_tax = parsed_json["billedTax"]
|
99
|
+
total_billed_amount = parsed_json["totalBilledAmount"]
|
100
|
+
creation_state = parsed_json["creationState"]
|
101
|
+
unless parsed_json["agent"].nil?
|
102
|
+
agent = parsed_json["agent"].to_json
|
103
|
+
agent = Paid::Agent.from_json(json_object: agent)
|
104
|
+
else
|
105
|
+
agent = nil
|
106
|
+
end
|
107
|
+
order_line_attributes = parsed_json["orderLineAttributes"]&.map do | item |
|
108
|
+
item = item.to_json
|
109
|
+
Paid::OrderLineAttribute.from_json(json_object: item)
|
110
|
+
end
|
111
|
+
new(
|
112
|
+
id: id,
|
113
|
+
order_id: order_id,
|
114
|
+
agent_id: agent_id,
|
115
|
+
name: name,
|
116
|
+
description: description,
|
117
|
+
start_date: start_date,
|
118
|
+
end_date: end_date,
|
119
|
+
total_amount: total_amount,
|
120
|
+
billed_amount_without_tax: billed_amount_without_tax,
|
121
|
+
billed_tax: billed_tax,
|
122
|
+
total_billed_amount: total_billed_amount,
|
123
|
+
creation_state: creation_state,
|
124
|
+
agent: agent,
|
125
|
+
order_line_attributes: order_line_attributes,
|
126
|
+
additional_properties: struct
|
127
|
+
)
|
128
|
+
end
|
129
|
+
# Serialize an instance of OrderLine to a JSON object
|
130
|
+
#
|
131
|
+
# @return [String]
|
132
|
+
def to_json
|
133
|
+
@_field_set&.to_json
|
134
|
+
end
|
135
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
136
|
+
# hash and check each fields type against the current object's property
|
137
|
+
# definitions.
|
138
|
+
#
|
139
|
+
# @param obj [Object]
|
140
|
+
# @return [Void]
|
141
|
+
def self.validate_raw(obj:)
|
142
|
+
obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
143
|
+
obj.order_id&.is_a?(String) != false || raise("Passed value for field obj.order_id is not the expected type, validation failed.")
|
144
|
+
obj.agent_id&.is_a?(String) != false || raise("Passed value for field obj.agent_id is not the expected type, validation failed.")
|
145
|
+
obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
146
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
147
|
+
obj.start_date&.is_a?(String) != false || raise("Passed value for field obj.start_date is not the expected type, validation failed.")
|
148
|
+
obj.end_date&.is_a?(String) != false || raise("Passed value for field obj.end_date is not the expected type, validation failed.")
|
149
|
+
obj.total_amount&.is_a?(Float) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.")
|
150
|
+
obj.billed_amount_without_tax&.is_a?(Float) != false || raise("Passed value for field obj.billed_amount_without_tax is not the expected type, validation failed.")
|
151
|
+
obj.billed_tax&.is_a?(Float) != false || raise("Passed value for field obj.billed_tax is not the expected type, validation failed.")
|
152
|
+
obj.total_billed_amount&.is_a?(Float) != false || raise("Passed value for field obj.total_billed_amount is not the expected type, validation failed.")
|
153
|
+
obj.creation_state&.is_a?(Paid::CreationState) != false || raise("Passed value for field obj.creation_state is not the expected type, validation failed.")
|
154
|
+
obj.agent.nil? || Paid::Agent.validate_raw(obj: obj.agent)
|
155
|
+
obj.order_line_attributes&.is_a?(Array) != false || raise("Passed value for field obj.order_line_attributes is not the expected type, validation failed.")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|