dear-inventory-ruby 0.2.10.1 → 0.2.11

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.
@@ -967,6 +967,72 @@ module DearInventoryRuby
967
967
  return data, status_code, headers
968
968
  end
969
969
 
970
+ # Allows you to retrieve the carriers
971
+ # @param [Hash] opts the optional parameters
972
+ # @option opts [String] :page Default is 1 (default to '1')
973
+ # @option opts [String] :limit Default is 100 (default to '100')
974
+ # @option opts [String] :carrier_id Only return Carrier with the specific CarrierID
975
+ # @option opts [String] :description Only return Carriers that start with the specific Description
976
+ # @return [Carriers]
977
+ def get_carriers(opts = {})
978
+ data, _status_code, _headers = get_carriers_with_http_info(opts)
979
+ data
980
+ end
981
+
982
+ # Allows you to retrieve the carriers
983
+ # @param [Hash] opts the optional parameters
984
+ # @option opts [String] :page Default is 1
985
+ # @option opts [String] :limit Default is 100
986
+ # @option opts [String] :carrier_id Only return Carrier with the specific CarrierID
987
+ # @option opts [String] :description Only return Carriers that start with the specific Description
988
+ # @return [Array<(Carriers, Integer, Hash)>] Carriers data, response status code and response headers
989
+ def get_carriers_with_http_info(opts = {})
990
+ if @api_client.config.debugging
991
+ @api_client.config.logger.debug 'Calling API: InventoryApi.get_carriers ...'
992
+ end
993
+ # resource path
994
+ local_var_path = '/ref/carrier'
995
+
996
+ # query parameters
997
+ query_params = opts[:query_params] || {}
998
+ query_params[:'Page'] = opts[:'page'] if !opts[:'page'].nil?
999
+ query_params[:'Limit'] = opts[:'limit'] if !opts[:'limit'].nil?
1000
+ query_params[:'CarrierID'] = opts[:'carrier_id'] if !opts[:'carrier_id'].nil?
1001
+ query_params[:'Description'] = opts[:'description'] if !opts[:'description'].nil?
1002
+
1003
+ # header parameters
1004
+ header_params = opts[:header_params] || {}
1005
+ # HTTP header 'Accept' (if needed)
1006
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1007
+
1008
+ # form parameters
1009
+ form_params = opts[:form_params] || {}
1010
+
1011
+ # http body (model)
1012
+ post_body = opts[:body]
1013
+
1014
+ # return_type
1015
+ return_type = opts[:return_type] || 'Carriers'
1016
+
1017
+ # auth_names
1018
+ auth_names = opts[:auth_names] || ['accountID', 'appKey']
1019
+
1020
+ new_options = opts.merge(
1021
+ :header_params => header_params,
1022
+ :query_params => query_params,
1023
+ :form_params => form_params,
1024
+ :body => post_body,
1025
+ :auth_names => auth_names,
1026
+ :return_type => return_type
1027
+ )
1028
+
1029
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1030
+ if @api_client.config.debugging
1031
+ @api_client.config.logger.debug "API called: InventoryApi#get_carriers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1032
+ end
1033
+ return data, status_code, headers
1034
+ end
1035
+
970
1036
  # Allows you to retrieve the customers
971
1037
  # @param [Hash] opts the optional parameters
972
1038
  # @option opts [String] :page Default is 1 (default to '1')
@@ -975,8 +1041,8 @@ module DearInventoryRuby
975
1041
  # @option opts [String] :name Default is nil
976
1042
  # @option opts [String] :contact_filter Default is nil
977
1043
  # @option opts [String] :modified_since Default is nil
978
- # @option opts [String] :include_deprecated Default is false (default to 'false')
979
- # @option opts [String] :include_product_prices Default is false (default to 'false')
1044
+ # @option opts [Boolean] :include_deprecated Default is false (default to false)
1045
+ # @option opts [Boolean] :include_product_prices Default is false (default to false)
980
1046
  # @return [Customers]
981
1047
  def get_customers(opts = {})
982
1048
  data, _status_code, _headers = get_customers_with_http_info(opts)
@@ -991,8 +1057,8 @@ module DearInventoryRuby
991
1057
  # @option opts [String] :name Default is nil
992
1058
  # @option opts [String] :contact_filter Default is nil
993
1059
  # @option opts [String] :modified_since Default is nil
994
- # @option opts [String] :include_deprecated Default is false
995
- # @option opts [String] :include_product_prices Default is false
1060
+ # @option opts [Boolean] :include_deprecated Default is false
1061
+ # @option opts [Boolean] :include_product_prices Default is false
996
1062
  # @return [Array<(Customers, Integer, Hash)>] Customers data, response status code and response headers
997
1063
  def get_customers_with_http_info(opts = {})
998
1064
  if @api_client.config.debugging
@@ -1045,6 +1111,75 @@ module DearInventoryRuby
1045
1111
  return data, status_code, headers
1046
1112
  end
1047
1113
 
1114
+ # Allows you to retrieve the locations
1115
+ # @param [Hash] opts the optional parameters
1116
+ # @option opts [String] :page Default is 1 (default to '1')
1117
+ # @option opts [String] :limit Default is 100 (default to '100')
1118
+ # @option opts [String] :id Default is nil
1119
+ # @option opts [Boolean] :deprecated Default is false (default to false)
1120
+ # @option opts [String] :name Default is nil
1121
+ # @return [Locations]
1122
+ def get_locations(opts = {})
1123
+ data, _status_code, _headers = get_locations_with_http_info(opts)
1124
+ data
1125
+ end
1126
+
1127
+ # Allows you to retrieve the locations
1128
+ # @param [Hash] opts the optional parameters
1129
+ # @option opts [String] :page Default is 1
1130
+ # @option opts [String] :limit Default is 100
1131
+ # @option opts [String] :id Default is nil
1132
+ # @option opts [Boolean] :deprecated Default is false
1133
+ # @option opts [String] :name Default is nil
1134
+ # @return [Array<(Locations, Integer, Hash)>] Locations data, response status code and response headers
1135
+ def get_locations_with_http_info(opts = {})
1136
+ if @api_client.config.debugging
1137
+ @api_client.config.logger.debug 'Calling API: InventoryApi.get_locations ...'
1138
+ end
1139
+ # resource path
1140
+ local_var_path = '/ref/location'
1141
+
1142
+ # query parameters
1143
+ query_params = opts[:query_params] || {}
1144
+ query_params[:'Page'] = opts[:'page'] if !opts[:'page'].nil?
1145
+ query_params[:'Limit'] = opts[:'limit'] if !opts[:'limit'].nil?
1146
+ query_params[:'ID'] = opts[:'id'] if !opts[:'id'].nil?
1147
+ query_params[:'Deprecated'] = opts[:'deprecated'] if !opts[:'deprecated'].nil?
1148
+ query_params[:'Name'] = opts[:'name'] if !opts[:'name'].nil?
1149
+
1150
+ # header parameters
1151
+ header_params = opts[:header_params] || {}
1152
+ # HTTP header 'Accept' (if needed)
1153
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1154
+
1155
+ # form parameters
1156
+ form_params = opts[:form_params] || {}
1157
+
1158
+ # http body (model)
1159
+ post_body = opts[:body]
1160
+
1161
+ # return_type
1162
+ return_type = opts[:return_type] || 'Locations'
1163
+
1164
+ # auth_names
1165
+ auth_names = opts[:auth_names] || ['accountID', 'appKey']
1166
+
1167
+ new_options = opts.merge(
1168
+ :header_params => header_params,
1169
+ :query_params => query_params,
1170
+ :form_params => form_params,
1171
+ :body => post_body,
1172
+ :auth_names => auth_names,
1173
+ :return_type => return_type
1174
+ )
1175
+
1176
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1177
+ if @api_client.config.debugging
1178
+ @api_client.config.logger.debug "API called: InventoryApi#get_locations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1179
+ end
1180
+ return data, status_code, headers
1181
+ end
1182
+
1048
1183
  # Allows you to retrieve your information
1049
1184
  # @param [Hash] opts the optional parameters
1050
1185
  # @return [Me]
@@ -1099,6 +1234,60 @@ module DearInventoryRuby
1099
1234
  return data, status_code, headers
1100
1235
  end
1101
1236
 
