ultracart_api 4.1.154 → 4.1.156

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.
@@ -101,6 +101,77 @@ module UltracartClient
101
101
  return data, status_code, headers
102
102
  end
103
103
 
104
+ # One time link that opens a preview in a browser with no UltraCart login
105
+ # The preview URL only works in a browser already signed in to UltraCart on the storefront's own host, and an agent's built in browser never is. This returns a single use access_url on the storefront host instead. Opening it gets past the storefront lock, shows the requested theme and applies the requested preview session for the rest of that browser session, then redirects to path. It expires two minutes after issue or on first use. Pages opened afterwards carry an X-UltraCart-Preview header of applied or not-applied. Requires a token that resolves to a user, so use the device authorization flow.
106
+ # @param storefront_oid [Integer]
107
+ # @param [Hash] opts the optional parameters
108
+ # @option opts [SfvbPreviewAccessRequest] :preview_access What the browser should see
109
+ # @return [SfvbPreviewAccessResponse]
110
+ def create_sfvb_preview_access(storefront_oid, opts = {})
111
+ data, _status_code, _headers = create_sfvb_preview_access_with_http_info(storefront_oid, opts)
112
+ data
113
+ end
114
+
115
+ # One time link that opens a preview in a browser with no UltraCart login
116
+ # The preview URL only works in a browser already signed in to UltraCart on the storefront's own host, and an agent's built in browser never is. This returns a single use access_url on the storefront host instead. Opening it gets past the storefront lock, shows the requested theme and applies the requested preview session for the rest of that browser session, then redirects to path. It expires two minutes after issue or on first use. Pages opened afterwards carry an X-UltraCart-Preview header of applied or not-applied. Requires a token that resolves to a user, so use the device authorization flow.
117
+ # @param storefront_oid [Integer]
118
+ # @param [Hash] opts the optional parameters
119
+ # @option opts [SfvbPreviewAccessRequest] :preview_access What the browser should see
120
+ # @return [Array<(SfvbPreviewAccessResponse, Integer, Hash)>] SfvbPreviewAccessResponse data, response status code and response headers
121
+ def create_sfvb_preview_access_with_http_info(storefront_oid, opts = {})
122
+ if @api_client.config.debugging
123
+ @api_client.config.logger.debug 'Calling API: SfvbApi.create_sfvb_preview_access ...'
124
+ end
125
+ # verify the required parameter 'storefront_oid' is set
126
+ if @api_client.config.client_side_validation && storefront_oid.nil?
127
+ fail ArgumentError, "Missing the required parameter 'storefront_oid' when calling SfvbApi.create_sfvb_preview_access"
128
+ end
129
+ # resource path
130
+ local_var_path = '/sfvb/storefronts/{storefront_oid}/preview_access'.sub('{' + 'storefront_oid' + '}', CGI.escape(storefront_oid.to_s))
131
+
132
+ # query parameters
133
+ query_params = opts[:query_params] || {}
134
+
135
+ # header parameters
136
+ header_params = opts[:header_params] || {}
137
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
138
+ # HTTP header 'Accept' (if needed)
139
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
140
+ # HTTP header 'Content-Type'
141
+ content_type = @api_client.select_header_content_type(['application/json'])
142
+ if !content_type.nil?
143
+ header_params['Content-Type'] = content_type
144
+ end
145
+
146
+ # form parameters
147
+ form_params = opts[:form_params] || {}
148
+
149
+ # http body (model)
150
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'preview_access'])
151
+
152
+ # return_type
153
+ return_type = opts[:debug_return_type] || 'SfvbPreviewAccessResponse'
154
+
155
+ # auth_names
156
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
157
+
158
+ new_options = opts.merge(
159
+ :operation => :"SfvbApi.create_sfvb_preview_access",
160
+ :header_params => header_params,
161
+ :query_params => query_params,
162
+ :form_params => form_params,
163
+ :body => post_body,
164
+ :auth_names => auth_names,
165
+ :return_type => return_type
166
+ )
167
+
168
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
169
+ if @api_client.config.debugging
170
+ @api_client.config.logger.debug "API called: SfvbApi#create_sfvb_preview_access\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
171
+ end
172
+ return data, status_code, headers
173
+ end
174
+
104
175
  # Create a preview session
