bigcommerce 0.10.0 → 1.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +620 -0
  5. data/.travis.yml +15 -0
  6. data/CHANGELOG.md +11 -0
  7. data/CONTRIBUTING.md +119 -0
  8. data/DEPENDENCIES.md +7 -0
  9. data/Gemfile +15 -0
  10. data/Guardfile +22 -0
  11. data/LICENSE +15 -15
  12. data/README.md +61 -70
  13. data/RELEASING.md +64 -0
  14. data/Rakefile +8 -6
  15. data/bigcommerce.gemspec +22 -53
  16. data/examples/README.md +148 -0
  17. data/examples/configuration/legacy_auth.rb +12 -0
  18. data/examples/configuration/oauth.rb +9 -0
  19. data/examples/content/blog_post.rb +39 -0
  20. data/examples/content/blog_tag.rb +10 -0
  21. data/examples/content/redirect.rb +43 -0
  22. data/examples/customers/customer.rb +36 -0
  23. data/examples/customers/customer_address.rb +50 -0
  24. data/examples/customers/customer_group.rb +35 -0
  25. data/examples/exception_handling.rb +50 -0
  26. data/examples/geography/country.rb +16 -0
  27. data/examples/geography/state.rb +19 -0
  28. data/examples/marketing/coupon.rb +44 -0
  29. data/examples/orders/order.rb +53 -0
  30. data/examples/orders/order_coupon.rb +17 -0
  31. data/examples/orders/order_message.rb +17 -0
  32. data/examples/orders/order_product.rb +23 -0
  33. data/examples/orders/order_shipping_address.rb +23 -0
  34. data/examples/orders/order_status.rb +15 -0
  35. data/examples/orders/order_tax.rb +17 -0
  36. data/examples/orders/shipment.rb +57 -0
  37. data/examples/payments/payment_method.rb +10 -0
  38. data/examples/products/brand.rb +36 -0
  39. data/examples/products/bulk_pricing_rule.rb +47 -0
  40. data/examples/products/category.rb +37 -0
  41. data/examples/products/configurable_field.rb +29 -0
  42. data/examples/products/custom_field.rb +44 -0
  43. data/examples/products/google_product_search_mapping.rb +12 -0
  44. data/examples/products/option.rb +37 -0
  45. data/examples/products/option_set.rb +35 -0
  46. data/examples/products/option_set_option.rb +50 -0
  47. data/examples/products/option_value.rb +43 -0
  48. data/examples/products/product.rb +44 -0
  49. data/examples/products/product_image.rb +42 -0
  50. data/examples/products/product_option.rb +17 -0
  51. data/examples/products/product_review.rb +12 -0
  52. data/examples/products/product_rule.rb +54 -0
  53. data/examples/products/product_video.rb +45 -0
  54. data/examples/products/sku.rb +48 -0
  55. data/examples/shipping/shipping_method.rb +13 -0
  56. data/examples/store/store_info.rb +10 -0
  57. data/examples/system/time.rb +10 -0
  58. data/examples/tax/tax_class.rb +13 -0
  59. data/examples/webhooks/webhook.rb +29 -0
  60. data/lib/bigcommerce.rb +50 -8
  61. data/lib/bigcommerce/exception.rb +51 -0
  62. data/lib/bigcommerce/middleware/auth.rb +16 -0
  63. data/lib/bigcommerce/middleware/http_exception.rb +14 -0
  64. data/lib/bigcommerce/request.rb +89 -0
  65. data/lib/bigcommerce/resource_actions.rb +51 -0
  66. data/lib/bigcommerce/resources/content/blog_post.rb +31 -0
  67. data/lib/bigcommerce/resources/content/blog_tag.rb +17 -0
  68. data/lib/bigcommerce/resources/content/redirect.rb +21 -0
  69. data/lib/bigcommerce/resources/customers/customer.rb +30 -0
  70. data/lib/bigcommerce/resources/customers/customer_address.rb +34 -0
  71. data/lib/bigcommerce/resources/customers/customer_group.rb +21 -0
  72. data/lib/bigcommerce/resources/geography/country.rb +22 -0
  73. data/lib/bigcommerce/resources/geography/state.rb +25 -0
  74. data/lib/bigcommerce/resources/marketing/coupon.rb +30 -0
  75. data/lib/bigcommerce/resources/orders/order.rb +73 -0
  76. data/lib/bigcommerce/resources/orders/order_coupon.rb +20 -0
  77. data/lib/bigcommerce/resources/orders/order_message.rb +23 -0
  78. data/lib/bigcommerce/resources/orders/order_product.rb +64 -0
  79. data/lib/bigcommerce/resources/orders/order_shipping_address.rb +50 -0
  80. data/lib/bigcommerce/resources/orders/order_status.rb +16 -0
  81. data/lib/bigcommerce/resources/orders/order_tax.rb +23 -0
  82. data/lib/bigcommerce/resources/orders/shipment.rb +30 -0
  83. data/lib/bigcommerce/resources/payments/payment_method.rb +17 -0
  84. data/lib/bigcommerce/resources/products/brand.rb +23 -0
  85. data/lib/bigcommerce/resources/products/bulk_pricing_rule.rb +26 -0
  86. data/lib/bigcommerce/resources/products/category.rb +29 -0
  87. data/lib/bigcommerce/resources/products/configurable_field.rb +30 -0
  88. data/lib/bigcommerce/resources/products/custom_field.rb +24 -0
  89. data/lib/bigcommerce/resources/products/google_product_search_mapping.rb +26 -0
  90. data/lib/bigcommerce/resources/products/option.rb +20 -0
  91. data/lib/bigcommerce/resources/products/option_set.rb +18 -0
  92. data/lib/bigcommerce/resources/products/option_set_option.rb +19 -0
  93. data/lib/bigcommerce/resources/products/option_value.rb +15 -0
  94. data/lib/bigcommerce/resources/products/product.rb +97 -0
  95. data/lib/bigcommerce/resources/products/product_image.rb +31 -0
  96. data/lib/bigcommerce/resources/products/product_option.rb +17 -0
  97. data/lib/bigcommerce/resources/products/product_review.rb +22 -0
  98. data/lib/bigcommerce/resources/products/product_rule.rb +31 -0
  99. data/lib/bigcommerce/resources/products/product_video.rb +24 -0
  100. data/lib/bigcommerce/resources/products/sku.rb +29 -0
  101. data/lib/bigcommerce/resources/resource.rb +10 -0
  102. data/lib/bigcommerce/resources/shipping/shipping_method.rb +15 -0
  103. data/lib/bigcommerce/resources/store/store_information.rb +37 -0
  104. data/lib/bigcommerce/resources/system/time.rb +15 -0
  105. data/lib/bigcommerce/resources/tax/tax_class.rb +15 -0
  106. data/lib/bigcommerce/resources/webhooks/webhook.rb +22 -0
  107. data/lib/bigcommerce/subresource_actions.rb +43 -0
  108. data/lib/bigcommerce/version.rb +1 -4
  109. data/spec/bigcommerce/bigcommerce_spec.rb +76 -0
  110. data/spec/bigcommerce/unit/actions_spec.rb +151 -0
  111. data/spec/bigcommerce/unit/exception_spec.rb +53 -0
  112. data/spec/bigcommerce/unit/middleware/auth_spec.rb +18 -0
  113. data/spec/bigcommerce/unit/middleware/http_exception_spec.rb +40 -0
  114. data/spec/bigcommerce/unit/request_spec.rb +180 -0
  115. data/spec/bigcommerce/unit/resources/content/blog_post_spec.rb +12 -0
  116. data/spec/bigcommerce/unit/resources/content/blog_tag_spec.rb +12 -0
  117. data/spec/bigcommerce/unit/resources/content/redirect_spec.rb +12 -0
  118. data/spec/bigcommerce/unit/resources/customers/customer_address_spec.rb +21 -0
  119. data/spec/bigcommerce/unit/resources/customers/customer_group_spec.rb +12 -0
  120. data/spec/bigcommerce/unit/resources/customers/customer_spec.rb +12 -0
  121. data/spec/bigcommerce/unit/resources/geography/country_spec.rb +12 -0
  122. data/spec/bigcommerce/unit/resources/geography/state_spec.rb +21 -0
  123. data/spec/bigcommerce/unit/resources/marketing/coupon_spec.rb +12 -0
  124. data/spec/bigcommerce/unit/resources/orders/order_product_spec.rb +21 -0
  125. data/spec/bigcommerce/unit/resources/orders/order_shipping_address_spec.rb +21 -0
  126. data/spec/bigcommerce/unit/resources/orders/order_spec.rb +13 -0
  127. data/spec/bigcommerce/unit/resources/orders/shipment_spec.rb +21 -0
  128. data/spec/bigcommerce/unit/resources/payments/payment_method_spec.rb +23 -0
  129. data/spec/bigcommerce/unit/resources/products/brand_spec.rb +12 -0
  130. data/spec/bigcommerce/unit/resources/products/bulk_pricing_rule_spec.rb +21 -0
  131. data/spec/bigcommerce/unit/resources/products/category_spec.rb +12 -0
  132. data/spec/bigcommerce/unit/resources/products/configurable_field_spec.rb +21 -0
  133. data/spec/bigcommerce/unit/resources/products/custom_field_spec.rb +21 -0
  134. data/spec/bigcommerce/unit/resources/products/google_product_search_mapping_spec.rb +14 -0
  135. data/spec/bigcommerce/unit/resources/products/option_set_spec.rb +12 -0
  136. data/spec/bigcommerce/unit/resources/products/option_spec.rb +12 -0
  137. data/spec/bigcommerce/unit/resources/products/product_image_spec.rb +21 -0
  138. data/spec/bigcommerce/unit/resources/products/product_review_spec.rb +14 -0
  139. data/spec/bigcommerce/unit/resources/products/product_rule_spec.rb +21 -0
  140. data/spec/bigcommerce/unit/resources/products/product_spec.rb +13 -0
  141. data/spec/bigcommerce/unit/resources/products/product_video_spec.rb +21 -0
  142. data/spec/bigcommerce/unit/resources/products/sku_spec.rb +21 -0
  143. data/spec/bigcommerce/unit/resources/resource_spec.rb +4 -0
  144. data/spec/bigcommerce/unit/resources/store_info/store_information_spec.rb +12 -0
  145. data/spec/bigcommerce/unit/resources/system/time_spec.rb +12 -0
  146. data/spec/bigcommerce/unit/version_spec.rb +7 -0
  147. data/spec/spec_helper.rb +9 -25
  148. metadata +203 -127
  149. data/lib/big_commerce.rb +0 -1
  150. data/lib/bigcommerce/api.rb +0 -473
  151. data/lib/bigcommerce/connection.rb +0 -171
  152. data/lib/bigcommerce/product.rb +0 -13
  153. data/lib/bigcommerce/resource.rb +0 -50
  154. data/spec/big_commerce_spec.rb +0 -9
  155. data/spec/integration/orders_spec.rb +0 -18
  156. data/spec/support/integration_context.rb +0 -13
  157. data/spec/support/mock_api_context.rb +0 -10
  158. data/spec/unit/api_request_spec.rb +0 -34
  159. data/spec/unit/api_spec.rb +0 -49
  160. data/spec/unit/connection_spec.rb +0 -23
  161. data/spec/unit/date_time_spec.rb +0 -31
  162. data/spec/unit/version_spec.rb +0 -13
