ultracart_api 3.10.123 → 3.10.125
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -4
- data/docs/DatawarehouseApi.md +461 -0
- data/docs/OrderRefundableResponse.md +1 -0
- data/docs/Report.md +17 -0
- data/docs/ReportAuth.md +11 -0
- data/docs/ReportAuthResponse.md +12 -0
- data/docs/ReportDataSet.md +22 -0
- data/docs/ReportDataSetColumn.md +8 -0
- data/docs/ReportDataSetPage.md +17 -0
- data/docs/ReportDataSetPageResponse.md +12 -0
- data/docs/ReportDataSetQuery.md +19 -0
- data/docs/ReportDataSetResponse.md +12 -0
- data/docs/ReportDataSetRow.md +8 -0
- data/docs/ReportDataSetSchema.md +9 -0
- data/docs/ReportDataSource.md +13 -0
- data/docs/ReportDataSourceSchema.md +10 -0
- data/docs/ReportExecuteQueriesRequest.md +14 -0
- data/docs/ReportFilter.md +13 -0
- data/docs/ReportFilterConnection.md +9 -0
- data/docs/ReportPage.md +11 -0
- data/docs/ReportPageVisualization.md +16 -0
- data/docs/ReportPageVisualizationDimension.md +14 -0
- data/docs/ReportPageVisualizationMetric.md +11 -0
- data/docs/ReportResponse.md +12 -0
- data/docs/ReportsResponse.md +12 -0
- data/lib/ultracart_api/api/datawarehouse_api.rb +529 -0
- data/lib/ultracart_api/models/order_refundable_response.rb +11 -1
- data/lib/ultracart_api/models/report.rb +307 -0
- data/lib/ultracart_api/models/report_auth.rb +212 -0
- data/lib/ultracart_api/models/report_auth_response.rb +221 -0
- data/lib/ultracart_api/models/report_data_set.rb +362 -0
- data/lib/ultracart_api/models/report_data_set_column.rb +184 -0
- data/lib/ultracart_api/models/report_data_set_page.rb +273 -0
- data/lib/ultracart_api/models/report_data_set_page_response.rb +221 -0
- data/lib/ultracart_api/models/report_data_set_query.rb +330 -0
- data/lib/ultracart_api/models/report_data_set_response.rb +221 -0
- data/lib/ultracart_api/models/report_data_set_row.rb +186 -0
- data/lib/ultracart_api/models/report_data_set_schema.rb +228 -0
- data/lib/ultracart_api/models/report_data_source.rb +232 -0
- data/lib/ultracart_api/models/report_data_source_schema.rb +238 -0
- data/lib/ultracart_api/models/report_execute_queries_request.rb +278 -0
- data/lib/ultracart_api/models/report_filter.rb +272 -0
- data/lib/ultracart_api/models/report_filter_connection.rb +193 -0
- data/lib/ultracart_api/models/report_page.rb +216 -0
- data/lib/ultracart_api/models/report_page_visualization.rb +299 -0
- data/lib/ultracart_api/models/report_page_visualization_dimension.rb +244 -0
- data/lib/ultracart_api/models/report_page_visualization_metric.rb +248 -0
- data/lib/ultracart_api/models/report_response.rb +221 -0
- data/lib/ultracart_api/models/reports_response.rb +223 -0
- data/lib/ultracart_api/version.rb +1 -1
- data/lib/ultracart_api.rb +23 -0
- metadata +48 -2
@@ -0,0 +1,221 @@
|
|
1
|
+
=begin
|
2
|
+
#UltraCart Rest API V2
|
3
|
+
|
4
|
+
#UltraCart REST API Version 2
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0.0
|
7
|
+
Contact: support@ultracart.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.15-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module UltracartClient
|
16
|
+
class ReportAuthResponse
|
17
|
+
attr_accessor :error
|
18
|
+
|
19
|
+
attr_accessor :metadata
|
20
|
+
|
21
|
+
attr_accessor :report_auth
|
22
|
+
|
23
|
+
# Indicates if API call was successful
|
24
|
+
attr_accessor :success
|
25
|
+
|
26
|
+
attr_accessor :warning
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
:'error' => :'error',
|
32
|
+
:'metadata' => :'metadata',
|
33
|
+
:'report_auth' => :'report_auth',
|
34
|
+
:'success' => :'success',
|
35
|
+
:'warning' => :'warning'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Attribute type mapping.
|
40
|
+
def self.swagger_types
|
41
|
+
{
|
42
|
+
:'error' => :'Error',
|
43
|
+
:'metadata' => :'ResponseMetadata',
|
44
|
+
:'report_auth' => :'ReportAuth',
|
45
|
+
:'success' => :'BOOLEAN',
|
46
|
+
:'warning' => :'Warning'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
# Initializes the object
|
51
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
52
|
+
def initialize(attributes = {})
|
53
|
+
return unless attributes.is_a?(Hash)
|
54
|
+
|
55
|
+
# convert string to symbol for hash key
|
56
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
57
|
+
|
58
|
+
if attributes.has_key?(:'error')
|
59
|
+
self.error = attributes[:'error']
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes.has_key?(:'metadata')
|
63
|
+
self.metadata = attributes[:'metadata']
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes.has_key?(:'report_auth')
|
67
|
+
self.report_auth = attributes[:'report_auth']
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.has_key?(:'success')
|
71
|
+
self.success = attributes[:'success']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.has_key?(:'warning')
|
75
|
+
self.warning = attributes[:'warning']
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
80
|
+
# @return Array for valid properties with the reasons
|
81
|
+
def list_invalid_properties
|
82
|
+
invalid_properties = Array.new
|
83
|
+
invalid_properties
|
84
|
+
end
|
85
|
+
|
86
|
+
# Check to see if the all the properties in the model are valid
|
87
|
+
# @return true if the model is valid
|
88
|
+
def valid?
|
89
|
+
true
|
90
|
+
end
|
91
|
+
|
92
|
+
# Checks equality by comparing each attribute.
|
93
|
+
# @param [Object] Object to be compared
|
94
|
+
def ==(o)
|
95
|
+
return true if self.equal?(o)
|
96
|
+
self.class == o.class &&
|
97
|
+
error == o.error &&
|
98
|
+
metadata == o.metadata &&
|
99
|
+
report_auth == o.report_auth &&
|
100
|
+
success == o.success &&
|
101
|
+
warning == o.warning
|
102
|
+
end
|
103
|
+
|
104
|
+
# @see the `==` method
|
105
|
+
# @param [Object] Object to be compared
|
106
|
+
def eql?(o)
|
107
|
+
self == o
|
108
|
+
end
|
109
|
+
|
110
|
+
# Calculates hash code according to all attributes.
|
111
|
+
# @return [Fixnum] Hash code
|
112
|
+
def hash
|
113
|
+
[error, metadata, report_auth, success, warning].hash
|
114
|
+
end
|
115
|
+
|
116
|
+
# Builds the object from hash
|
117
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
118
|
+
# @return [Object] Returns the model itself
|
119
|
+
def build_from_hash(attributes)
|
120
|
+
return nil unless attributes.is_a?(Hash)
|
121
|
+
self.class.swagger_types.each_pair do |key, type|
|
122
|
+
if type =~ /\AArray<(.*)>/i
|
123
|
+
# check to ensure the input is an array given that the attribute
|
124
|
+
# is documented as an array but the input is not
|
125
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
126
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
127
|
+
end
|
128
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
129
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
130
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
131
|
+
end
|
132
|
+
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
136
|
+
# Deserializes the data based on type
|
137
|
+
# @param string type Data type
|
138
|
+
# @param string value Value to be deserialized
|
139
|
+
# @return [Object] Deserialized data
|
140
|
+
def _deserialize(type, value)
|
141
|
+
case type.to_sym
|
142
|
+
when :DateTime
|
143
|
+
DateTime.parse(value)
|
144
|
+
when :Date
|
145
|
+
Date.parse(value)
|
146
|
+
when :String
|
147
|
+
value.to_s
|
148
|
+
when :Integer
|
149
|
+
value.to_i
|
150
|
+
when :Float
|
151
|
+
value.to_f
|
152
|
+
when :BOOLEAN
|
153
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
154
|
+
true
|
155
|
+
else
|
156
|
+
false
|
157
|
+
end
|
158
|
+
when :Object
|
159
|
+
# generic object (usually a Hash), return directly
|
160
|
+
value
|
161
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
162
|
+
inner_type = Regexp.last_match[:inner_type]
|
163
|
+
value.map { |v| _deserialize(inner_type, v) }
|
164
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
165
|
+
k_type = Regexp.last_match[:k_type]
|
166
|
+
v_type = Regexp.last_match[:v_type]
|
167
|
+
{}.tap do |hash|
|
168
|
+
value.each do |k, v|
|
169
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
else # model
|
173
|
+
temp_model = UltracartClient.const_get(type).new
|
174
|
+
temp_model.build_from_hash(value)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# Returns the string representation of the object
|
179
|
+
# @return [String] String presentation of the object
|
180
|
+
def to_s
|
181
|
+
to_hash.to_s
|
182
|
+
end
|
183
|
+
|
184
|
+
# to_body is an alias to to_hash (backward compatibility)
|
185
|
+
# @return [Hash] Returns the object in the form of hash
|
186
|
+
def to_body
|
187
|
+
to_hash
|
188
|
+
end
|
189
|
+
|
190
|
+
# Returns the object in the form of hash
|
191
|
+
# @return [Hash] Returns the object in the form of hash
|
192
|
+
def to_hash
|
193
|
+
hash = {}
|
194
|
+
self.class.attribute_map.each_pair do |attr, param|
|
195
|
+
value = self.send(attr)
|
196
|
+
next if value.nil?
|
197
|
+
hash[param] = _to_hash(value)
|
198
|
+
end
|
199
|
+
hash
|
200
|
+
end
|
201
|
+
|
202
|
+
# Outputs non-array value in the form of hash
|
203
|
+
# For object, use to_hash. Otherwise, just return the value
|
204
|
+
# @param [Object] value Any valid value
|
205
|
+
# @return [Hash] Returns the value in the form of hash
|
206
|
+
def _to_hash(value)
|
207
|
+
if value.is_a?(Array)
|
208
|
+
value.compact.map { |v| _to_hash(v) }
|
209
|
+
elsif value.is_a?(Hash)
|
210
|
+
{}.tap do |hash|
|
211
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
212
|
+
end
|
213
|
+
elsif value.respond_to? :to_hash
|
214
|
+
value.to_hash
|
215
|
+
else
|
216
|
+
value
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
end
|
@@ -0,0 +1,362 @@
|
|
1
|
+
=begin
|
2
|
+
#UltraCart Rest API V2
|
3
|
+
|
4
|
+
#UltraCart REST API Version 2
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0.0
|
7
|
+
Contact: support@ultracart.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.15-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module UltracartClient
|
16
|
+
class ReportDataSet
|
17
|
+
# A unique identifier assigned to the data set query that is returned.
|
18
|
+
attr_accessor :data_set_query_uuid
|
19
|
+
|
20
|
+
# A unique identifier assigned to the data set that is returned.
|
21
|
+
attr_accessor :data_set_uuid
|
22
|
+
|
23
|
+
# The BigQuery destination table id that contains the result.
|
24
|
+
attr_accessor :destination_table_id
|
25
|
+
|
26
|
+
# Error message if the query failed.
|
27
|
+
attr_accessor :error_message
|
28
|
+
|
29
|
+
# An identifier that can be used to help match up the returned data set
|
30
|
+
attr_accessor :for_object_id
|
31
|
+
|
32
|
+
# The type of object this data set is for
|
33
|
+
attr_accessor :for_object_type
|
34
|
+
|
35
|
+
# Initial pages returned in the dataset
|
36
|
+
attr_accessor :initial_pages
|
37
|
+
|
38
|
+
# The total number of results
|
39
|
+
attr_accessor :max_results
|
40
|
+
|
41
|
+
# Merchant that owns this data set
|
42
|
+
attr_accessor :merchant_id
|
43
|
+
|
44
|
+
# The size of the pages
|
45
|
+
attr_accessor :page_count
|
46
|
+
|
47
|
+
# The size of the pages
|
48
|
+
attr_accessor :page_size
|
49
|
+
|
50
|
+
# The schema associated with the data set.
|
51
|
+
attr_accessor :schema
|
52
|
+
|
53
|
+
# Security level this dataset was read from.
|
54
|
+
attr_accessor :security_level
|
55
|
+
|
56
|
+
attr_accessor :timezone
|
57
|
+
|
58
|
+
# Any other data that needs to be returned with the response to help the UI
|
59
|
+
attr_accessor :user_data
|
60
|
+
|
61
|
+
class EnumAttributeValidator
|
62
|
+
attr_reader :datatype
|
63
|
+
attr_reader :allowable_values
|
64
|
+
|
65
|
+
def initialize(datatype, allowable_values)
|
66
|
+
@allowable_values = allowable_values.map do |value|
|
67
|
+
case datatype.to_s
|
68
|
+
when /Integer/i
|
69
|
+
value.to_i
|
70
|
+
when /Float/i
|
71
|
+
value.to_f
|
72
|
+
else
|
73
|
+
value
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def valid?(value)
|
79
|
+
!value || allowable_values.include?(value)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
84
|
+
def self.attribute_map
|
85
|
+
{
|
86
|
+
:'data_set_query_uuid' => :'data_set_query_uuid',
|
87
|
+
:'data_set_uuid' => :'data_set_uuid',
|
88
|
+
:'destination_table_id' => :'destination_table_id',
|
89
|
+
:'error_message' => :'error_message',
|
90
|
+
:'for_object_id' => :'for_object_id',
|
91
|
+
:'for_object_type' => :'for_object_type',
|
92
|
+
:'initial_pages' => :'initial_pages',
|
93
|
+
:'max_results' => :'max_results',
|
94
|
+
:'merchant_id' => :'merchant_id',
|
95
|
+
:'page_count' => :'page_count',
|
96
|
+
:'page_size' => :'page_size',
|
97
|
+
:'schema' => :'schema',
|
98
|
+
:'security_level' => :'security_level',
|
99
|
+
:'timezone' => :'timezone',
|
100
|
+
:'user_data' => :'user_data'
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
# Attribute type mapping.
|
105
|
+
def self.swagger_types
|
106
|
+
{
|
107
|
+
:'data_set_query_uuid' => :'String',
|
108
|
+
:'data_set_uuid' => :'String',
|
109
|
+
:'destination_table_id' => :'String',
|
110
|
+
:'error_message' => :'String',
|
111
|
+
:'for_object_id' => :'String',
|
112
|
+
:'for_object_type' => :'String',
|
113
|
+
:'initial_pages' => :'Array<ReportDataSetPage>',
|
114
|
+
:'max_results' => :'Integer',
|
115
|
+
:'merchant_id' => :'String',
|
116
|
+
:'page_count' => :'Integer',
|
117
|
+
:'page_size' => :'Integer',
|
118
|
+
:'schema' => :'Array<ReportDataSetSchema>',
|
119
|
+
:'security_level' => :'String',
|
120
|
+
:'timezone' => :'String',
|
121
|
+
:'user_data' => :'String'
|
122
|
+
}
|
123
|
+
end
|
124
|
+
|
125
|
+
# Initializes the object
|
126
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
127
|
+
def initialize(attributes = {})
|
128
|
+
return unless attributes.is_a?(Hash)
|
129
|
+
|
130
|
+
# convert string to symbol for hash key
|
131
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
132
|
+
|
133
|
+
if attributes.has_key?(:'data_set_query_uuid')
|
134
|
+
self.data_set_query_uuid = attributes[:'data_set_query_uuid']
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.has_key?(:'data_set_uuid')
|
138
|
+
self.data_set_uuid = attributes[:'data_set_uuid']
|
139
|
+
end
|
140
|
+
|
141
|
+
if attributes.has_key?(:'destination_table_id')
|
142
|
+
self.destination_table_id = attributes[:'destination_table_id']
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.has_key?(:'error_message')
|
146
|
+
self.error_message = attributes[:'error_message']
|
147
|
+
end
|
148
|
+
|
149
|
+
if attributes.has_key?(:'for_object_id')
|
150
|
+
self.for_object_id = attributes[:'for_object_id']
|
151
|
+
end
|
152
|
+
|
153
|
+
if attributes.has_key?(:'for_object_type')
|
154
|
+
self.for_object_type = attributes[:'for_object_type']
|
155
|
+
end
|
156
|
+
|
157
|
+
if attributes.has_key?(:'initial_pages')
|
158
|
+
if (value = attributes[:'initial_pages']).is_a?(Array)
|
159
|
+
self.initial_pages = value
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
if attributes.has_key?(:'max_results')
|
164
|
+
self.max_results = attributes[:'max_results']
|
165
|
+
end
|
166
|
+
|
167
|
+
if attributes.has_key?(:'merchant_id')
|
168
|
+
self.merchant_id = attributes[:'merchant_id']
|
169
|
+
end
|
170
|
+
|
171
|
+
if attributes.has_key?(:'page_count')
|
172
|
+
self.page_count = attributes[:'page_count']
|
173
|
+
end
|
174
|
+
|
175
|
+
if attributes.has_key?(:'page_size')
|
176
|
+
self.page_size = attributes[:'page_size']
|
177
|
+
end
|
178
|
+
|
179
|
+
if attributes.has_key?(:'schema')
|
180
|
+
if (value = attributes[:'schema']).is_a?(Array)
|
181
|
+
self.schema = value
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
if attributes.has_key?(:'security_level')
|
186
|
+
self.security_level = attributes[:'security_level']
|
187
|
+
end
|
188
|
+
|
189
|
+
if attributes.has_key?(:'timezone')
|
190
|
+
self.timezone = attributes[:'timezone']
|
191
|
+
end
|
192
|
+
|
193
|
+
if attributes.has_key?(:'user_data')
|
194
|
+
self.user_data = attributes[:'user_data']
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
199
|
+
# @return Array for valid properties with the reasons
|
200
|
+
def list_invalid_properties
|
201
|
+
invalid_properties = Array.new
|
202
|
+
invalid_properties
|
203
|
+
end
|
204
|
+
|
205
|
+
# Check to see if the all the properties in the model are valid
|
206
|
+
# @return true if the model is valid
|
207
|
+
def valid?
|
208
|
+
for_object_type_validator = EnumAttributeValidator.new('String', ['schema', 'filter', 'visualization'])
|
209
|
+
return false unless for_object_type_validator.valid?(@for_object_type)
|
210
|
+
true
|
211
|
+
end
|
212
|
+
|
213
|
+
# Custom attribute writer method checking allowed values (enum).
|
214
|
+
# @param [Object] for_object_type Object to be assigned
|
215
|
+
def for_object_type=(for_object_type)
|
216
|
+
validator = EnumAttributeValidator.new('String', ['schema', 'filter', 'visualization'])
|
217
|
+
unless validator.valid?(for_object_type)
|
218
|
+
fail ArgumentError, 'invalid value for "for_object_type", must be one of #{validator.allowable_values}.'
|
219
|
+
end
|
220
|
+
@for_object_type = for_object_type
|
221
|
+
end
|
222
|
+
|
223
|
+
# Checks equality by comparing each attribute.
|
224
|
+
# @param [Object] Object to be compared
|
225
|
+
def ==(o)
|
226
|
+
return true if self.equal?(o)
|
227
|
+
self.class == o.class &&
|
228
|
+
data_set_query_uuid == o.data_set_query_uuid &&
|
229
|
+
data_set_uuid == o.data_set_uuid &&
|
230
|
+
destination_table_id == o.destination_table_id &&
|
231
|
+
error_message == o.error_message &&
|
232
|
+
for_object_id == o.for_object_id &&
|
233
|
+
for_object_type == o.for_object_type &&
|
234
|
+
initial_pages == o.initial_pages &&
|
235
|
+
max_results == o.max_results &&
|
236
|
+
merchant_id == o.merchant_id &&
|
237
|
+
page_count == o.page_count &&
|
238
|
+
page_size == o.page_size &&
|
239
|
+
schema == o.schema &&
|
240
|
+
security_level == o.security_level &&
|
241
|
+
timezone == o.timezone &&
|
242
|
+
user_data == o.user_data
|
243
|
+
end
|
244
|
+
|
245
|
+
# @see the `==` method
|
246
|
+
# @param [Object] Object to be compared
|
247
|
+
def eql?(o)
|
248
|
+
self == o
|
249
|
+
end
|
250
|
+
|
251
|
+
# Calculates hash code according to all attributes.
|
252
|
+
# @return [Fixnum] Hash code
|
253
|
+
def hash
|
254
|
+
[data_set_query_uuid, data_set_uuid, destination_table_id, error_message, for_object_id, for_object_type, initial_pages, max_results, merchant_id, page_count, page_size, schema, security_level, timezone, user_data].hash
|
255
|
+
end
|
256
|
+
|
257
|
+
# Builds the object from hash
|
258
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
259
|
+
# @return [Object] Returns the model itself
|
260
|
+
def build_from_hash(attributes)
|
261
|
+
return nil unless attributes.is_a?(Hash)
|
262
|
+
self.class.swagger_types.each_pair do |key, type|
|
263
|
+
if type =~ /\AArray<(.*)>/i
|
264
|
+
# check to ensure the input is an array given that the attribute
|
265
|
+
# is documented as an array but the input is not
|
266
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
267
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
268
|
+
end
|
269
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
270
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
271
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
272
|
+
end
|
273
|
+
|
274
|
+
self
|
275
|
+
end
|
276
|
+
|
277
|
+
# Deserializes the data based on type
|
278
|
+
# @param string type Data type
|
279
|
+
# @param string value Value to be deserialized
|
280
|
+
# @return [Object] Deserialized data
|
281
|
+
def _deserialize(type, value)
|
282
|
+
case type.to_sym
|
283
|
+
when :DateTime
|
284
|
+
DateTime.parse(value)
|
285
|
+
when :Date
|
286
|
+
Date.parse(value)
|
287
|
+
when :String
|
288
|
+
value.to_s
|
289
|
+
when :Integer
|
290
|
+
value.to_i
|
291
|
+
when :Float
|
292
|
+
value.to_f
|
293
|
+
when :BOOLEAN
|
294
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
295
|
+
true
|
296
|
+
else
|
297
|
+
false
|
298
|
+
end
|
299
|
+
when :Object
|
300
|
+
# generic object (usually a Hash), return directly
|
301
|
+
value
|
302
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
303
|
+
inner_type = Regexp.last_match[:inner_type]
|
304
|
+
value.map { |v| _deserialize(inner_type, v) }
|
305
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
306
|
+
k_type = Regexp.last_match[:k_type]
|
307
|
+
v_type = Regexp.last_match[:v_type]
|
308
|
+
{}.tap do |hash|
|
309
|
+
value.each do |k, v|
|
310
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
else # model
|
314
|
+
temp_model = UltracartClient.const_get(type).new
|
315
|
+
temp_model.build_from_hash(value)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
# Returns the string representation of the object
|
320
|
+
# @return [String] String presentation of the object
|
321
|
+
def to_s
|
322
|
+
to_hash.to_s
|
323
|
+
end
|
324
|
+
|
325
|
+
# to_body is an alias to to_hash (backward compatibility)
|
326
|
+
# @return [Hash] Returns the object in the form of hash
|
327
|
+
def to_body
|
328
|
+
to_hash
|
329
|
+
end
|
330
|
+
|
331
|
+
# Returns the object in the form of hash
|
332
|
+
# @return [Hash] Returns the object in the form of hash
|
333
|
+
def to_hash
|
334
|
+
hash = {}
|
335
|
+
self.class.attribute_map.each_pair do |attr, param|
|
336
|
+
value = self.send(attr)
|
337
|
+
next if value.nil?
|
338
|
+
hash[param] = _to_hash(value)
|
339
|
+
end
|
340
|
+
hash
|
341
|
+
end
|
342
|
+
|
343
|
+
# Outputs non-array value in the form of hash
|
344
|
+
# For object, use to_hash. Otherwise, just return the value
|
345
|
+
# @param [Object] value Any valid value
|
346
|
+
# @return [Hash] Returns the value in the form of hash
|
347
|
+
def _to_hash(value)
|
348
|
+
if value.is_a?(Array)
|
349
|
+
value.compact.map { |v| _to_hash(v) }
|
350
|
+
elsif value.is_a?(Hash)
|
351
|
+
{}.tap do |hash|
|
352
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
353
|
+
end
|
354
|
+
elsif value.respond_to? :to_hash
|
355
|
+
value.to_hash
|
356
|
+
else
|
357
|
+
value
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
end
|
362
|
+
end
|