carbon_ruby_sdk 0.2.34 → 0.2.36

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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +460 -2
  4. data/lib/carbon_ruby_sdk/api/crm_api.rb +909 -0
  5. data/lib/carbon_ruby_sdk/api/integrations_api.rb +298 -0
  6. data/lib/carbon_ruby_sdk/models/account.rb +398 -0
  7. data/lib/carbon_ruby_sdk/models/account_filters.rb +226 -0
  8. data/lib/carbon_ruby_sdk/models/account_response.rb +246 -0
  9. data/lib/carbon_ruby_sdk/models/accounts_order_by.rb +39 -0
  10. data/lib/carbon_ruby_sdk/models/accounts_order_by_nullable.rb +39 -0
  11. data/lib/carbon_ruby_sdk/models/accounts_request.rb +293 -0
  12. data/lib/carbon_ruby_sdk/models/address.rb +276 -0
  13. data/lib/carbon_ruby_sdk/models/authentication_property.rb +32 -6
  14. data/lib/carbon_ruby_sdk/models/azure_blob_auth_request.rb +245 -0
  15. data/lib/carbon_ruby_sdk/models/azure_blob_file_sync_input.rb +379 -0
  16. data/lib/carbon_ruby_sdk/models/azure_blob_get_file_input.rb +226 -0
  17. data/lib/carbon_ruby_sdk/models/azure_blob_storage_authentication.rb +244 -0
  18. data/lib/carbon_ruby_sdk/models/base_includes.rb +36 -0
  19. data/lib/carbon_ruby_sdk/models/contact.rb +434 -0
  20. data/lib/carbon_ruby_sdk/models/contact_filters.rb +236 -0
  21. data/lib/carbon_ruby_sdk/models/contacts_order_by.rb +39 -0
  22. data/lib/carbon_ruby_sdk/models/contacts_order_by_nullable.rb +39 -0
  23. data/lib/carbon_ruby_sdk/models/contacts_request.rb +293 -0
  24. data/lib/carbon_ruby_sdk/models/contacts_response.rb +246 -0
  25. data/lib/carbon_ruby_sdk/models/data_source_type.rb +2 -1
  26. data/lib/carbon_ruby_sdk/models/data_source_type_nullable.rb +2 -1
  27. data/lib/carbon_ruby_sdk/models/email.rb +230 -0
  28. data/lib/carbon_ruby_sdk/models/event.rb +370 -0
  29. data/lib/carbon_ruby_sdk/models/lead.rb +468 -0
  30. data/lib/carbon_ruby_sdk/models/lead_filters.rb +246 -0
  31. data/lib/carbon_ruby_sdk/models/leads_order_by.rb +38 -0
  32. data/lib/carbon_ruby_sdk/models/leads_order_by_nullable.rb +38 -0
  33. data/lib/carbon_ruby_sdk/models/leads_request.rb +293 -0
  34. data/lib/carbon_ruby_sdk/models/leads_response.rb +246 -0
  35. data/lib/carbon_ruby_sdk/models/one_drive_authentication.rb +250 -0
  36. data/lib/carbon_ruby_sdk/models/opportunities_order_by.rb +40 -0
  37. data/lib/carbon_ruby_sdk/models/opportunities_order_by_nullable.rb +40 -0
  38. data/lib/carbon_ruby_sdk/models/opportunities_request.rb +293 -0
  39. data/lib/carbon_ruby_sdk/models/opportunities_response.rb +246 -0
  40. data/lib/carbon_ruby_sdk/models/opportunity.rb +400 -0
  41. data/lib/carbon_ruby_sdk/models/opportunity_filters.rb +246 -0
  42. data/lib/carbon_ruby_sdk/models/opportunity_status.rb +36 -0
  43. data/lib/carbon_ruby_sdk/models/opportunity_status_nullable.rb +36 -0
  44. data/lib/carbon_ruby_sdk/models/order_dir_v2_nullable.rb +36 -0
  45. data/lib/carbon_ruby_sdk/models/partial_account.rb +216 -0
  46. data/lib/carbon_ruby_sdk/models/partial_account_nullable.rb +216 -0
  47. data/lib/carbon_ruby_sdk/models/partial_contact.rb +216 -0
  48. data/lib/carbon_ruby_sdk/models/partial_contact_nullable.rb +216 -0
  49. data/lib/carbon_ruby_sdk/models/partial_owner.rb +216 -0
  50. data/lib/carbon_ruby_sdk/models/partial_owner_nullable.rb +216 -0
  51. data/lib/carbon_ruby_sdk/models/phone_number.rb +230 -0
  52. data/lib/carbon_ruby_sdk/models/sent_webhook_payload.rb +2 -2
  53. data/lib/carbon_ruby_sdk/models/sharepoint_authentication.rb +1 -5
  54. data/lib/carbon_ruby_sdk/models/task.rb +346 -0
  55. data/lib/carbon_ruby_sdk/version.rb +1 -1
  56. data/lib/carbon_ruby_sdk.rb +47 -0
  57. data/spec/api/crm_api_spec.rb +129 -0
  58. data/spec/api/integrations_api_spec.rb +24 -0
  59. data/spec/models/account_filters_spec.rb +34 -0
  60. data/spec/models/account_response_spec.rb +40 -0
  61. data/spec/models/account_spec.rb +118 -0
  62. data/spec/models/accounts_order_by_nullable_spec.rb +22 -0
  63. data/spec/models/accounts_order_by_spec.rb +22 -0
  64. data/spec/models/accounts_request_spec.rb +70 -0
  65. data/spec/models/address_spec.rb +64 -0
  66. data/spec/models/authentication_property_spec.rb +12 -0
  67. data/spec/models/azure_blob_auth_request_spec.rb +40 -0
  68. data/spec/models/azure_blob_file_sync_input_spec.rb +112 -0
  69. data/spec/models/azure_blob_get_file_input_spec.rb +34 -0
  70. data/spec/models/azure_blob_storage_authentication_spec.rb +40 -0
  71. data/spec/models/base_includes_spec.rb +22 -0
  72. data/spec/models/contact_filters_spec.rb +40 -0
  73. data/spec/models/contact_spec.rb +136 -0
  74. data/spec/models/contacts_order_by_nullable_spec.rb +22 -0
  75. data/spec/models/contacts_order_by_spec.rb +22 -0
  76. data/spec/models/contacts_request_spec.rb +70 -0
  77. data/spec/models/contacts_response_spec.rb +40 -0
  78. data/spec/models/email_spec.rb +34 -0
  79. data/spec/models/event_spec.rb +106 -0
  80. data/spec/models/lead_filters_spec.rb +46 -0
  81. data/spec/models/lead_spec.rb +154 -0
  82. data/spec/models/leads_order_by_nullable_spec.rb +22 -0
  83. data/spec/models/leads_order_by_spec.rb +22 -0
  84. data/spec/models/leads_request_spec.rb +70 -0
  85. data/spec/models/leads_response_spec.rb +40 -0
  86. data/spec/models/one_drive_authentication_spec.rb +46 -0
  87. data/spec/models/opportunities_order_by_nullable_spec.rb +22 -0
  88. data/spec/models/opportunities_order_by_spec.rb +22 -0
  89. data/spec/models/opportunities_request_spec.rb +70 -0
  90. data/spec/models/opportunities_response_spec.rb +40 -0
  91. data/spec/models/opportunity_filters_spec.rb +46 -0
  92. data/spec/models/opportunity_spec.rb +124 -0
  93. data/spec/models/opportunity_status_nullable_spec.rb +22 -0
  94. data/spec/models/opportunity_status_spec.rb +22 -0
  95. data/spec/models/order_dir_v2_nullable_spec.rb +22 -0
  96. data/spec/models/partial_account_nullable_spec.rb +28 -0
  97. data/spec/models/partial_account_spec.rb +28 -0
  98. data/spec/models/partial_contact_nullable_spec.rb +28 -0
  99. data/spec/models/partial_contact_spec.rb +28 -0
  100. data/spec/models/partial_owner_nullable_spec.rb +28 -0
  101. data/spec/models/partial_owner_spec.rb +28 -0
  102. data/spec/models/phone_number_spec.rb +34 -0
  103. data/spec/models/sent_webhook_payload_spec.rb +1 -1
  104. data/spec/models/task_spec.rb +94 -0
  105. metadata +137 -2
