ultracart_api 4.1.155 → 4.1.157

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.
@@ -673,7 +673,7 @@ module UltracartClient
673
673
  end
674
674
 
675
675
  # Read a container stored outside the file system
676
- # owner_type is one of upsell, email, postcardfront, postcardback or item. Item containers also require container_name. Theme and page containers are files; read those through files/content.
676
+ # owner_type is one of upsell, email, postcardfront, postcardback, item or itemid. It also says how owner_object_id is read - item and upsell take an oid, itemid takes a merchant item id, and the rest take an esp uuid. itemid reaches the same containers as item and is the way to address one from a storefront, where data-context-item-id carries the merchant item id and the oid appears nowhere. Item containers also require container_name. Theme and page containers are files; read those through files/content.
677
677
  # @param storefront_oid [Integer]
678
678
  # @param owner_type [String]
679
679
  # @param owner_object_id [String]
@@ -686,7 +686,7 @@ module UltracartClient
686
686
  end
687
687
 
688
688
  # Read a container stored outside the file system
689
- # owner_type is one of upsell, email, postcardfront, postcardback or item. Item containers also require container_name. Theme and page containers are files; read those through files/content.
689
+ # owner_type is one of upsell, email, postcardfront, postcardback, item or itemid. It also says how owner_object_id is read - item and upsell take an oid, itemid takes a merchant item id, and the rest take an esp uuid. itemid reaches the same containers as item and is the way to address one from a storefront, where data-context-item-id carries the merchant item id and the oid appears nowhere. Item containers also require container_name. Theme and page containers are files; read those through files/content.
690
690
  # @param storefront_oid [Integer]
691
691
  # @param owner_type [String]
692
692
  # @param owner_object_id [String]
@@ -752,7 +752,7 @@ module UltracartClient
752
752
  end
753
753
 
754
754
  # Read the CJSON stored in one container history entry
755
- # Inspect or diff an earlier version without reverting to it. The version is addressed through the container that owns it, so a history oid belonging to some other resource cannot be read through this route.
755
+ # Inspect or diff an earlier version without reverting to it. The version is addressed through the container that owns it, so a history oid belonging to some other resource cannot be read through this route. owner_type also says how owner_object_id is read, and itemid addresses an item container by merchant item id.
756
756
  # @param storefront_oid [Integer]
757
757
  # @param container_history_oid [Integer]
758
758
  # @param [Hash] opts the optional parameters
@@ -766,7 +766,7 @@ module UltracartClient
766
766
  end
767
767
 
768
768
  # Read the CJSON stored in one container history entry
769
- # Inspect or diff an earlier version without reverting to it. The version is addressed through the container that owns it, so a history oid belonging to some other resource cannot be read through this route.
769
+ # Inspect or diff an earlier version without reverting to it. The version is addressed through the container that owns it, so a history oid belonging to some other resource cannot be read through this route. owner_type also says how owner_object_id is read, and itemid addresses an item container by merchant item id.
770
770
  # @param storefront_oid [Integer]
771
771
  # @param container_history_oid [Integer]
772
772
  # @param [Hash] opts the optional parameters
@@ -1104,6 +1104,140 @@ module UltracartClient
1104
1104
  return data, status_code, headers
1105
1105
  end
1106
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
+
1107
1241
  # Read a page's attributes and images
1108
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.
1109
1243
  # @param storefront_oid [Integer]
@@ -1643,6 +1777,7 @@ module UltracartClient
1643
1777
  end
1644
1778
 
1645
1779
  # Version history for a container stored outside the file system
1780
+ # Addressed the same way as the container itself, so owner_type also says how owner_object_id is read and itemid lists the history of the item container that merchant item id names.
1646
1781
  # @param storefront_oid [Integer]
1647
1782
  # @param [Hash] opts the optional parameters
1648
1783
  # @option opts [String] :owner_type
@@ -1655,6 +1790,7 @@ module UltracartClient
1655
1790
  end
1656
1791
 
1657
1792
  # Version history for a container stored outside the file system
1793
+ # Addressed the same way as the container itself, so owner_type also says how owner_object_id is read and itemid lists the history of the item container that merchant item id names.
1658
1794
  # @param storefront_oid [Integer]
1659
1795
  # @param [Hash] opts the optional parameters
1660
1796
  # @option opts [String] :owner_type
@@ -2099,7 +2235,7 @@ module UltracartClient
2099
2235
  end
2100
2236
 
2101
2237
  # Write a container stored outside the file system
2102
- # Validation is mandatory and runs here regardless of whether the caller validated first. The previous value is snapshotted before the write, so the change can be reverted. Side effects the visual builder performs on save, such as upsell screenshot regeneration and email content review flagging, are applied too.
2238
+ # Validation is mandatory and runs here regardless of whether the caller validated first. The previous value is snapshotted before the write, so the change can be reverted. Side effects the visual builder performs on save, such as upsell screenshot regeneration and email content review flagging, are applied too. owner_type also says how owner_object_id is read; send itemid to address an item container by merchant item id rather than by oid. Either way the history records the one canonical address, so a container written under one spelling is listed and reverted under the other.
2103
2239
  # @param storefront_oid [Integer]
2104
2240
  # @param owner_type [String]
2105
2241
  # @param owner_object_id [String]
@@ -2114,7 +2250,7 @@ module UltracartClient
2114
2250
  end
2115
2251
 
2116
2252
  # Write a container stored outside the file system
2117
- # Validation is mandatory and runs here regardless of whether the caller validated first. The previous value is snapshotted before the write, so the change can be reverted. Side effects the visual builder performs on save, such as upsell screenshot regeneration and email content review flagging, are applied too.
2253
+ # Validation is mandatory and runs here regardless of whether the caller validated first. The previous value is snapshotted before the write, so the change can be reverted. Side effects the visual builder performs on save, such as upsell screenshot regeneration and email content review flagging, are applied too. owner_type also says how owner_object_id is read; send itemid to address an item container by merchant item id rather than by oid. Either way the history records the one canonical address, so a container written under one spelling is listed and reverted under the other.
2118
2254
  # @param storefront_oid [Integer]
2119
2255
  # @param owner_type [String]
2120
2256
  # @param owner_object_id [String]
@@ -2280,6 +2416,90 @@ module UltracartClient
2280
2416
  return data, status_code, headers
2281
2417
  end
2282
2418
 