105
176
  # Returns a server generated session id to push containers into, and opens the session so that id exists rather than merely being random. The id is not caller supplied, because concurrent agents choosing their own would be free to collide, and the browser editor's habit of minting one with Math.random is not a property worth carrying into an API. Expires after eight hours and can be deleted sooner. Requires a token that resolves to a user, so use the device authorization flow.
106
177
  # @param storefront_oid [Integer]
@@ -1033,6 +1104,140 @@ module UltracartClient
1033
1104
  return data, status_code, headers
1034
1105
  end
1035
1106
 
1107
+ # Read one store menu and its entries
1108
+ # The whole tree, in render order. Page entries carry the page_path they resolve to and item entries the merchant_item_id, rather than the oids the storage keeps. Menu item oids are not returned at all because a write regenerates every one of them. Keep hash_sha256 - it is the If-Match a write needs.
1109
+ # @param storefront_oid [Integer]
1110
+ # @param code [String] Menu code, matched without regard to case
1111
+ # @param [Hash] opts the optional parameters
1112
+ # @return [SfvbMenu]
1113
+ def get_sfvb_menu(storefront_oid, code, opts = {})
1114
+ data, _status_code, _headers = get_sfvb_menu_with_http_info(storefront_oid, code, opts)
1115
+ data
1116
+ end
1117
+
1118
+ # Read one store menu and its entries
1119
+ # The whole tree, in render order. Page entries carry the page_path they resolve to and item entries the merchant_item_id, rather than the oids the storage keeps. Menu item oids are not returned at all because a write regenerates every one of them. Keep hash_sha256 - it is the If-Match a write needs.
1120
+ # @param storefront_oid [Integer]
1121
+ # @param code [String] Menu code, matched without regard to case
1122
+ # @param [Hash] opts the optional parameters
1123
+ # @return [Array<(SfvbMenu, Integer, Hash)>] SfvbMenu data, response status code and response headers
1124
+ def get_sfvb_menu_with_http_info(storefront_oid, code, opts = {})
1125
+ if @api_client.config.debugging
1126
+ @api_client.config.logger.debug 'Calling API: SfvbApi.get_sfvb_menu ...'
1127
+ end
1128
+ # verify the required parameter 'storefront_oid' is set
1129
+ if @api_client.config.client_side_validation && storefront_oid.nil?
1130
+ fail ArgumentError, "Missing the required parameter 'storefront_oid' when calling SfvbApi.get_sfvb_menu"
1131
+ end
1132
+ # verify the required parameter 'code' is set
1133
+ if @api_client.config.client_side_validation && code.nil?
1134
+ fail ArgumentError, "Missing the required parameter 'code' when calling SfvbApi.get_sfvb_menu"
1135
+ end
1136
+ # resource path
1137
+ local_var_path = '/sfvb/storefronts/{storefront_oid}/menus/{code}'.sub('{' + 'storefront_oid' + '}', CGI.escape(storefront_oid.to_s)).sub('{' + 'code' + '}', CGI.escape(code.to_s))
1138
+
1139
+ # query parameters
1140
+ query_params = opts[:query_params] || {}
1141
+
1142
+ # header parameters
1143
+ header_params = opts[:header_params] || {}
1144
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1145
+ # HTTP header 'Accept' (if needed)
1146
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1147
+
1148
+ # form parameters
1149
+ form_params = opts[:form_params] || {}
1150
+
1151
+ # http body (model)
1152
+ post_body = opts[:debug_body]
1153
+
1154
+ # return_type
1155
+ return_type = opts[:debug_return_type] || 'SfvbMenu'
1156
+
1157
+ # auth_names
1158
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
1159
+
1160
+ new_options = opts.merge(
1161
+ :operation => :"SfvbApi.get_sfvb_menu",
1162
+ :header_params => header_params,
1163
+ :query_params => query_params,
1164
+ :form_params => form_params,
1165
+ :body => post_body,
1166
+ :auth_names => auth_names,
1167
+ :return_type => return_type
1168
+ )
1169
+
1170
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1171
+ if @api_client.config.debugging
1172
+ @api_client.config.logger.debug "API called: SfvbApi#get_sfvb_menu\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1173
+ end
1174
+ return data, status_code, headers
1175
+ end
1176
+
1177
+ # List a storefront's store menus
1178
+ # The menus a menu element's menuName can name, sorted by code and without their entries. A code the active theme's templates ask for but nothing has created is included with unconfigured true - that code renders an empty list today, and writing it creates it. A menu no template names is marked undeclared, which usually means a menuName is misspelled.
1179
+ # @param storefront_oid [Integer]
1180
+ # @param [Hash] opts the optional parameters
1181
+ # @return [SfvbMenusResponse]
1182
+ def get_sfvb_menus(storefront_oid, opts = {})
1183
+ data, _status_code, _headers = get_sfvb_menus_with_http_info(storefront_oid, opts)
1184
+ data
1185
+ end
1186
+
1187
+ # List a storefront&#39;s store menus
1188
+ # The menus a menu element&#39;s menuName can name, sorted by code and without their entries. A code the active theme&#39;s templates ask for but nothing has created is included with unconfigured true - that code renders an empty list today, and writing it creates it. A menu no template names is marked undeclared, which usually means a menuName is misspelled.
1189
+ # @param storefront_oid [Integer]
1190
+ # @param [Hash] opts the optional parameters
1191
+ # @return [Array<(SfvbMenusResponse, Integer, Hash)>] SfvbMenusResponse data, response status code and response headers
1192
+ def get_sfvb_menus_with_http_info(storefront_oid, opts = {})
1193
+ if @api_client.config.debugging
1194
+ @api_client.config.logger.debug 'Calling API: SfvbApi.get_sfvb_menus ...'
1195
+ end
1196
+ # verify the required parameter 'storefront_oid' is set
1197
+ if @api_client.config.client_side_validation && storefront_oid.nil?
1198
+ fail ArgumentError, "Missing the required parameter 'storefront_oid' when calling SfvbApi.get_sfvb_menus"
1199
+ end
1200
+ # resource path
1201
+ local_var_path = '/sfvb/storefronts/{storefront_oid}/menus'.sub('{' + 'storefront_oid' + '}', CGI.escape(storefront_oid.to_s))
1202
+
1203
+ # query parameters
1204
+ query_params = opts[:query_params] || {}
1205
+
1206
+ # header parameters
1207
+ header_params = opts[:header_params] || {}
1208
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
1209
+ # HTTP header 'Accept' (if needed)
1210
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
1211
+
1212
+ # form parameters
1213
+ form_params = opts[:form_params] || {}
1214
+
1215
+ # http body (model)
1216
+ post_body = opts[:debug_body]
1217
+
1218
+ # return_type
1219
+ return_type = opts[:debug_return_type] || 'SfvbMenusResponse'
1220
+
1221
+ # auth_names
1222
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
1223
+
1224
+ new_options = opts.merge(
1225
+ :operation => :"SfvbApi.get_sfvb_menus",
1226
+ :header_params => header_params,
1227
+ :query_params => query_params,
1228
+ :form_params => form_params,
1229
+ :body => post_body,
1230
+ :auth_names => auth_names,
1231
+ :return_type => return_type
1232
+ )
1233
+
1234
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
1235
+ if @api_client.config.debugging
1236
+ @api_client.config.logger.debug "API called: SfvbApi#get_sfvb_menus\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1237
+ end
1238
+ return data, status_code, headers
1239
+ end
1240
+
1036
1241
  # Read a page's attributes and images