@@ -0,0 +1,246 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class OpportunityFilters
14
+ attr_accessor :owner_id
15
+
16
+ attr_accessor :account_id
17
+
18
+ attr_accessor :status
19
+
20
+ attr_accessor :stage
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'owner_id' => :'owner_id',
26
+ :'account_id' => :'account_id',
27
+ :'status' => :'status',
28
+ :'stage' => :'stage'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'owner_id' => :'String',
41
+ :'account_id' => :'String',
42
+ :'status' => :'OpportunityStatusNullable',
43
+ :'stage' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ :'owner_id',
51
+ :'account_id',
52
+ :'status',
53
+ :'stage'
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::OpportunityFilters` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::OpportunityFilters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'owner_id')
73
+ self.owner_id = attributes[:'owner_id']
74
+ end
75
+
76
+ if attributes.key?(:'account_id')
77
+ self.account_id = attributes[:'account_id']
78
+ end
79
+
80
+ if attributes.key?(:'status')
81
+ self.status = attributes[:'status']
82
+ end
83
+
84
+ if attributes.key?(:'stage')
85
+ self.stage = attributes[:'stage']
86
+ end
87
+ end
88
+
89
+ # Show invalid properties with the reasons. Usually used together with valid?
90
+ # @return Array for valid properties with the reasons
91
+ def list_invalid_properties
92
+ invalid_properties = Array.new
93
+ invalid_properties
94
+ end
95
+
96
+ # Check to see if the all the properties in the model are valid
97
+ # @return true if the model is valid
98
+ def valid?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ owner_id == o.owner_id &&
108
+ account_id == o.account_id &&
109
+ status == o.status &&
110
+ stage == o.stage
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [owner_id, account_id, status, stage].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ attributes = attributes.transform_keys(&:to_sym)
138
+ self.class.openapi_types.each_pair do |key, type|
139
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
140
+ self.send("#{key}=", nil)
141
+ elsif type =~ /\AArray<(.*)>/i
142
+ # check to ensure the input is an array given that the attribute
143
+ # is documented as an array but the input is not
144
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
145
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
146
+ end
147
+ elsif !attributes[self.class.attribute_map[key]].nil?
148
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
149
+ end
150
+ end
151
+
152
+ self
153
+ end
154
+
155
+ # Deserializes the data based on type
156
+ # @param string type Data type
157
+ # @param string value Value to be deserialized
158
+ # @return [Object] Deserialized data
159
+ def _deserialize(type, value)
160
+ case type.to_sym
161
+ when :Time
162
+ Time.parse(value)
163
+ when :Date
164
+ Date.parse(value)
165
+ when :String
166
+ value.to_s
167
+ when :Integer
168
+ value.to_i
169
+ when :Float
170
+ value.to_f
171
+ when :Boolean
172
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
173
+ true
174
+ else
175
+ false
176
+ end
177
+ when :Object
178
+ # generic object (usually a Hash), return directly
179
+ value
180
+ when /\AArray<(?<inner_type>.+)>\z/
181
+ inner_type = Regexp.last_match[:inner_type]
182
+ value.map { |v| _deserialize(inner_type, v) }
183
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
184
+ k_type = Regexp.last_match[:k_type]
185
+ v_type = Regexp.last_match[:v_type]
186
+ {}.tap do |hash|
187
+ value.each do |k, v|
188
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
189
+ end
190
+ end
191
+ else # model
192
+ # models (e.g. Pet) or oneOf
193
+ klass = Carbon.const_get(type)
194
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
195
+ end
196
+ end
197
+
198
+ # Returns the string representation of the object
199
+ # @return [String] String presentation of the object
200
+ def to_s
201
+ to_hash.to_s
202
+ end
203
+
204
+ # to_body is an alias to to_hash (backward compatibility)
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_body
207
+ to_hash
208
+ end
209
+
210
+ # Returns the object in the form of hash
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_hash
213
+ hash = {}
214
+ self.class.attribute_map.each_pair do |attr, param|
215
+ value = self.send(attr)
216
+ if value.nil?
217
+ is_nullable = self.class.openapi_nullable.include?(attr)
218
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
219
+ end
220
+
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ hash
224
+ end
225
+
226
+ # Outputs non-array value in the form of hash
227
+ # For object, use to_hash. Otherwise, just return the value
228
+ # @param [Object] value Any valid value
229
+ # @return [Hash] Returns the value in the form of hash
230
+ def _to_hash(value)
231
+ if value.is_a?(Array)
232
+ value.compact.map { |v| _to_hash(v) }
233
+ elsif value.is_a?(Hash)
234
+ {}.tap do |hash|
235
+ value.each { |k, v| hash[k] = _to_hash(v) }
236
+ end
237
+ elsif value.respond_to? :to_hash
238
+ value.to_hash
239
+ else
240
+ value
241
+ end
242
+ end
243
+
244
+ end
245
+
246
+ end
@@ -0,0 +1,36 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class OpportunityStatus
14
+ WON = "WON".freeze
15
+ OPEN = "OPEN".freeze
16
+
17
+ def self.all_vars
18
+ @all_vars ||= [WON, OPEN].freeze
19
+ end
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ return value if OpportunityStatus.all_vars.include?(value)
33
+ raise "Invalid ENUM value #{value} for class #OpportunityStatus"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class OpportunityStatusNullable
14
+ WON = "WON".freeze
15
+ OPEN = "OPEN".freeze
16
+
17
+ def self.all_vars
18
+ @all_vars ||= [WON, OPEN].freeze
19
+ end
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ return value if OpportunityStatusNullable.all_vars.include?(value)
33
+ raise "Invalid ENUM value #{value} for class #OpportunityStatusNullable"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class OrderDirV2Nullable
14
+ ASC = "asc".freeze
15
+ DESC = "desc".freeze
16
+
17
+ def self.all_vars
18
+ @all_vars ||= [ASC, DESC].freeze
19
+ end
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ return value if OrderDirV2Nullable.all_vars.include?(value)
33
+ raise "Invalid ENUM value #{value} for class #OrderDirV2Nullable"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,216 @@
1
+ =begin
2
+ #Carbon
3
+
4
+ #Connect external data to LLMs, no matter the source.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ =end
8
+
9
+ require 'date'
10
+ require 'time'
11
+
12
+ module Carbon
13
+ class PartialAccount
14
+ attr_accessor :id
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :'id' => :'id'
20
+ }
21
+ end
22
+
23
+ # Returns all the JSON keys this model knows about
24
+ def self.acceptable_attributes
25
+ attribute_map.values
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.openapi_types
30
+ {
31
+ :'id' => :'String'
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new([
38
+ :'id'
39
+ ])
40
+ end
41
+
42
+ # Initializes the object
43
+ # @param [Hash] attributes Model attributes in the form of hash
44
+ def initialize(attributes = {})
45
+ if (!attributes.is_a?(Hash))
46
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Carbon::PartialAccount` initialize method"
47
+ end
48
+
49
+ # check to see if the attribute exists and convert string to symbol for hash key
50
+ attributes = attributes.each_with_object({}) { |(k, v), h|
51
+ if (!self.class.attribute_map.key?(k.to_sym))
52
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Carbon::PartialAccount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
53
+ end
54
+ h[k.to_sym] = v
55
+ }
56
+
57
+ if attributes.key?(:'id')
58
+ self.id = attributes[:'id']
59
+ end
60
+ end
61
+
62
+ # Show invalid properties with the reasons. Usually used together with valid?
63
+ # @return Array for valid properties with the reasons
64
+ def list_invalid_properties
65
+ invalid_properties = Array.new
66
+ invalid_properties
67
+ end
68
+
69
+ # Check to see if the all the properties in the model are valid
70
+ # @return true if the model is valid
71
+ def valid?
72
+ true
73
+ end
74
+
75
+ # Checks equality by comparing each attribute.
76
+ # @param [Object] Object to be compared
77
+ def ==(o)
78
+ return true if self.equal?(o)
79
+ self.class == o.class &&
80
+ id == o.id
81
+ end
82
+
83
+ # @see the `==` method
84
+ # @param [Object] Object to be compared
85
+ def eql?(o)
86
+ self == o
87
+ end
88
+
89
+ # Calculates hash code according to all attributes.
90
+ # @return [Integer] Hash code
91
+ def hash
92
+ [id].hash
93
+ end
94
+
95
+ # Builds the object from hash
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ # @return [Object] Returns the model itself
98
+ def self.build_from_hash(attributes)
99
+ new.build_from_hash(attributes)
100
+ end
101
+
102
+ # Builds the object from hash
103
+ # @param [Hash] attributes Model attributes in the form of hash
104
+ # @return [Object] Returns the model itself
105
+ def build_from_hash(attributes)
106
+ return nil unless attributes.is_a?(Hash)
107
+ attributes = attributes.transform_keys(&:to_sym)
108
+ self.class.openapi_types.each_pair do |key, type|
109
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
110
+ self.send("#{key}=", nil)
111
+ elsif type =~ /\AArray<(.*)>/i
112
+ # check to ensure the input is an array given that the attribute
113
+ # is documented as an array but the input is not
114
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
115
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
116
+ end
117
+ elsif !attributes[self.class.attribute_map[key]].nil?
118
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
119
+ end
120
+ end
121
+
122
+ self
123
+ end
124
+
125
+ # Deserializes the data based on type
126
+ # @param string type Data type
127
+ # @param string value Value to be deserialized
128
+ # @return [Object] Deserialized data
129
+ def _deserialize(type, value)
130
+ case type.to_sym
131
+ when :Time
132
+ Time.parse(value)
133
+ when :Date
134
+ Date.parse(value)
135
+ when :String
136
+ value.to_s
137
+ when :Integer
138
+ value.to_i
139
+ when :Float
140
+ value.to_f
141
+ when :Boolean
142
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
+ true
144
+ else
145
+ false
146
+ end
147
+ when :Object
148
+ # generic object (usually a Hash), return directly
149
+ value
150
+ when /\AArray<(?<inner_type>.+)>\z/
151
+ inner_type = Regexp.last_match[:inner_type]
152
+ value.map { |v| _deserialize(inner_type, v) }
153
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
+ k_type = Regexp.last_match[:k_type]
155
+ v_type = Regexp.last_match[:v_type]
156
+ {}.tap do |hash|
157
+ value.each do |k, v|
158
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
+ end
160
+ end
161
+ else # model
162
+ # models (e.g. Pet) or oneOf
163
+ klass = Carbon.const_get(type)
164
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
165
+ end
166
+ end
167
+
168
+ # Returns the string representation of the object
169
+ # @return [String] String presentation of the object
170
+ def to_s
171
+ to_hash.to_s
172
+ end
173
+
174
+ # to_body is an alias to to_hash (backward compatibility)
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_body
177
+ to_hash
178
+ end
179
+
180
+ # Returns the object in the form of hash
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_hash
183
+ hash = {}
184
+ self.class.attribute_map.each_pair do |attr, param|
185
+ value = self.send(attr)
186
+ if value.nil?
187
+ is_nullable = self.class.openapi_nullable.include?(attr)
188
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
189
+ end
190
+
191
+ hash[param] = _to_hash(value)
192
+ end
193
+ hash
194
+ end
195
+
196
+ # Outputs non-array value in the form of hash
197
+ # For object, use to_hash. Otherwise, just return the value
198
+ # @param [Object] value Any valid value
199
+ # @return [Hash] Returns the value in the form of hash
200
+ def _to_hash(value)
201
+ if value.is_a?(Array)
202
+ value.compact.map { |v| _to_hash(v) }
203
+ elsif value.is_a?(Hash)
204
+ {}.tap do |hash|
205
+ value.each { |k, v| hash[k] = _to_hash(v) }
206
+ end
207
+ elsif value.respond_to? :to_hash
208
+ value.to_hash
209
+ else
210
+ value
211
+ end
212
+ end
213
+
214
+ end
215
+
216
+ end