1237
+ # Allows you to retrieve the me contacts (Sales Representatives)
1238
+ # @param [Hash] opts the optional parameters
1239
+ # @return [MeContacts]
1240
+ def get_me_contacts(opts = {})
1241
+ data, _status_code, _headers = get_me_contacts_with_http_info(opts)
1242
+ data
1243
+ end
1244
+
1245
+ # Allows you to retrieve the me contacts (Sales Representatives)
1246
+ # @param [Hash] opts the optional parameters
1247
+ # @return [Array<(MeContacts, Integer, Hash)>] MeContacts data, response status code and response headers
1248
+ def get_me_contacts_with_http_info(opts = {})
1249
+ if @api_client.config.debugging
1250
+ @api_client.config.logger.debug 'Calling API: InventoryApi.get_me_contacts ...'
1251
+ end
1252
+ # resource path
1253
+ local_var_path = '/me/contacts'
1254
+
1255
+ # query parameters
1256
+ query_params = opts[:query_params] || {}
1257
+
1258
+ # header parameters
1259
+ header_params = opts[:header_params] || {}
1260
+ # HTTP header 'Accept' (if needed)
1261
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1262
+
1263
+ # form parameters
1264
+ form_params = opts[:form_params] || {}
1265
+
1266
+ # http body (model)
1267
+ post_body = opts[:body]
1268
+
1269
+ # return_type
1270
+ return_type = opts[:return_type] || 'MeContacts'
1271
+
1272
+ # auth_names
1273
+ auth_names = opts[:auth_names] || ['accountID', 'appKey']
1274
+
1275
+ new_options = opts.merge(
1276
+ :header_params => header_params,
1277
+ :query_params => query_params,
1278
+ :form_params => form_params,
1279
+ :body => post_body,
1280
+ :auth_names => auth_names,
1281
+ :return_type => return_type
1282
+ )
1283
+
1284
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1285
+ if @api_client.config.debugging
1286
+ @api_client.config.logger.debug "API called: InventoryApi#get_me_contacts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1287
+ end
1288
+ return data, status_code, headers
1289
+ end
1290
+
1102
1291
  # Allows you to retrieve the payment terms
1103
1292
  # @param [Hash] opts the optional parameters
1104
1293
  # @option opts [String] :page Default is 1 (default to '1')
@@ -0,0 +1,217 @@
1
+ =begin
2
+ #DEAR Inventory API
3
+
4
+ #This specifing endpoints for DEAR Inventory API
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: nnhansg@gmail.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DearInventoryRuby
16
+ class Bin
17
+ # Unique ID
18
+ attr_accessor :id
19
+
20
+ # Name of `Bin`
21
+ attr_accessor :name
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'id' => :'ID',
27
+ :'name' => :'Name'
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'id' => :'String',
35
+ :'name' => :'String'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::Bin` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::Bin`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'id')
61
+ self.id = attributes[:'id']
62
+ end
63
+
64
+ if attributes.key?(:'name')
65
+ self.name = attributes[:'name']
66
+ end
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properties with the reasons
71
+ def list_invalid_properties
72
+ invalid_properties = Array.new
73
+ invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(o)
85
+ return true if self.equal?(o)
86
+ self.class == o.class &&
87
+ id == o.id &&
88
+ name == o.name
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Integer] Hash code
99
+ def hash
100
+ [id, name].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ new.build_from_hash(attributes)
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ self.class.openapi_types.each_pair do |key, type|
116
+ if type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ DearInventoryRuby.const_get(type).build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+ end
217
+ end
@@ -0,0 +1,217 @@
1
+ =begin
2
+ #DEAR Inventory API
3
+
4
+ #This specifing endpoints for DEAR Inventory API
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: nnhansg@gmail.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DearInventoryRuby
16
+ class Carrier
17
+ # Unique `Carrier` ID
18
+ attr_accessor :carrier_id
19
+
20
+ # Name of `Carrier`
21
+ attr_accessor :description
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'carrier_id' => :'CarrierID',
27
+ :'description' => :'Description'
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'carrier_id' => :'String',
35
+ :'description' => :'String'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::Carrier` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::Carrier`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'carrier_id')
61
+ self.carrier_id = attributes[:'carrier_id']
62
+ end
63
+
64
+ if attributes.key?(:'description')
65
+ self.description = attributes[:'description']
66
+ end
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properties with the reasons
71
+ def list_invalid_properties
72
+ invalid_properties = Array.new
73
+ invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(o)
85
+ return true if self.equal?(o)
86
+ self.class == o.class &&
87
+ carrier_id == o.carrier_id &&
88
+ description == o.description
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Integer] Hash code
99
+ def hash
100
+ [carrier_id, description].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ new.build_from_hash(attributes)
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ self.class.openapi_types.each_pair do |key, type|
116
+ if type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ DearInventoryRuby.const_get(type).build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+ end
217
+ end