@@ -0,0 +1,47 @@
1
+ require 'bigcommerce'
2
+ require 'securerandom'
3
+
4
+ Bigcommerce.configure do |config|
5
+ config.store_hash = ENV['BC_STORE_HASH']
6
+ config.client_id = ENV['BC_CLIENT_ID']
7
+ config.access_token = ENV['BC_ACCESS_TOKEN']
8
+ end
9
+
10
+ @product = Bigcommerce::Product.all[0]
11
+
12
+ # Create a products bulk pricing rule
13
+ @bulk_pricing_rule = Bigcommerce::BulkPricingRule.create(
14
+ @product.id,
15
+ min: 1,
16
+ max: 5,
17
+ type: 'price',
18
+ type_value: 2
19
+ )
20
+ puts @bulk_pricing_rule
21
+
22
+ # List bulk pricing rules
23
+ puts Bigcommerce::BulkPricingRule.all(@product.id)
24
+
25
+ # Get a product bulk pricing rule
26
+ puts Bigcommerce::BulkPricingRule.find(@product.id, @bulk_pricing_rule.id)
27
+
28
+ # Get a count of bulk pricing rules
29
+ puts Bigcommerce::BulkPricingRule.count(@product.id)
30
+
31
+ # Get a count of all bulk pricing rules for all products
32
+ puts Bigcommerce::BulkPricingRule.count_all
33
+
34
+ # Update a bulk pricing rule
35
+ puts Bigcommerce::BulkPricingRule.update(
36
+ @product.id,
37
+ @bulk_pricing_rule.id,
38
+ min: 2,
39
+ type: 'price',
40
+ type_value: 2
41
+ )
42
+
43
+ # Delete a product bulk pricing rule
44
+ puts Bigcommerce::BulkPricingRule.destroy(@product.id, @bulk_pricing_rule.id)
45
+
46
+ # Delete multiple bulk pricing rules
47
+ # puts Bigcommerce::BulkPricingRule.destroy(@product.id)
@@ -0,0 +1,37 @@
1
+ require 'bigcommerce'
2
+ require 'securerandom'
3
+
4
+ Bigcommerce.configure do |config|
5
+ config.store_hash = ENV['BC_STORE_HASH']
6
+ config.client_id = ENV['BC_CLIENT_ID']
7
+ config.access_token = ENV['BC_ACCESS_TOKEN']
8
+ end
9
+
10
+ # List categories
11
+ @categories = Bigcommerce::Category.all
12
+ puts @categories
13
+
14
+ # Get a category
15
+ @category = @categories[0]
16
+ puts Bigcommerce::Category.find(@category.id)
17
+
18
+ # Get a count of categories
19
+ puts Bigcommerce::Category.count
20
+
21
+ # Create a category
22
+ @category = Bigcommerce::Category.create(
23
+ name: SecureRandom.hex
24
+ )
25
+ puts @category
26
+
27
+ # Update a category
28
+ puts Bigcommerce::Category.update(
29
+ @category.id,
30
+ name: 'Foobar'
31
+ )
32
+
33
+ # Delete a category
34
+ puts Bigcommerce::Category.destroy(@category.id)
35
+
36
+ # Delete all categories
37
+ # Bigcommerce::Category.destroy_all
@@ -0,0 +1,29 @@
1
+ require 'bigcommerce'
2
+
3
+ Bigcommerce.configure do |config|
4
+ config.store_hash = ENV['BC_STORE_HASH']
5
+ config.client_id = ENV['BC_CLIENT_ID']
6
+ config.access_token = ENV['BC_ACCESS_TOKEN']
7
+ end
8
+
9
+ @product = Bigcommerce::Product.all[0]
10
+
11
+ # List configurable fields
12
+ @configurable_fields = Bigcommerce::ConfigurableField.all(@product.id)
13
+ puts @configurable_fields
14
+
15
+ # Get a configurable field
16
+ @configurable_field = @configurable_fields[0]
17
+ puts Bigcommerce::ConfigurableField.all(@product.id, @configurable_field.id)
18
+
19
+ # Get a count of configurable fields
20
+ puts Bigcommerce::ConfigurableField.count(@product.id)
21
+
22
+ # Get a count of all configurable fields for all products
23
+ puts Bigcommerce::ConfigurableField.count(@product.id)
24
+
25
+ # Delete a configurable field
26
+ puts Bigcommerce::ConfigurableField.destroy(@product.id, @configurable_field.id)
27
+
28
+ # Delete multiple configurable fields
29
+ # puts Bigcommerce::ConfigurableField.destroy_all(@product.id)
@@ -0,0 +1,44 @@
1
+ require 'bigcommerce'
2
+ require 'securerandom'
3
+
4
+ Bigcommerce.configure do |config|
5
+ config.store_hash = ENV['BC_STORE_HASH']
6
+ config.client_id = ENV['BC_CLIENT_ID']
7
+ config.access_token = ENV['BC_ACCESS_TOKEN']
8
+ end
9
+
10
+ @product = Bigcommerce::Product.all[0]
11
+
12
+ # Create a custom field
13
+ @custom_field = Bigcommerce::CustomField.create(
14
+ @product.id,
15
+ name: SecureRandom.hex,
16
+ text: SecureRandom.hex
17
+ )
18
+ puts @custom_field
19
+
20
+ # List custom fields
21
+ puts Bigcommerce::CustomField.all(@product.id)
22
+
23
+ # Get a custom field
24
+ puts Bigcommerce::CustomField.find(@product.id, @custom_field.id)
25
+
26
+ # Get a count of custom fields
27
+ puts Bigcommerce::CustomField.count(@product.id)
28
+
29
+ # Get a count of custom fields for all products
30
+ puts Bigcommerce::CustomField.count_all
31
+
32
+ # Update a custom field
33
+ puts Bigcommerce::CustomField.update(
34
+ @product.id,
35
+ @custom_field.id,
36
+ name: ':)',
37
+ text: ':)'
38
+ )
39
+
40
+ # Delete a custom field
41
+ puts Bigcommerce::CustomField.destroy(@product.id, @custom_field.id)
42
+
43
+ # Delete multiple custom fields
44
+ # puts Bigcommerce::CustomField.destroy_all(@product.id)
@@ -0,0 +1,12 @@
1
+ require 'bigcommerce'
2
+
3
+ Bigcommerce.configure do |config|
4
+ config.store_hash = ENV['BC_STORE_HASH']
5
+ config.client_id = ENV['BC_CLIENT_ID']
6
+ config.access_token = ENV['BC_ACCESS_TOKEN']
7
+ end
8
+
9
+ @product = Bigcommerce::Product.all[0]
10
+
11
+ # List Google product search mappings
12
+ puts Bigcommerce::GoogleProductSearchMapping.all(@product.id)
@@ -0,0 +1,37 @@
1
+ require 'bigcommerce'
2
+ require 'securerandom'
3
+
4
+ Bigcommerce.configure do |config|
5
+ config.store_hash = ENV['BC_STORE_HASH']
6
+ config.client_id = ENV['BC_CLIENT_ID']
7
+ config.access_token = ENV['BC_ACCESS_TOKEN']
8
+ end
9
+
10
+ # Create an option
11
+ @option = Bigcommerce::Option.create(
12
+ name: SecureRandom.hex,
13
+ type: 'CS'
14
+ )
15
+ puts @option
16
+
17
+ # List options
18
+ puts Bigcommerce::Option.all
19
+
20
+ # Get an option
21
+ puts Bigcommerce::Option.find(@option.id)
22
+
23
+ # Get a count of options
24
+ puts Bigcommerce::Option.count
25
+
26
+ # Update an option
27
+ puts Bigcommerce::Option.update(
28
+ @option.id,
29
+ name: ':)',
30
+ type: 'CS'
31
+ )
32
+
33
+ # Delete an option
34
+ puts Bigcommerce::Option.destroy(@option.id)
35
+
36
+ # Delete all options
37
+ # Bigcommerce::Option.destroy_all
@@ -0,0 +1,35 @@
1
+ require 'bigcommerce'
2
+ require 'securerandom'
3
+
4
+ Bigcommerce.configure do |config|
5
+ config.store_hash = ENV['BC_STORE_HASH']
6
+ config.client_id = ENV['BC_CLIENT_ID']
7
+ config.access_token = ENV['BC_ACCESS_TOKEN']
8
+ end
9
+
10
+ # Create an option set
11
+ @option_set = Bigcommerce::OptionSet.create(
12
+ name: SecureRandom.hex
13
+ )
14
+ puts @option_set
15
+
16
+ # List option sets
17
+ puts Bigcommerce::OptionSet.all
18
+
19
+ # Get an option set
20
+ puts Bigcommerce::OptionSet.find(@option_set.id)
21
+
22
+ # Get a count of option sets
23
+ puts Bigcommerce::OptionSet.count
24
+
25
+ # Update an option set
26
+ puts Bigcommerce::OptionSet.update(
27
+ @option_set.id,
28
+ name: ':)'
29
+ )
30
+
31
+ # Delete an option set
32
+ puts Bigcommerce::OptionSet.destroy(@option_set.id)
33
+
34
+ # Delete all option sets
35
+ # Bigcommerce::OptionSet.destroy_all
@@ -0,0 +1,50 @@
1
+ require 'bigcommerce'
2
+ require 'securerandom'
3
+
4
+ Bigcommerce.configure do |config|
5
+ config.store_hash = ENV['BC_STORE_HASH']
6
+ config.client_id = ENV['BC_CLIENT_ID']
7
+ config.access_token = ENV['BC_ACCESS_TOKEN']
8
+ end
9
+
10
+ @option_set = Bigcommerce::OptionSet.create(
11
+ name: SecureRandom.hex
12
+ )
13
+
14
+ @option = Bigcommerce::Option.create(
15
+ name: SecureRandom.hex,
16
+ type: 'CS'
17
+ )
18
+
19
+ # Create an option set option
20
+ @option_set_option = Bigcommerce::OptionSetOption.create(
21
+ @option_set.id,
22
+ option_id: @option.id,
23
+ display_name: SecureRandom.hex,
24
+ sort_order: 1,
25
+ is_required: true
26
+ )
27
+ puts @option_set_option
28
+
29
+ # List option set options
30
+ puts Bigcommerce::OptionSetOption.all(@option_set.id)
31
+
32
+ puts Bigcommerce::OptionSetOption.count(@option_set.id)
33
+
34
+ # Get an option set option
35
+ puts Bigcommerce::OptionSetOption.find(@option_set.id, @option_set_option.id)
36
+
37
+ # Update an option set option
38
+ puts Bigcommerce::OptionSetOption.update(
39
+ @option_set.id,
40
+ @option_set_option.id,
41
+ display_name: 'Pick a color...',
42
+ sort_order: 2,
43
+ is_required: false
44
+ )
45
+
46
+ # Delete an option set option
47
+ puts Bigcommerce::OptionSetOption.destroy(@option_set.id, @option_set_option.id)
48
+
49
+ # Delete multiple option set options
50
+ # puts Bigcommerce::OptionSetOption.destroy_all(@option_set.id)
@@ -0,0 +1,43 @@
1
+ require 'bigcommerce'
2
+ require 'securerandom'
3
+
4
+ Bigcommerce.configure do |config|
5
+ config.store_hash = ENV['BC_STORE_HASH']
6
+ config.client_id = ENV['BC_CLIENT_ID']
7
+ config.access_token = ENV['BC_ACCESS_TOKEN']
8
+ end
9
+
10
+ @option = Bigcommerce::Option.create(
11
+ name: SecureRandom.hex,
12
+ type: 'CS'
13
+ )
14
+
15
+ # Create an option value
16
+ @option_value = Bigcommerce::OptionValue.create(
17
+ @option.id,
18
+ label: SecureRandom.hex,
19
+ sort_order: 0,
20
+ value: '#FFFFFF'
21
+ )
22
+ puts @option_value
23
+
24
+ # List option values
25
+ puts Bigcommerce::OptionValue.all(@option.id)
26
+
27
+ # Get an option value
28
+ puts Bigcommerce::OptionValue.find(@option.id, @option_value.id)
29
+
30
+ # Update an option value
31
+ puts Bigcommerce::OptionValue.update(
32
+ @option.id,
33
+ @option_value.id,
34
+ label: SecureRandom.hex,
35
+ sort_order: 0,
36
+ value: '#000000'
37
+ )
38
+
39
+ # Delete an option value
40
+ puts Bigcommerce::OptionValue.destroy(@option.id, @option_value.id)
41
+
42
+ # Delete multiple option values
43
+ # puts Bigcommerce::OptionValue.destroy_all(@option.id)
@@ -0,0 +1,44 @@
1
+ require 'bigcommerce'
2
+ require 'securerandom'
3
+
4
+ Bigcommerce.configure do |config|
5
+ config.store_hash = ENV['BC_STORE_HASH']
6
+ config.client_id = ENV['BC_CLIENT_ID']
7
+ config.access_token = ENV['BC_ACCESS_TOKEN']
8
+ end
9
+
10
+ # List products
11
+ @products = Bigcommerce::Product.all
12
+ puts @products
13
+
14
+ # Get a product
15
+ @product = @products[0]
16
+ puts Bigcommerce::Product.find(@product.id)
17
+
18
+ # Get products count
19
+ puts Bigcommerce::Product.count
20
+
21
+ # Create a product
22
+ @category = Bigcommerce::Category.all[0]
23
+ @product = Bigcommerce::Product.create(
24
+ name: SecureRandom.hex,
25
+ type: 'physical',
26
+ description: SecureRandom.hex,
27
+ price: '19.95',
28
+ categories: [@category.id],
29
+ availability: 'available',
30
+ weight: '0.5'
31
+ )
32
+ puts @product
33
+
34
+ # Update a product
35
+ puts Bigcommerce::Product.update(
36
+ @product.id,
37
+ custom_url: '/foo-bar/'
38
+ )
39
+
40
+ # Delete a product
41
+ puts Bigcommerce::Product.destroy(@product.id)
42
+
43
+ # Delete all products
44
+ # puts Bigcommerce::Product.destroy_all
@@ -0,0 +1,42 @@
1
+ require 'bigcommerce'
2
+
3
+ Bigcommerce.configure do |config|
4
+ config.store_hash = ENV['BC_STORE_HASH']
5
+ config.client_id = ENV['BC_CLIENT_ID']
6
+ config.access_token = ENV['BC_ACCESS_TOKEN']
7
+ end
8
+
9
+ @product = Bigcommerce::Product.all[0]
10
+
11
+ # List product images
12
+ @product_images = Bigcommerce::ProductImage.all(@product.id)
13
+ puts @product_images
14
+
15
+ # Get a count of product images
16
+ puts Bigcommerce::ProductImage.count(@product.id)
17
+
18
+ # Get a count of all product images for all products
19
+ puts Bigcommerce::ProductImage.count_all
20
+
21
+ # Create a product image
22
+ @product_image = Bigcommerce::ProductImage.create(
23
+ @product.id,
24
+ image_file: 'http://i.imgur.com/Z5aV28x.gif'
25
+ )
26
+ puts @product_image
27
+
28
+ # Get a product image
29
+ puts Bigcommerce::ProductImage.find(@product.id, @product_image.id)
30
+
31
+ # Update a product image
32
+ puts Bigcommerce::ProductImage.update(
33
+ @product.id,
34
+ @product_image.id,
35
+ image_file: 'http://i.imgur.com/4Dl6Y9d.gif'
36
+ )
37
+
38
+ # Delete a product image
39
+ puts Bigcommerce::ProductImage.destroy(@product.id, @product_image.id)
40
+
41
+ # Delete all product images
42
+ # puts Bigcommerce::ProductImage.destroy_all(@product.id)
@@ -0,0 +1,17 @@
1
+ require 'bigcommerce'
2
+
3
+ Bigcommerce.configure do |config|
4
+ config.store_hash = ENV['BC_STORE_HASH']
5
+ config.client_id = ENV['BC_CLIENT_ID']
6
+ config.access_token = ENV['BC_ACCESS_TOKEN']
7
+ end
8
+
9
+ @product = Bigcommerce::Product.all[0]
10
+
11
+ # List product options
12
+ @product_options = Bigcommerce::ProductOption.all(@product.id)
13
+ puts @product_options
14
+
15
+ # Get a product option
16
+ @product_option = @product_options[0]
17
+ puts Bigcommerce::ProductOption.find(@product.id, @product_option.id)