2419
+ # Replace a store menu's entries
2420
+ # 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.
2421
+ # @param storefront_oid [Integer]
2422
+ # @param code [String] Menu code, matched without regard to case
2423
+ # @param menu_write_request [SfvbMenuWriteRequest] The menu&#39;s replacement contents
2424
+ # @param [Hash] opts the optional parameters
2425
+ # @option opts [String] :if_match Content hash from the last read. Required when the menu already exists; 428 when absent, 412 when stale.
2426
+ # @return [SfvbMenu]
2427
+ def put_sfvb_menu(storefront_oid, code, menu_write_request, opts = {})
2428
+ data, _status_code, _headers = put_sfvb_menu_with_http_info(storefront_oid, code, menu_write_request, opts)
2429
+ data
2430
+ end
2431
+
2432
+ # Replace a store menu&#39;s entries
2433
+ # 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.
2434
+ # @param storefront_oid [Integer]
2435
+ # @param code [String] Menu code, matched without regard to case
2436
+ # @param menu_write_request [SfvbMenuWriteRequest] The menu&#39;s replacement contents
2437
+ # @param [Hash] opts the optional parameters
2438
+ # @option opts [String] :if_match Content hash from the last read. Required when the menu already exists; 428 when absent, 412 when stale.
2439
+ # @return [Array<(SfvbMenu, Integer, Hash)>] SfvbMenu data, response status code and response headers
2440
+ def put_sfvb_menu_with_http_info(storefront_oid, code, menu_write_request, opts = {})
2441
+ if @api_client.config.debugging
2442
+ @api_client.config.logger.debug 'Calling API: SfvbApi.put_sfvb_menu ...'
2443
+ end
2444
+ # verify the required parameter 'storefront_oid' is set
2445
+ if @api_client.config.client_side_validation && storefront_oid.nil?
2446
+ fail ArgumentError, "Missing the required parameter 'storefront_oid' when calling SfvbApi.put_sfvb_menu"
2447
+ end
2448
+ # verify the required parameter 'code' is set
2449
+ if @api_client.config.client_side_validation && code.nil?
2450
+ fail ArgumentError, "Missing the required parameter 'code' when calling SfvbApi.put_sfvb_menu"
2451
+ end
2452
+ # verify the required parameter 'menu_write_request' is set
2453
+ if @api_client.config.client_side_validation && menu_write_request.nil?
2454
+ fail ArgumentError, "Missing the required parameter 'menu_write_request' when calling SfvbApi.put_sfvb_menu"
2455
+ end
2456
+ # resource path
2457
+ 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))
2458
+
2459
+ # query parameters
2460
+ query_params = opts[:query_params] || {}
2461
+
2462
+ # header parameters
2463
+ header_params = opts[:header_params] || {}
2464
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
2465
+ # HTTP header 'Accept' (if needed)
2466
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
2467
+ # HTTP header 'Content-Type'
2468
+ content_type = @api_client.select_header_content_type(['application/json'])
2469
+ if !content_type.nil?
2470
+ header_params['Content-Type'] = content_type
2471
+ end
2472
+ header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?
2473
+
2474
+ # form parameters
2475
+ form_params = opts[:form_params] || {}
2476
+
2477
+ # http body (model)
2478
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(menu_write_request)
2479
+
2480
+ # return_type
2481
+ return_type = opts[:debug_return_type] || 'SfvbMenu'
2482
+
2483
+ # auth_names
2484
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
2485
+
2486
+ new_options = opts.merge(
2487
+ :operation => :"SfvbApi.put_sfvb_menu",
2488
+ :header_params => header_params,
2489
+ :query_params => query_params,
2490
+ :form_params => form_params,
2491
+ :body => post_body,
2492
+ :auth_names => auth_names,
2493
+ :return_type => return_type
2494
+ )
2495
+
2496
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
2497
+ if @api_client.config.debugging
2498
+ @api_client.config.logger.debug "API called: SfvbApi#put_sfvb_menu\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
2499
+ end
2500
+ return data, status_code, headers
2501
+ end
2502
+
2283
2503
  # Change a page's attributes
2284
2504
  # 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.
2285
2505
  # @param storefront_oid [Integer]
@@ -2758,7 +2978,7 @@ module UltracartClient
2758
2978
  end
2759
2979
 
2760
2980
  # Revert a container stored outside the file system
2761
- # The restore is itself snapshotted, so a revert can be undone in turn. Reverting to an entry recorded before the container existed removes it again. Addressed through the owning container and guarded by If-Match, because a revert overwrites live content just as much as an ordinary write does.
2981
+ # The restore is itself snapshotted, so a revert can be undone in turn. Reverting to an entry recorded before the container existed removes it again. Addressed through the owning container and guarded by If-Match, because a revert overwrites live content just as much as an ordinary write does. owner_type also says how owner_object_id is read, so a version written by oid can be reverted by merchant item id and the other way round.
2762
2982
  # @param storefront_oid [Integer]
2763
2983
  # @param owner_type [String]
2764
2984
  # @param owner_object_id [String]
@@ -2773,7 +2993,7 @@ module UltracartClient
2773
2993
  end
2774
2994
 
2775
2995
  # Revert a container stored outside the file system
2776
- # The restore is itself snapshotted, so a revert can be undone in turn. Reverting to an entry recorded before the container existed removes it again. Addressed through the owning container and guarded by If-Match, because a revert overwrites live content just as much as an ordinary write does.
2996
+ # The restore is itself snapshotted, so a revert can be undone in turn. Reverting to an entry recorded before the container existed removes it again. Addressed through the owning container and guarded by If-Match, because a revert overwrites live content just as much as an ordinary write does. owner_type also says how owner_object_id is read, so a version written by oid can be reverted by merchant item id and the other way round.
2777
2997
  # @param storefront_oid [Integer]
2778
2998
  # @param owner_type [String]
2779
2999
  # @param owner_object_id [String]
@@ -27,6 +27,9 @@ module UltracartClient
27
27
  # When the container was last modified, in the store's own record of it. Every owner type reports this. It is absent only when the container has never been written since the store began recording it, so treat an absent value as unknown rather than as never modified. Two behaviours worth knowing. A postcard keeps one timestamp for both of its sides, so writing the front moves the value the back reports. An upsell container that is rewritten with byte identical content keeps its original date rather than moving to now, because the timestamp tracks changes to the container and not writes to the offer.
28
28
  attr_accessor :last_modified
29
29
 
30
+ # The merchant item id of the owning item, for item containers only and absent for every other owner type. owner_object_id is the item oid, which appears nowhere on a rendered storefront, so this is how a caller confirms which item an oid actually reached. It is read fresh on every call and so reflects a renamed item. A container's own id embeds this value, which is what a preview session keys an item container on.
31
+ attr_accessor :merchant_item_id
32
+
30
33
  # Identifier of the owning object within its store.
31
34
  attr_accessor :owner_object_id
32
35
 
@@ -62,6 +65,7 @@ module UltracartClient
62
65
  :'container_name' => :'container_name',
63
66
  :'hash_sha256' => :'hash_sha256',
64
67
  :'last_modified' => :'last_modified',
68
+ :'merchant_item_id' => :'merchant_item_id',
65
69
  :'owner_object_id' => :'owner_object_id',
66
70
  :'owner_type' => :'owner_type'
67
71
  }
@@ -79,6 +83,7 @@ module UltracartClient
79
83
  :'container_name' => :'String',
80
84
  :'hash_sha256' => :'String',
81
85
  :'last_modified' => :'String',
86
+ :'merchant_item_id' => :'String',
82
87
  :'owner_object_id' => :'String',
83
88
  :'owner_type' => :'String'
84
89
  }
@@ -121,6 +126,10 @@ module UltracartClient
121
126
  self.last_modified = attributes[:'last_modified']
122
127
  end
123
128
 
129
+ if attributes.key?(:'merchant_item_id')
130
+ self.merchant_item_id = attributes[:'merchant_item_id']
131
+ end
132
+
124
133
  if attributes.key?(:'owner_object_id')
125
134
  self.owner_object_id = attributes[:'owner_object_id']
126
135
  end
@@ -164,6 +173,7 @@ module UltracartClient
164
173
  container_name == o.container_name &&
165
174
  hash_sha256 == o.hash_sha256 &&
166
175
  last_modified == o.last_modified &&
176
+ merchant_item_id == o.merchant_item_id &&
167
177
  owner_object_id == o.owner_object_id &&
168
178
  owner_type == o.owner_type
169
179
  end
@@ -177,7 +187,7 @@ module UltracartClient
177
187
  # Calculates hash code according to all attributes.
178
188
  # @return [Integer] Hash code
179
189
  def hash
180
- [cjson, container_name, hash_sha256, last_modified, owner_object_id, owner_type].hash
190
+ [cjson, container_name, hash_sha256, last_modified, merchant_item_id, owner_object_id, owner_type].hash
181
191
  end
182
192
 
183
193
  # Builds the object from hash
@@ -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