bigcommerce-oauth-api 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75787d5311705ef1dc2959615900806588650813
4
- data.tar.gz: 0220bf99f82590445b75d1c7486663c24186bbab
3
+ metadata.gz: a484aad29a21d82ebb61dc10ad1051c174af5e64
4
+ data.tar.gz: 84be7bae67c690f8f40e735af3862c1a9dfab2e1
5
5
  SHA512:
6
- metadata.gz: b93b0f562c53505273ae9d3057385ffee21090d920032c38f6fed8ac46e476c6d12ece7cd0b73153dd597eba72a40e050ab3cc8dd36c0290d68a390401cfd2a9
7
- data.tar.gz: 0c84e1610a355f2e09e2318e1c8d069016725a2ae99ece2c65ba20864d2407c9de4b23d1e335e8f89e4875a5b26f0d5e248da940bea795bef13fd1cec535d4b1
6
+ metadata.gz: 3508631521b911e5b7956bdd5cbe1387551b036348b09f6209ad5de061b86e0cbed6a24e422ddb0ddeee56186cb8e1de5a29ad0a445086c022837ca0a13b5010
7
+ data.tar.gz: 6ca92909b5b6cd1edc34bd9f98e11e5073490c4739f0d7412971e960f13a9988de4031e8ef234d084a61190ea8e5a439a74aa670640dbc51d45c1badd6600dde
@@ -1,3 +1,21 @@
1
+ ### 1.4.0 (2016-10-09)
2
+
3
+ Features:
4
+
5
+ - added banner apis
6
+ - added gift certificate apis
7
+ - enable BigcommerceOAuthAPI::Resource to set attributes through methods (ex. resource.attribute_name = 'abc')
8
+ - add .to_h method on BigcommerceOAuthAPI::Error. This method will parse the json error message and return it as a hash.
9
+
10
+ Bugfixes:
11
+
12
+ - enable BigcommerceOAuthAPI::Resource to convert array attributes to arrays of BigcommerceOAuthAPI::Resource.
13
+
14
+ Deprecation warnings added:
15
+
16
+ - config.if_modified_since will be removed in v2.0.0
17
+ - config.format will be removed in v2.0.0
18
+
1
19
  ### 1.3.2 (2016-01-14)
2
20
 
3
21
  Bugfixes:
data/README.md CHANGED
@@ -23,14 +23,14 @@ Configuration
23
23
  The gem can be configured either by module or class configuration. Starting from v1.2.0 `bigcommerce-oauth-api` supports both OAuth and legacy authentication.