1037
1242
  # What the pageattribute and pageimage elements render for this page. These are not in any file, which is why a page folder can be empty and its elements still render something. Attributes and image codes a template declares but nothing has set are included, so the response describes what the page can show rather than only what has been saved.
1038
1243
  # @param storefront_oid [Integer]
@@ -2209,6 +2414,90 @@ module UltracartClient
2209
2414
  return data, status_code, headers
2210
2415
  end
2211
2416
 
2417
+ # Replace a store menu's entries
2418
+ # A whole menu replace, not a merge - what you send is what the menu holds afterwards, so read it, change the tree and send it back. Omitting items changes only the title; sending an empty array empties the menu. Writing a code that does not exist creates it. Every entry is checked before any of it is written, including that a merchant_item_id and a page_path actually resolve, so a tree with one bad entry changes nothing. Always needs sfvb_publish, because a menu is shared by every theme and there is no dormant copy to change instead.
2419
+ # @param storefront_oid [Integer]
2420
+ # @param code [String] Menu code, matched without regard to case
2421
+ # @param menu_write_request [SfvbMenuWriteRequest] The menu&#39;s replacement contents
2422
+ # @param [Hash] opts the optional parameters
2423
+ # @option opts [String] :if_match Content hash from the last read. Required when the menu already exists; 428 when absent, 412 when stale.
2424
+ # @return [SfvbMenu]
2425
+ def put_sfvb_menu(storefront_oid, code, menu_write_request, opts = {})
2426
+ data, _status_code, _headers = put_sfvb_menu_with_http_info(storefront_oid, code, menu_write_request, opts)
2427
+ data
2428
+ end
2429
+
2430
+ # Replace a store menu&#39;s entries
2431
+ # A whole menu replace, not a merge - what you send is what the menu holds afterwards, so read it, change the tree and send it back. Omitting items changes only the title; sending an empty array empties the menu. Writing a code that does not exist creates it. Every entry is checked before any of it is written, including that a merchant_item_id and a page_path actually resolve, so a tree with one bad entry changes nothing. Always needs sfvb_publish, because a menu is shared by every theme and there is no dormant copy to change instead.
2432
+ # @param storefront_oid [Integer]
2433
+ # @param code [String] Menu code, matched without regard to case
2434
+ # @param menu_write_request [SfvbMenuWriteRequest] The menu&#39;s replacement contents
2435
+ # @param [Hash] opts the optional parameters
2436
+ # @option opts [String] :if_match Content hash from the last read. Required when the menu already exists; 428 when absent, 412 when stale.
2437
+ # @return [Array<(SfvbMenu, Integer, Hash)>] SfvbMenu data, response status code and response headers
2438
+ def put_sfvb_menu_with_http_info(storefront_oid, code, menu_write_request, opts = {})
2439
+ if @api_client.config.debugging
2440
+ @api_client.config.logger.debug 'Calling API: SfvbApi.put_sfvb_menu ...'
2441
+ end
2442
+ # verify the required parameter 'storefront_oid' is set
2443
+ if @api_client.config.client_side_validation && storefront_oid.nil?
2444
+ fail ArgumentError, "Missing the required parameter 'storefront_oid' when calling SfvbApi.put_sfvb_menu"
2445
+ end
2446
+ # verify the required parameter 'code' is set
2447
+ if @api_client.config.client_side_validation && code.nil?
2448
+ fail ArgumentError, "Missing the required parameter 'code' when calling SfvbApi.put_sfvb_menu"
2449
+ end
2450
+ # verify the required parameter 'menu_write_request' is set
2451
+ if @api_client.config.client_side_validation && menu_write_request.nil?
2452
+ fail ArgumentError, "Missing the required parameter 'menu_write_request' when calling SfvbApi.put_sfvb_menu"
2453
+ end
2454
+ # resource path
2455
+ local_var_path = '/sfvb/storefronts/{storefront_oid}/menus/{code}'.sub('{' + 'storefront_oid' + '}', CGI.escape(storefront_oid.to_s)).sub('{' + 'code' + '}', CGI.escape(code.to_s))
2456
+
2457
+ # query parameters
2458
+ query_params = opts[:query_params] || {}
2459
+
2460
+ # header parameters
2461
+ header_params = opts[:header_params] || {}
2462
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
2463
+ # HTTP header 'Accept' (if needed)
2464
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
2465
+ # HTTP header 'Content-Type'
2466
+ content_type = @api_client.select_header_content_type(['application/json'])
2467
+ if !content_type.nil?
2468
+ header_params['Content-Type'] = content_type
2469
+ end
2470
+ header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?
2471
+
2472
+ # form parameters
2473
+ form_params = opts[:form_params] || {}
2474
+
2475
+ # http body (model)
2476
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(menu_write_request)
2477
+
2478
+ # return_type
2479
+ return_type = opts[:debug_return_type] || 'SfvbMenu'
2480
+
2481
+ # auth_names
2482
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
2483
+
2484
+ new_options = opts.merge(
2485
+ :operation => :"SfvbApi.put_sfvb_menu",
2486
+ :header_params => header_params,
2487
+ :query_params => query_params,
2488
+ :form_params => form_params,
2489
+ :body => post_body,
2490
+ :auth_names => auth_names,
2491
+ :return_type => return_type
2492
+ )
2493
+
2494
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
2495
+ if @api_client.config.debugging
2496
+ @api_client.config.logger.debug "API called: SfvbApi#put_sfvb_menu\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
2497
+ end
2498
+ return data, status_code, headers
2499
+ end
2500
+
2212
2501
  # Change a page's attributes
2213
2502
  # A partial update. Only the attributes you name are changed. Every entry is checked before any is written. List, slider, item set, page collection and video list attributes are refused - edit those in the page editor. Always needs sfvb_publish, because a page's attributes are shared by every theme and there is no dormant copy to change instead.
2214
2503
  # @param storefront_oid [Integer]
@@ -0,0 +1,282 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class SfvbMenu
18
+ # The menu's code, which is the value a menu element's menuName refers to. Compare case insensitively.
19
+ attr_accessor :code
20
+
21
+ # Content hash of the menu as stored. Send it back as If-Match when writing.
22
+ attr_accessor :hash_sha256
23
+
24
+ # How many entries the menu holds in total, counting every level of the tree.
25
+ attr_accessor :item_count
26
+
27
+ # The menu's entries, in the order they render. Omitted from the list endpoint, which returns each menu's identity and counts only.
28
+ attr_accessor :items
29
+
30
+ # The menu's own label, shown in the store admin rather than on the storefront. Trimmed to 250 characters.
31
+ attr_accessor :title
32
+
33
+ # True when a template names this code but no menu has been created for it. Such a code renders an empty list today. Write it to create it.
34
+ attr_accessor :unconfigured
35
+
36
+ # True when no template on the storefront names this code. The menu is stored and editable, but nothing renders it, which usually means a menu element's menuName is misspelled.
37
+ attr_accessor :undeclared
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'code' => :'code',
43
+ :'hash_sha256' => :'hash_sha256',
44
+ :'item_count' => :'item_count',
45
+ :'items' => :'items',
46
+ :'title' => :'title',
47
+ :'unconfigured' => :'unconfigured',
48
+ :'undeclared' => :'undeclared'
49
+ }
50
+ end
51
+
52
+ # Returns all the JSON keys this model knows about
53
+ def self.acceptable_attributes
54
+ attribute_map.values
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'code' => :'String',
61
+ :'hash_sha256' => :'String',
62
+ :'item_count' => :'Integer',
63
+ :'items' => :'Array<SfvbMenuItem>',
64
+ :'title' => :'String',
65
+ :'unconfigured' => :'Boolean',
66
+ :'undeclared' => :'Boolean'
67
+ }
68
+ end
69
+
70
+ # List of attributes with nullable: true
71
+ def self.openapi_nullable
72
+ Set.new([
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbMenu` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbMenu`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
90
+
91
+ if attributes.key?(:'code')
92
+ self.code = attributes[:'code']
93
+ end
94
+
95
+ if attributes.key?(:'hash_sha256')
96
+ self.hash_sha256 = attributes[:'hash_sha256']
97
+ end
98
+
99
+ if attributes.key?(:'item_count')
100
+ self.item_count = attributes[:'item_count']
101
+ end
102
+
103
+ if attributes.key?(:'items')
104
+ if (value = attributes[:'items']).is_a?(Array)
105
+ self.items = value
106
+ end
107
+ end
108
+
109
+ if attributes.key?(:'title')
110
+ self.title = attributes[:'title']
111
+ end
112
+
113
+ if attributes.key?(:'unconfigured')
114
+ self.unconfigured = attributes[:'unconfigured']
115
+ end
116
+
117
+ if attributes.key?(:'undeclared')
118
+ self.undeclared = attributes[:'undeclared']
119
+ end
120
+ end
121
+
122
+ # Show invalid properties with the reasons. Usually used together with valid?
123
+ # @return Array for valid properties with the reasons
124
+ def list_invalid_properties
125
+ invalid_properties = Array.new
126
+ invalid_properties
127
+ end
128
+
129
+ # Check to see if the all the properties in the model are valid
130
+ # @return true if the model is valid
131
+ def valid?
132
+ true
133
+ end
134
+
135
+ # Checks equality by comparing each attribute.
136
+ # @param [Object] Object to be compared
137
+ def ==(o)
138
+ return true if self.equal?(o)
139
+ self.class == o.class &&
140
+ code == o.code &&
141
+ hash_sha256 == o.hash_sha256 &&
142
+ item_count == o.item_count &&
143
+ items == o.items &&
144
+ title == o.title &&
145
+ unconfigured == o.unconfigured &&
146
+ undeclared == o.undeclared
147
+ end
148
+
149
+ # @see the `==` method
150
+ # @param [Object] Object to be compared
151
+ def eql?(o)
152
+ self == o
153
+ end
154
+
155
+ # Calculates hash code according to all attributes.
156
+ # @return [Integer] Hash code
157
+ def hash
158
+ [code, hash_sha256, item_count, items, title, unconfigured, undeclared].hash
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def self.build_from_hash(attributes)
165
+ new.build_from_hash(attributes)
166
+ end
167
+
168
+ # Builds the object from hash
169
+ # @param [Hash] attributes Model attributes in the form of hash
170
+ # @return [Object] Returns the model itself
171
+ def build_from_hash(attributes)
172
+ return nil unless attributes.is_a?(Hash)
173
+ attributes = attributes.transform_keys(&:to_sym)
174
+ self.class.openapi_types.each_pair do |key, type|
175
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
176
+ self.send("#{key}=", nil)
177
+ elsif type =~ /\AArray<(.*)>/i
178
+ # check to ensure the input is an array given that the attribute
179
+ # is documented as an array but the input is not
180
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
181
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
182
+ end
183
+ elsif !attributes[self.class.attribute_map[key]].nil?
184
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
185
+ end
186
+ end
187
+
188
+ self
189
+ end
190
+
191
+ # Deserializes the data based on type
192
+ # @param string type Data type
193
+ # @param string value Value to be deserialized
194
+ # @return [Object] Deserialized data
195
+ def _deserialize(type, value)
196
+ case type.to_sym
197
+ when :Time
198
+ Time.parse(value)
199
+ when :Date
200
+ Date.parse(value)
201
+ when :String
202
+ value.to_s
203
+ when :Integer
204
+ value.to_i
205
+ when :Float
206
+ value.to_f
207
+ when :Boolean
208
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
209
+ true
210
+ else
211
+ false
212
+ end
213
+ when :Object
214
+ # generic object (usually a Hash), return directly
215
+ value
216
+ when /\AArray<(?<inner_type>.+)>\z/
217
+ inner_type = Regexp.last_match[:inner_type]
218
+ value.map { |v| _deserialize(inner_type, v) }
219
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
220
+ k_type = Regexp.last_match[:k_type]
221
+ v_type = Regexp.last_match[:v_type]
222
+ {}.tap do |hash|
223
+ value.each do |k, v|
224
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
225
+ end
226
+ end
227
+ else # model
228
+ # models (e.g. Pet) or oneOf
229
+ klass = UltracartClient.const_get(type)
230
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
231
+ end
232
+ end
233
+
234
+ # Returns the string representation of the object
235
+ # @return [String] String presentation of the object
236
+ def to_s
237
+ to_hash.to_s
238
+ end
239
+
240
+ # to_body is an alias to to_hash (backward compatibility)
241
+ # @return [Hash] Returns the object in the form of hash
242
+ def to_body
243
+ to_hash
244
+ end
245
+
246
+ # Returns the object in the form of hash
247
+ # @return [Hash] Returns the object in the form of hash
248
+ def to_hash
249
+ hash = {}
250
+ self.class.attribute_map.each_pair do |attr, param|
251
+ value = self.send(attr)
252
+ if value.nil?
253
+ is_nullable = self.class.openapi_nullable.include?(attr)
254
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
255
+ end
256
+
257
+ hash[param] = _to_hash(value)
258
+ end
259
+ hash
260
+ end
261
+
262
+ # Outputs non-array value in the form of hash
263
+ # For object, use to_hash. Otherwise, just return the value
264
+ # @param [Object] value Any valid value
265
+ # @return [Hash] Returns the value in the form of hash
266
+ def _to_hash(value)
267
+ if value.is_a?(Array)
268
+ value.compact.map { |v| _to_hash(v) }
269
+ elsif value.is_a?(Hash)
270
+ {}.tap do |hash|
271
+ value.each { |k, v| hash[k] = _to_hash(v) }
272
+ end
273
+ elsif value.respond_to? :to_hash
274
+ value.to_hash
275
+ else
276
+ value
277
+ end
278
+ end
279
+
280
+ end
281
+
282
+ end