24
24
  ```
25
25
  # module oauth configuration
26
- BigcommerceOAuthAPI.configuration do |config|
26
+ BigcommerceOAuthAPI.configure do |config|
27
27
  config.store_hash = 'YOU STORE ID'
28
28
  config.client_id = 'YOUR CLIENT ID'
29
29
  config.access_token = 'YOUR OAUTH ACCESS TOKEN'
30
30
  end
31
31
 
32
32
  # module legacy (basic auth) configuration
33
- BigcommerceOAuthAPI.configuration do |config|
33
+ BigcommerceOAuthAPI.configure do |config|
34
34
  config.endpoint = 'YOU STORE URL (https://store-XYZ.mybigcommerce.com)'
35
35
  config.user_name = 'API USER NAME'
36
36
  config.api_key = 'API KEY'
@@ -132,7 +132,9 @@ customer address | 1.0.2 | https://developer.bigcommerce.com/api/stores/v2/custo
132
132
  customer group | 1.0.2 | https://developer.bigcommerce.com/api/stores/v2/customer_groups
133
133
  geography country | 1.0.2 | https://developer.bigcommerce.com/api/stores/v2/countries
134
134
  geography state | 1.0.2 | https://developer.bigcommerce.com/api/stores/v2/countries/states
135
+ marketing banner | 1.4.0 | https://developer.bigcommerce.com/api/stores/v2/banners
135
136
  marketing coupon | 1.0.2 | https://developer.bigcommerce.com/api/stores/v2/coupons
137
+ marketing gift certificate | 1.4.0 | https://developer.bigcommerce.com/api/stores/v2/gift_certificates
136
138
  option | 1.1.0 | https://developer.bigcommerce.com/api/stores/v2/options
137
139
  option set | 1.1.0 | https://developer.bigcommerce.com/api/stores/v2/option_sets
138
140
  option set option | 1.1.0 | https://developer.bigcommerce.com/api/stores/v2/option_sets/options
@@ -3,7 +3,7 @@ require File.expand_path('../lib/bigcommerce-oauth-api/version', __FILE__)
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'bigcommerce-oauth-api'
5
5
  s.version = BigcommerceOAuthAPI::VERSION.dup
6
- s.date = '2016-01-14'
6
+ s.date = '2016-10-09'
7
7
  s.summary = "Ruby client library for Bigcommerce APIs with OAuth and basic authentication support"
8
8
  s.description = "Connect Ruby applications to Bigcommerce APIs through OAuth or basic authentication"
9
9
  s.authors = ["Christian Orthmann"]
@@ -8,6 +8,8 @@ module BigcommerceOAuthAPI
8
8
 
9
9
  def initialize(options = {})
10
10
  merged_options = BigcommerceOAuthAPI.options.merge(options)
11
+ warn "[DEPRECATION] bigcommerce-oauth-api: 'config.format' will be removed in v2.0.0" unless merged_options[:format] == :json
12
+ warn "[DEPRECATION] bigcommerce-oauth-api: 'config.if_modified_since' will be removed in v2.0.0" unless merged_options[:if_modified_since].nil?
11
13
 
12
14
  Configuration::VALID_OPTIONS_KEYS.each do |key|
13
15
  send("#{key}=", merged_options[key])
@@ -30,7 +30,9 @@ module BigcommerceOAuthAPI
30
30
  :customer_group => { api_module: :customer_group, scope: :self, methods: [:all, :select, :create, :update, :delete]},
31
31
  :geography_country => { api_module: :country, scope: :self, methods: [:all, :select, :count]},
32
32
  :geography_state => { api_module: :state, scope: :country, methods: [:all, :select, :count]},
33
+ :marketing_banner => { api_module: :banner, scope: :self, methods: [:all, :select, :create, :update, :delete]},
33
34
  :marketing_coupons => { api_module: :coupon, scope: :self, methods: [:all, :select, :create, :update, :delete, :count]},
35
+ :marketing_gift_certificate => { api_module: :gift_certificate, scope: :self, methods: [:all, :select, :create, :update, :delete]},
34
36
  :option => { api_module: :option, scope: :self, methods: [:all, :select, :create, :update, :delete, :count]},
35
37
  :option_set => { api_module: :option_set, scope: :self, methods: [:all, :select, :create, :update, :delete, :count]},
36
38
  :option_set_option => { api_module: :option, scope: :option_set, methods: [:all, :select, :create, :update, :delete]},
@@ -74,7 +76,7 @@ module BigcommerceOAuthAPI
74
76
  # @!method update_blog_post(id, options = {})
75
77
  # @param [Integer] id the identifier for the post
76
78
  # @param [Hash] options the attributes for the post
77
- # update the attributes of the post with the given id
79
+ # updates the attributes of the post with the given id
78
80
 
79
81
  # @!method delete_blog_post(id)
80
82
  # @param [Integer] id the identifier for the post
@@ -99,7 +101,7 @@ module BigcommerceOAuthAPI
99
101
  # @!method update_brand(id, options = {})
100
102
  # @param [Integer] id the identifier for the brand
101
103
  # @param [Hash] options the attributes for the brand
102
- # update the attributes of the brand with the given id
104
+ # updates the attributes of the brand with the given id
103
105
 
104
106
  # @!method delete_brand(id)
105
107
  # @param [Integer] id the identifier for the brand
@@ -124,7 +126,7 @@ module BigcommerceOAuthAPI
124
126
  # @!method update_category(id, options = {})
125
127
  # @param [Integer] id the identifier for the category
126
128
  # @param [Hash] options the attributes for the category
127
- # update the attributes of the category with the given id
129
+ # updates the attributes of the category with the given id
128
130
 
129
131
  # @!method delete_category(id)
130
132
  # @param [Integer] id the identifier for the category
@@ -145,7 +147,7 @@ module BigcommerceOAuthAPI
145
147
  # @!method update_customer(id, options = {})
146
148
  # @param [Integer] id the identifier for the customer
147
149
  # @param [Hash] options the attributes for the customer
148
- # update the attributes of the customer with the given id
150
+ # updates the attributes of the customer with the given id
149
151
 
150
152
  # @!method delete_customer(id)
151
153
  # @param [Integer] id the identifier for the customer
@@ -161,8 +163,8 @@ module BigcommerceOAuthAPI
161
163
  # gets a list of addresses for the given customer
162
164
 
163
165
  # @!method customer_address(customer_id, id, options = {})
164
- # @param [Integer] id the identifier for the address
165
166
  # @param [Integer] customer_id the identifier for the customer
167
+ # @param [Integer] id the identifier for the address
166
168
  # gets the address with the given id for the given customer
167
169
 
168
170
  # @!method create_customer_address(customer_id, options = {})
@@ -171,14 +173,14 @@ module BigcommerceOAuthAPI
171
173
  # creates a address with the given attributes for the given customer
172
174
 
173
175
  # @!method update_customer_address(customer_id, id, options = {})
174
- # @param [Integer] id the identifier for the address
175
176
  # @param [Integer] customer_id the identifier for the customer
177
+ # @param [Integer] id the identifier for the address
176
178
  # @param [Hash] options the attributes for the address
177
- # update the attributes of the address with the given id for the given customer
179
+ # updates the attributes of the address with the given id for the given customer
178
180
 
179
181
  # @!method delete_customer_address(customer_id, id)
180
- # @param [Integer] id the identifier for the address
181
182
  # @param [Integer] customer_id the identifier for the customer
183
+ # @param [Integer] id the identifier for the address
182
184
  # deletes the address with the given id for the given customer
183
185
 
184
186
  # @!method customer_groups(options = {})
@@ -196,7 +198,7 @@ module BigcommerceOAuthAPI
196
198
  # @!method update_customer_group(id, options = {})
197
199
  # @param [Integer] id the identifier for the customer_group
198
200
  # @param [Hash] options the attributes for the customer_group
199
- # update the attributes of the customer_group with the given id
201
+ # updates the attributes of the customer_group with the given id
200
202
 
201
203
  # @!method delete_customer_group(id)
202
204
  # @param [Integer] id the identifier for the customer_group
@@ -220,8 +222,8 @@ module BigcommerceOAuthAPI
220
222
  # gets a list of states for the given country
221
223
 
222
224
  # @!method country_state(country_id, id, options = {})
223
- # @param [Integer] id the identifier for the state
224
225
  # @param [Integer] country_id the identifier for the country
226
+ # @param [Integer] id the identifier for the state
225
227
  # gets the state with the given id for the given country
226
228
 
227
229
  # @!method country_states_count(country_id, options = {})
@@ -229,6 +231,27 @@ module BigcommerceOAuthAPI
229
231
  # @param [Hash] options the filters for the states
230
232
  # returns the number of states for the given country
231
233
 
234
+ # @!method banners(options = {})
235
+ # @param [Hash] options the filters for the banners
236
+ # gets a list of banners
237
+
238
+ # @!method banner(id, options = {})
239
+ # @param [Integer] id the identifier for the banner
240
+ # gets the banner with the given id
241
+
242
+ # @!method create_banner(options = {})
243
+ # @param [Hash] options the attributes for the banner
244
+ # creates a banner with the given attributes
245
+
246
+ # @!method update_banner(id, options = {})
247
+ # @param [Integer] id the identifier for the banner
248
+ # @param [Hash] options the attributes for the banner
249
+ # updates the attributes of the banner with the given id
250
+
251
+ # @!method delete_banner(id)
252
+ # @param [Integer] id the identifier for the banner
253
+ # deletes the banner with the given id
254
+
232
255
  # @!method coupons(options = {})
233
256
  # @param [Hash] options the filters for the coupons
234
257
  # gets a list of coupons
@@ -244,7 +267,7 @@ module BigcommerceOAuthAPI
244
267
  # @!method update_coupon(id, options = {})
245
268
  # @param [Integer] id the identifier for the coupon
246
269
  # @param [Hash] options the attributes for the coupon
247
- # update the attributes of the coupon with the given id
270
+ # updates the attributes of the coupon with the given id
248
271
 
249
272
  # @!method delete_coupon(id)
250
273
  # @param [Integer] id the identifier for the coupon
@@ -254,6 +277,27 @@ module BigcommerceOAuthAPI
254
277
  # @param [Hash] options the filters for the coupons
255
278
  # returns the number of coupons
256
279
 
280
+ # @!method gift_certificates(options = {})
281
+ # @param [Hash] options the filters for the gift_certificates
282
+ # gets a list of gift_certificates
283
+
284
+ # @!method gift_certificate(id, options = {})
285
+ # @param [Integer] id the identifier for the gift_certificate
286
+ # gets the gift_certificate with the given id
287
+
288
+ # @!method create_gift_certificate(options = {})
289
+ # @param [Hash] options the attributes for the gift_certificate
290
+ # creates a gift_certificate with the given attributes
291
+
292
+ # @!method update_gift_certificate(id, options = {})
293
+ # @param [Integer] id the identifier for the gift_certificate
294
+ # @param [Hash] options the attributes for the gift_certificate
295
+ # updates the attributes of the gift_certificate with the given id
296
+
297
+ # @!method delete_gift_certificate(id)
298
+ # @param [Integer] id the identifier for the gift_certificate
299
+ # deletes the gift_certificate with the given id
300
+
257
301
  # @!method options(options = {})
258
302
  # @param [Hash] options the filters for the options
259
303
  # gets a list of options
@@ -269,7 +313,7 @@ module BigcommerceOAuthAPI
269
313
  # @!method update_option(id, options = {})
270
314
  # @param [Integer] id the identifier for the option
271
315
  # @param [Hash] options the attributes for the option
272
- # update the attributes of the option with the given id
316
+ # updates the attributes of the option with the given id
273
317
 
274
318
  # @!method delete_option(id)
275
319
  # @param [Integer] id the identifier for the option
@@ -294,7 +338,7 @@ module BigcommerceOAuthAPI
294
338
  # @!method update_option_set(id, options = {})
295
339
  # @param [Integer] id the identifier for the option_set
296
340
  # @param [Hash] options the attributes for the option_set
297
- # update the attributes of the option_set with the given id
341
+ # updates the attributes of the option_set with the given id
298
342
 
299
343
  # @!method delete_option_set(id)
300
344
  # @param [Integer] id the identifier for the option_set
@@ -310,8 +354,8 @@ module BigcommerceOAuthAPI
310
354
  # gets a list of options for the given option_set
311
355
 
312
356
  # @!method option_set_option(option_set_id, id, options = {})
313
- # @param [Integer] id the identifier for the option
314
357
  # @param [Integer] option_set_id the identifier for the option_set
358
+ # @param [Integer] id the identifier for the option
315
359
  # gets the option with the given id for the given option_set
316
360
 
317
361
  # @!method create_option_set_option(option_set_id, options = {})
@@ -320,14 +364,14 @@ module BigcommerceOAuthAPI
320
364
  # creates a option with the given attributes for the given option_set
321
365
 
322
366
  # @!method update_option_set_option(option_set_id, id, options = {})
323
- # @param [Integer] id the identifier for the option
324
367
  # @param [Integer] option_set_id the identifier for the option_set
368
+ # @param [Integer] id the identifier for the option
325
369
  # @param [Hash] options the attributes for the option
326
- # update the attributes of the option with the given id for the given option_set
370
+ # updates the attributes of the option with the given id for the given option_set
327
371
 
328
372
  # @!method delete_option_set_option(option_set_id, id)
329
- # @param [Integer] id the identifier for the option
330
373
  # @param [Integer] option_set_id the identifier for the option_set
374
+ # @param [Integer] id the identifier for the option
331
375
  # deletes the option with the given id for the given option_set
332
376
 
333
377
  # @!method option_values(option_id, options = {})
@@ -336,8 +380,8 @@ module BigcommerceOAuthAPI
336
380
  # gets a list of values for the given option
337
381
 
338
382
  # @!method option_value(option_id, id, options = {})
339
- # @param [Integer] id the identifier for the value
340
383
  # @param [Integer] option_id the identifier for the option
384
+ # @param [Integer] id the identifier for the value
341
385
  # gets the value with the given id for the given option
342
386
 
343
387
  # @!method create_option_value(option_id, options = {})
@@ -346,14 +390,14 @@ module BigcommerceOAuthAPI
346
390
  # creates a value with the given attributes for the given option
347
391
 
348
392
  # @!method update_option_value(option_id, id, options = {})
349
- # @param [Integer] id the identifier for the value
350
393
  # @param [Integer] option_id the identifier for the option
394
+ # @param [Integer] id the identifier for the value
351
395
  # @param [Hash] options the attributes for the value
352
- # update the attributes of the value with the given id for the given option
396
+ # updates the attributes of the value with the given id for the given option
353
397
 
354
398
  # @!method delete_option_value(option_id, id)
355
- # @param [Integer] id the identifier for the value
356
399
  # @param [Integer] option_id the identifier for the option
400
+ # @param [Integer] id the identifier for the value
357
401
  # deletes the value with the given id for the given option
358
402
 
359
403
  # @!method order_statuses(options = {})
@@ -379,7 +423,7 @@ module BigcommerceOAuthAPI
379
423
  # @!method update_order(id, options = {})
380
424
  # @param [Integer] id the identifier for the order
381
425
  # @param [Hash] options the attributes for the order
382
- # update the attributes of the order with the given id
426
+ # updates the attributes of the order with the given id
383
427
 
384
428
  # @!method delete_order(id)
385
429
  # @param [Integer] id the identifier for the order
@@ -395,8 +439,8 @@ module BigcommerceOAuthAPI
395
439
  # gets a list of coupons for the given order
396
440
 
397
441
  # @!method order_coupon(order_id, id, options = {})
398
- # @param [Integer] id the identifier for the coupon
399
442
  # @param [Integer] order_id the identifier for the order
443
+ # @param [Integer] id the identifier for the coupon
400
444
  # gets the coupon with the given id for the given order
401
445
 
402
446
  # @!method order_messages(order_id, options = {})
@@ -405,8 +449,8 @@ module BigcommerceOAuthAPI
405
449
  # gets a list of messages for the given order
406
450
 
407
451
  # @!method order_message(order_id, id, options = {})
408
- # @param [Integer] id the identifier for the message
409
452
  # @param [Integer] order_id the identifier for the order
453
+ # @param [Integer] id the identifier for the message
410
454
  # gets the message with the given id for the given order
411
455
 
412
456
  # @!method order_products(order_id, options = {})
@@ -415,8 +459,8 @@ module BigcommerceOAuthAPI
415
459
  # gets a list of products for the given order
416
460
 
417
461
  # @!method order_product(order_id, id, options = {})
418
- # @param [Integer] id the identifier for the product
419
462
  # @param [Integer] order_id the identifier for the order
463
+ # @param [Integer] id the identifier for the product
420
464
  # gets the product with the given id for the given order
421
465
 
422
466
  # @!method order_products_count(order_id, options = {})
@@ -430,8 +474,8 @@ module BigcommerceOAuthAPI
430
474
  # gets a list of shipments for the given order
431
475
 
432
476
  # @!method order_shipment(order_id, id, options = {})
433
- # @param [Integer] id the identifier for the shipment
434
477
  # @param [Integer] order_id the identifier for the order
478
+ # @param [Integer] id the identifier for the shipment
435
479
  # gets the shipment with the given id for the given order
436
480
 
437
481
  # @!method create_order_shipment(order_id, options = {})
@@ -440,14 +484,14 @@ module BigcommerceOAuthAPI
440
484
  # creates a shipment with the given attributes for the given order
441
485
 
442
486
  # @!method update_order_shipment(order_id, id, options = {})
443
- # @param [Integer] id the identifier for the shipment
444
487
  # @param [Integer] order_id the identifier for the order
488
+ # @param [Integer] id the identifier for the shipment
445
489
  # @param [Hash] options the attributes for the shipment
446
- # update the attributes of the shipment with the given id for the given order
490
+ # updates the attributes of the shipment with the given id for the given order
447
491
 
448
492
  # @!method delete_order_shipment(order_id, id)
449
- # @param [Integer] id the identifier for the shipment
450
493
  # @param [Integer] order_id the identifier for the order
494
+ # @param [Integer] id the identifier for the shipment
451
495
  # deletes the shipment with the given id for the given order
452
496
 
453
497
  # @!method order_shipping_addresses(order_id, options = {})
@@ -456,8 +500,8 @@ module BigcommerceOAuthAPI
456
500
  # gets a list of shipping_addresses for the given order
457
501
 
458
502
  # @!method order_shipping_address(order_id, id, options = {})
459
- # @param [Integer] id the identifier for the shipping_address
460
503
  # @param [Integer] order_id the identifier for the order
504
+ # @param [Integer] id the identifier for the shipping_address
461
505
  # gets the shipping_address with the given id for the given order
462
506
 
463
507
  # @!method order_taxes(order_id, options = {})
@@ -466,8 +510,8 @@ module BigcommerceOAuthAPI
466
510
  # gets a list of taxes for the given order
467
511
 
468
512
  # @!method order_tax(order_id, id, options = {})
469
- # @param [Integer] id the identifier for the tax
470
513
  # @param [Integer] order_id the identifier for the order
514
+ # @param [Integer] id the identifier for the tax
471
515
  # gets the tax with the given id for the given order
472
516
 
473
517
  # @!method payment_methods(options = {})
@@ -489,7 +533,7 @@ module BigcommerceOAuthAPI
489
533
  # @!method update_product(id, options = {})
490
534
  # @param [Integer] id the identifier for the product
491
535
  # @param [Hash] options the attributes for the product
492
- # update the attributes of the product with the given id
536
+ # updates the attributes of the product with the given id
493
537
 
494
538
  # @!method delete_product(id)
495
539
  # @param [Integer] id the identifier for the product
@@ -505,8 +549,8 @@ module BigcommerceOAuthAPI
505
549
  # gets a list of custom_fields for the given product
506
550
 
507
551
  # @!method product_custom_field(product_id, id, options = {})
508
- # @param [Integer] id the identifier for the custom_field
509
552
  # @param [Integer] product_id the identifier for the product
553
+ # @param [Integer] id the identifier for the custom_field
510
554
  # gets the custom_field with the given id for the given product
511
555
 
512
556
  # @!method create_product_custom_field(product_id, options = {})
@@ -515,14 +559,14 @@ module BigcommerceOAuthAPI
515
559
  # creates a custom_field with the given attributes for the given product
516
560
 
517
561
  # @!method update_product_custom_field(product_id, id, options = {})
518
- # @param [Integer] id the identifier for the custom_field
519
562
  # @param [Integer] product_id the identifier for the product
563
+ # @param [Integer] id the identifier for the custom_field
520
564
  # @param [Hash] options the attributes for the custom_field
521
- # update the attributes of the custom_field with the given id for the given product
565
+ # updates the attributes of the custom_field with the given id for the given product
522
566
 
523
567
  # @!method delete_product_custom_field(product_id, id)
524
- # @param [Integer] id the identifier for the custom_field
525
568
  # @param [Integer] product_id the identifier for the product
569
+ # @param [Integer] id the identifier for the custom_field
526
570
  # deletes the custom_field with the given id for the given product
527
571
 
528
572
  # @!method product_discount_rules(product_id, options = {})
@@ -531,8 +575,8 @@ module BigcommerceOAuthAPI
531
575
  # gets a list of discount_rules for the given product
532
576
 
533
577
  # @!method product_discount_rule(product_id, id, options = {})
534
- # @param [Integer] id the identifier for the discount_rule
535
578
  # @param [Integer] product_id the identifier for the product
579
+ # @param [Integer] id the identifier for the discount_rule
536
580
  # gets the discount_rule with the given id for the given product
537
581
 
538
582
  # @!method create_product_discount_rule(product_id, options = {})
@@ -541,14 +585,14 @@ module BigcommerceOAuthAPI
541
585
  # creates a discount_rule with the given attributes for the given product
542
586
 
543
587
  # @!method update_product_discount_rule(product_id, id, options = {})
544
- # @param [Integer] id the identifier for the discount_rule
545
588
  # @param [Integer] product_id the identifier for the product
589
+ # @param [Integer] id the identifier for the discount_rule
546
590
  # @param [Hash] options the attributes for the discount_rule
547
- # update the attributes of the discount_rule with the given id for the given product
591
+ # updates the attributes of the discount_rule with the given id for the given product
548
592
 
549
593
  # @!method delete_product_discount_rule(product_id, id)
550
- # @param [Integer] id the identifier for the discount_rule
551
594
  # @param [Integer] product_id the identifier for the product
595
+ # @param [Integer] id the identifier for the discount_rule
552
596
  # deletes the discount_rule with the given id for the given product
553
597
 
554
598
  # @!method product_discount_rules_count(product_id, options = {})
@@ -562,13 +606,13 @@ module BigcommerceOAuthAPI
562
606
  # gets a list of configurable_fields for the given product
563
607
 
564
608
  # @!method product_configurable_field(product_id, id, options = {})
565
- # @param [Integer] id the identifier for the configurable_field
566
609
  # @param [Integer] product_id the identifier for the product
610
+ # @param [Integer] id the identifier for the configurable_field
567
611
  # gets the configurable_field with the given id for the given product
568
612
 
569
613
  # @!method delete_product_configurable_field(product_id, id)
570
- # @param [Integer] id the identifier for the configurable_field
571
614
  # @param [Integer] product_id the identifier for the product
615
+ # @param [Integer] id the identifier for the configurable_field
572
616
  # deletes the configurable_field with the given id for the given product
573
617
 
574
618
  # @!method product_configurable_fields_count(product_id, options = {})
@@ -582,8 +626,8 @@ module BigcommerceOAuthAPI
582
626
  # gets a list of images for the given product
583
627
 
584
628
  # @!method product_image(product_id, id, options = {})
585
- # @param [Integer] id the identifier for the image
586
629
  # @param [Integer] product_id the identifier for the product
630
+ # @param [Integer] id the identifier for the image
587
631
  # gets the image with the given id for the given product
588
632
 
589
633
  # @!method create_product_image(product_id, options = {})
@@ -592,14 +636,14 @@ module BigcommerceOAuthAPI
592
636
  # creates a image with the given attributes for the given product
593
637
 
594
638
  # @!method update_product_image(product_id, id, options = {})
595
- # @param [Integer] id the identifier for the image
596
639
  # @param [Integer] product_id the identifier for the product
640
+ # @param [Integer] id the identifier for the image
597
641
  # @param [Hash] options the attributes for the image
598
- # update the attributes of the image with the given id for the given product
642
+ # updates the attributes of the image with the given id for the given product
599
643
 
600
644
  # @!method delete_product_image(product_id, id)
601
- # @param [Integer] id the identifier for the image
602
645
  # @param [Integer] product_id the identifier for the product
646
+ # @param [Integer] id the identifier for the image
603
647
  # deletes the image with the given id for the given product
604
648
 
605
649
  # @!method product_images_count(product_id, options = {})
@@ -613,8 +657,8 @@ module BigcommerceOAuthAPI
613
657
  # gets a list of options for the given product
614
658
 
615
659
  # @!method product_option(product_id, id, options = {})
616
- # @param [Integer] id the identifier for the option
617
660
  # @param [Integer] product_id the identifier for the product
661
+ # @param [Integer] id the identifier for the option
618
662
  # gets the option with the given id for the given product
619
663
 
620
664
  # @!method product_reviews(product_id, options = {})
@@ -628,8 +672,8 @@ module BigcommerceOAuthAPI
628
672
  # gets a list of rules for the given product
629
673
 
630
674
  # @!method product_rule(product_id, id, options = {})
631
- # @param [Integer] id the identifier for the rule
632
675
  # @param [Integer] product_id the identifier for the product
676
+ # @param [Integer] id the identifier for the rule
633
677
  # gets the rule with the given id for the given product
634
678
 
635
679
  # @!method create_product_rule(product_id, options = {})
@@ -638,14 +682,14 @@ module BigcommerceOAuthAPI
638
682
  # creates a rule with the given attributes for the given product
639
683
 
640
684
  # @!method update_product_rule(product_id, id, options = {})
641
- # @param [Integer] id the identifier for the rule
642
685
  # @param [Integer] product_id the identifier for the product
686
+ # @param [Integer] id the identifier for the rule
643
687
  # @param [Hash] options the attributes for the rule
644
- # update the attributes of the rule with the given id for the given product
688
+ # updates the attributes of the rule with the given id for the given product
645
689
 
646
690
  # @!method delete_product_rule(product_id, id)
647
- # @param [Integer] id the identifier for the rule
648
691
  # @param [Integer] product_id the identifier for the product
692
+ # @param [Integer] id the identifier for the rule
649
693
  # deletes the rule with the given id for the given product
650
694
 
651
695
  # @!method product_rules_count(product_id, options = {})
@@ -659,8 +703,8 @@ module BigcommerceOAuthAPI
659
703
  # gets a list of videos for the given product
660
704
 
661
705
  # @!method product_video(product_id, id, options = {})
662
- # @param [Integer] id the identifier for the video
663
706
  # @param [Integer] product_id the identifier for the product
707
+ # @param [Integer] id the identifier for the video
664
708
  # gets the video with the given id for the given product
665
709
 
666
710
  # @!method create_product_video(product_id, options = {})
@@ -669,14 +713,14 @@ module BigcommerceOAuthAPI
669
713
  # creates a video with the given attributes for the given product
670
714
 
671
715
  # @!method update_product_video(product_id, id, options = {})
672
- # @param [Integer] id the identifier for the video
673
716
  # @param [Integer] product_id the identifier for the product
717
+ # @param [Integer] id the identifier for the video
674
718
  # @param [Hash] options the attributes for the video
675
- # update the attributes of the video with the given id for the given product
719
+ # updates the attributes of the video with the given id for the given product
676
720
 
677
721
  # @!method delete_product_video(product_id, id)
678
- # @param [Integer] id the identifier for the video
679
722
  # @param [Integer] product_id the identifier for the product
723
+ # @param [Integer] id the identifier for the video
680
724
  # deletes the video with the given id for the given product
681
725
 
682
726
  # @!method product_videos_count(product_id, options = {})
@@ -690,8 +734,8 @@ module BigcommerceOAuthAPI
690
734
  # gets a list of skus for the given product
691
735
 
692
736
  # @!method product_sku(product_id, id, options = {})
693
- # @param [Integer] id the identifier for the sku
694
737
  # @param [Integer] product_id the identifier for the product
738
+ # @param [Integer] id the identifier for the sku
695
739
  # gets the sku with the given id for the given product
696
740
 
697
741
  # @!method create_product_sku(product_id, options = {})
@@ -700,14 +744,14 @@ module BigcommerceOAuthAPI
700
744
  # creates a sku with the given attributes for the given product
701
745
 
702
746
  # @!method update_product_sku(product_id, id, options = {})
703
- # @param [Integer] id the identifier for the sku
704
747
  # @param [Integer] product_id the identifier for the product
748
+ # @param [Integer] id the identifier for the sku
705
749
  # @param [Hash] options the attributes for the sku
706
- # update the attributes of the sku with the given id for the given product
750
+ # updates the attributes of the sku with the given id for the given product
707
751
 
708
752
  # @!method delete_product_sku(product_id, id)
709
- # @param [Integer] id the identifier for the sku
710
753
  # @param [Integer] product_id the identifier for the product
754
+ # @param [Integer] id the identifier for the sku
711
755
  # deletes the sku with the given id for the given product
712
756
 
713
757
  # @!method product_skus_count(product_id, options = {})
@@ -730,7 +774,7 @@ module BigcommerceOAuthAPI
730
774
  # @!method update_redirect(id, options = {})
731
775
  # @param [Integer] id the identifier for the redirect
732
776
  # @param [Hash] options the attributes for the redirect
733
- # update the attributes of the redirect with the given id
777
+ # updates the attributes of the redirect with the given id
734
778
 
735
779
  # @!method delete_redirect(id)
736
780
  # @param [Integer] id the identifier for the redirect
@@ -771,7 +815,7 @@ module BigcommerceOAuthAPI
771
815
  # @!method update_hook(id, options = {})
772
816
  # @param [Integer] id the identifier for the hook
773
817
  # @param [Hash] options the attributes for the hook
774
- # update the attributes of the hook with the given id
818
+ # updates the attributes of the hook with the given id
775
819
 
776
820
  # @!method delete_hook(id)
777
821
  # @param [Integer] id the identifier for the hook
@@ -1,5 +1,12 @@
1
+ require 'json'
2
+
1
3
  module BigcommerceOAuthAPI
2
4
  class Error < StandardError
5
+
6
+ def to_h
7
+ JSON.parse(message, symbolize_names: true) rescue {}
8
+ end
9
+
3
10
  def inspect
4
11
  "#<BigcommerceOAuthAPI::Error: BigcommerceOAuthAPI::Error message=\"#{message}\">"
5
12
  end
@@ -7,11 +7,13 @@ module BigcommerceOAuthAPI
7
7
  end
8
8
 
9
9
  def [](key)
10
- @attributes[key.to_sym]
10
+ value = memoize(key.to_sym) # get memoized value if present
11
+ value || @attributes[key.to_sym]
11
12
  end
12
13
 
13
14
  def []=(key, value)
14
15
  @attributes[key.to_sym] = value
16
+ unmemoize(key.to_sym) # protect against memoized data
15
17
  end
16
18
 
17
19
  def ==(other)
@@ -31,27 +33,21 @@ module BigcommerceOAuthAPI
31
33
  end
32
34
 
33
35
  def method_missing(method_sym, *arguments)
34
- if @attributes.include?(method_sym)
36
+ method_type = method_sym.to_s[-1] # last char
37
+ if @attributes.include?(method_sym) || method_type == '='
35
38
  attribute_name = method_sym.to_s.gsub(/(\?$)|(=$)/, '')
36
- self.instance_eval build_attribute_getter(attribute_name)
39
+ case method_type
40
+ when '='
41
+ self.instance_eval build_attribute_setter(attribute_name)
42
+ else
43
+ self.instance_eval build_attribute_getter(attribute_name)
44
+ end
37
45
  send(method_sym, *arguments)
38
46
  else
39
47
  super(method_sym, *arguments)
40
48
  end
41
49
  end
42
50
 
43
- def build_attribute_getter(attribute_name)
44
- "def #{attribute_name}
45
- if @attributes[:#{attribute_name}] && @attributes[:#{attribute_name}].is_a?(Hash)
46
- memoize(:#{attribute_name}) do
47
- self.class.new(@attributes[:#{attribute_name}])
48
- end
49
- else
50
- @attributes[:#{attribute_name}]
51
- end
52
- end"
53
- end
54
-
55
51
  def marshal_dump
56
52
  {}.merge(@attributes.to_h)
57
53
  end
@@ -71,5 +67,37 @@ module BigcommerceOAuthAPI
71
67
 
72
68
  var
73
69
  end
70
+
71
+ def unmemoize(name)
72
+ var = instance_variable_get("@#{name.to_s}") rescue nil
73
+ unless var.nil?
74
+ instance_variable_set("@#{name.to_s}", nil)
75
+ end
76
+ end
77
+
78
+ def build_attribute_getter(attribute_name)
79
+ "def #{attribute_name}
80
+ if @attributes[:#{attribute_name}] && @attributes[:#{attribute_name}].is_a?(Hash)
81
+ memoize(:#{attribute_name}) do
82
+ self.class.new(@attributes[:#{attribute_name}])
83
+ end
84
+ elsif @attributes[:#{attribute_name}] && @attributes[:#{attribute_name}].is_a?(Array)
85
+ memoize(:#{attribute_name}) do
86
+ @attributes[:#{attribute_name}].map do |entry|
87
+ self.class.new(entry)
88
+ end
89
+ end
90
+ else
91
+ @attributes[:#{attribute_name}]
92
+ end
93
+ end"
94
+ end
95
+
96
+ def build_attribute_setter(attribute_name)
97
+ "def #{attribute_name}=(value)
98
+ @attributes[:#{attribute_name}] = value
99
+ unmemoize(:#{attribute_name}) # protect against memoized data
100
+ end"
101
+ end
74
102
  end
75
103
  end
@@ -1,3 +1,3 @@
1
1
  module BigcommerceOAuthAPI
2
- VERSION = '1.3.2'.freeze
2
+ VERSION = '1.4.0'.freeze
3
3
  end
@@ -9,6 +9,8 @@ describe BigcommerceOAuthAPI::Client do
9
9
  { api_module: 'tag', methods: [:all], prefix_paths: 'blog', prefix_methods: 'blog'},
10
10
  { api_module: 'brand', methods: [:all, :select, :create, :update, :delete, :count]},
11
11
  { api_module: 'category', methods: [:all, :select, :create, :update, :delete]},
12
+ { api_module: 'banner', methods: [:all, :select, :create, :update, :delete]},
13
+ { api_module: 'gift_certificate', methods: [:all, :select, :create, :update, :delete]},
12
14
  { api_module: 'customer', methods: [:all, :select, :create, :update, :delete, :count]},
13
15
  { api_module: 'customer_group', methods: [:all, :select, :create, :update, :delete]},
14
16
  { api_module: 'country', scope: :self, methods: [:all, :select, :count]},
@@ -22,6 +22,18 @@ module BigcommerceOAuthAPI
22
22
  expect(instance.c[:foo]).to eql('bar')
23
23
  expect(instance.c.foo).to eql('bar')
24
24
  end
25
+
26
+ it 'can set attributes' do
27
+ expect(instance.a).to eq('foo')
28
+ instance.a = 'method'
29
+ expect(instance.a).to eq('method')
30
+ instance['a'] = 'hash'
31
+ expect(instance.a).to eq('hash')
32
+ instance[:a] = 'symbol'
33
+ expect(instance.a).to eq('symbol')
34
+ instance.new_method = 'new stuff'
35
+ expect(instance.new_method).to eq('new stuff')
36
+ end
25
37
  end
26
38
 
27
39
  context 'when initialized with a deeply nested hash' do
@@ -39,6 +51,18 @@ module BigcommerceOAuthAPI
39
51
  expect(instance.a.b.c.d).to eql('e')
40
52
  end
41
53
 
54
+ it 'can set attributes' do
55
+ expect(instance.a.b.c.d).to eq('e')
56
+ instance.a.b.c.d = 'method'
57
+ expect(instance.a.b.c.d).to eq('method')
58
+ instance['a']['b']['c']['d'] = 'hash'
59
+ expect(instance.a.b.c.d).to eq('hash')
60
+ instance[:a][:b][:c][:d] = 'symbol'
61
+ expect(instance.a.b.c.d).to eq('symbol')
62
+ instance.a.b.c.new_method = 'new stuff'
63
+ expect(instance.a.b.c.new_method).to eq('new stuff')
64
+ end
65
+
42
66
  describe '#marshal_dump' do
43
67
  it 'can load a marshal dump correctly' do
44
68
  dump = Marshal.dump(instance)
@@ -50,5 +74,50 @@ module BigcommerceOAuthAPI
50
74
  end
51
75
  end
52
76
  end
77
+
78
+ context 'when initialized with a list attribute' do
79
+ let(:instance) do
80
+ described_class.new({a: [{b: 1}, {b: 2}] })
81
+ end
82
+
83
+ it 'converts the list elements to resources' do
84
+ expect(instance).to be
85
+ expect(instance.respond_to?(:a)).to be true
86
+ expect(instance.a).to be_a Array
87
+ expect(instance.a.size).to eq(2)
88
+ instance.a.each do |entry|
89
+ expect(entry).to be_a BigcommerceOAuthAPI::Resource
90
+ expect(entry.respond_to?(:b)).to be true
91
+ end
92
+ end
93
+
94
+ it 'can set attributes' do
95
+ expect(instance.a).to be_a Array
96
+ first_object = instance.a.first
97
+ expect(first_object.b).to eq(1)
98
+ first_object.b = 3
99
+ expect(instance.a.first.b).to eq(3)
100
+ instance[:a][0][:b] = 4
101
+ expect(instance.a.first.b).to eq(4)
102
+ instance['a'][0]['b'] = 5
103
+ expect(instance.a.first.b).to eq(5)
104
+ end
105
+
106
+ describe '#marshal_dump' do
107
+ it 'can load a marshal dump correctly' do
108
+ dump = Marshal.dump(instance)
109
+ expect(dump).to be_a String
110
+ loaded_object = Marshal.load(dump)
111
+ expect(loaded_object).to_not be_a String
112
+ expect(loaded_object).to be_a BigcommerceOAuthAPI::Resource
113
+ expect(loaded_object.a).to be_a Array
114
+ expect(loaded_object.a.size).to eq(2)
115
+ loaded_object.a.each do |entry|
116
+ expect(entry).to be_a BigcommerceOAuthAPI::Resource
117
+ expect(entry.respond_to?(:b)).to be true
118
+ end
119
+ end
120
+ end
121
+ end
53
122
  end
54
123
  end
metadata CHANGED
@@ -1,145 +1,145 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigcommerce-oauth-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Orthmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-14 00:00:00.000000000 Z
11
+ date: 2016-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: webmock
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov-rcov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: yard
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: faraday
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: faraday_middleware
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: activesupport
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: 3.0.0
132
- - - <
132
+ - - "<"
133
133
  - !ruby/object:Gem::Version
134
134
  version: 5.0.0
135
135
  type: :runtime
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - '>='
139
+ - - ">="
140
140
  - !ruby/object:Gem::Version
141
141
  version: 3.0.0
142
- - - <
142
+ - - "<"
143
143
  - !ruby/object:Gem::Version
144
144
  version: 5.0.0
145
145
  description: Connect Ruby applications to Bigcommerce APIs through OAuth or basic
@@ -149,7 +149,7 @@ executables: []
149
149
  extensions: []
150
150
  extra_rdoc_files: []
151
151
  files:
152
- - .rspec
152
+ - ".rspec"
153
153
  - CHANGELOG.md
154
154
  - Gemfile
155
155
  - README.md
@@ -187,20 +187,19 @@ require_paths:
187
187
  - lib
188
188
  required_ruby_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - '>='
190
+ - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  requirements:
195
- - - '>='
195
+ - - ">="
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
199
  rubyforge_project:
200
- rubygems_version: 2.4.3
200
+ rubygems_version: 2.5.1
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: Ruby client library for Bigcommerce APIs with OAuth and basic authentication
204
204
  support
205
205
  test_files: []
206
- has_rdoc: