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
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
- require 'bundler/gem_tasks'
2
- require 'ci/reporter/rake/rspec'
3
1
  require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+ require 'bigcommerce'
4
4
 
5
- Bundler::GemHelper.install_tasks
6
-
7
- RSpec::Core::RakeTask.new(:spec) do |spec|
5
+ RSpec::Core::RakeTask.new do |spec|
8
6
  spec.pattern = 'spec/**/*_spec.rb'
7
+ spec.verbose = false
9
8
  end
10
9
 
11
- task :default => ['ci:setup:rspec', :spec]
10
+ require 'rubocop/rake_task'
11
+ RuboCop::RakeTask.new(:rubocop)
12
+
13
+ task default: [:rubocop, :spec]
@@ -1,59 +1,28 @@
1
- # -*- encoding: utf-8 -*-
2
- # stub: bigcommerce 0.9.0 ruby lib
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'bigcommerce/version'
3
4
 
4
5
  Gem::Specification.new do |s|
5
- s.name = "bigcommerce"
6
- s.version = "0.10.0"
7
-
8
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
- s.authors = ["Mark Rickerby", "Rob Howard", "Saranyan Vigraham", "Sasha Gerrand"]
10
- s.date = "2015-01-27"
11
- s.description = "Enables Ruby applications to communicate with the Bigcommerce API V2."
6
+ s.name = 'bigcommerce'
7
+ s.homepage = 'https://github.com/bigcommerce/bigcommerce-api-ruby'
8
+ s.authors = ['Patrick Edelman']
9
+ s.version = Bigcommerce::VERSION
12
10
  s.license = 'MIT'
13
- s.email = ["mark.rickerby@bigcommerce.com", "rob.howard@bigcommerce.com", "saranyan.vigraham@bigcommerce.com", "sasha.gerrand@bigcommerce.com"]
14
- s.files = ["LICENSE", "Rakefile", "README.md", "bigcommerce.gemspec", "./lib/big_commerce.rb", "./lib/bigcommerce/api.rb", "./lib/bigcommerce/connection.rb", "./lib/bigcommerce/version.rb", "./lib/bigcommerce/resource.rb", "./lib/bigcommerce/product.rb", "./lib/bigcommerce.rb", "./spec/big_commerce_spec.rb", "./spec/integration/orders_spec.rb", "./spec/spec_helper.rb", "./spec/support/integration_context.rb", "./spec/support/mock_api_context.rb", "./spec/unit/api_request_spec.rb", "./spec/unit/api_spec.rb", "./spec/unit/connection_spec.rb", "./spec/unit/date_time_spec.rb", "./spec/unit/version_spec.rb", "spec/big_commerce_spec.rb", "spec/integration/orders_spec.rb", "spec/unit/api_request_spec.rb", "spec/unit/api_spec.rb", "spec/unit/connection_spec.rb", "spec/unit/date_time_spec.rb", "spec/unit/version_spec.rb"]
15
- s.homepage = "http://github.com/bigcommerce/bigcommerce-api-ruby"
16
- s.require_paths = ["lib"]
17
- s.rubygems_version = "2.1.11"
18
- s.summary = "Enables Ruby applications to communicate with the Bigcommerce API"
19
- s.test_files = ["spec/big_commerce_spec.rb", "spec/integration/orders_spec.rb", "spec/unit/api_request_spec.rb", "spec/unit/api_spec.rb", "spec/unit/connection_spec.rb", "spec/unit/date_time_spec.rb", "spec/unit/version_spec.rb"]
20
11
 
21
- if s.respond_to? :specification_version then
22
- s.specification_version = 4
12
+ s.description = 'Bigcommerce API Ruby client library. Allows developers to \
13
+ easily communicate with the Bigcommerce API, for either CLI tools or public \
14
+ apps. More info: http://developer.bigcommerce.com'
15
+ s.summary = 'Ruby client library for the Bigcommerce v2 API'
16
+
17
+ s.required_ruby_version = '>= 1.9.3'
18
+ s.require_paths = ['lib']
19
+ s.files = `git ls-files`.split($ORS)
20
+ s.test_files = Dir['spec/**/*.rb']
21
+
22
+ s.add_development_dependency 'rake'
23
+ s.add_development_dependency 'bundler'
23
24
 
24
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
- s.add_runtime_dependency(%q<activesupport>, [">= 0"])
26
- s.add_runtime_dependency(%q<json>, [">= 0"])
27
- s.add_runtime_dependency(%q<rest-client>, [">= 0"])
28
- s.add_development_dependency(%q<coveralls>, [">= 0"])
29
- s.add_development_dependency(%q<ci_reporter_rspec>, [">= 0"])
30
- s.add_development_dependency(%q<mocha>, [">= 0"])
31
- s.add_development_dependency(%q<rake>, [">= 0"])
32
- s.add_development_dependency(%q<rspec>, ["~> 2.11"])
33
- s.add_development_dependency(%q<vcr>, [">= 0"])
34
- s.add_development_dependency(%q<webmock>, ["= 1.9"])
35
- else
36
- s.add_dependency(%q<activesupport>, [">= 0"])
37
- s.add_dependency(%q<json>, [">= 0"])
38
- s.add_dependency(%q<rest-client>, [">= 0"])
39
- s.add_dependency(%q<coveralls>, [">= 0"])
40
- s.add_dependency(%q<ci_reporter_rspec>, [">= 0"])
41
- s.add_dependency(%q<mocha>, [">= 0"])
42
- s.add_dependency(%q<rake>, [">= 0"])
43
- s.add_dependency(%q<rspec>, ["~> 2.11"])
44
- s.add_dependency(%q<vcr>, [">= 0"])
45
- s.add_dependency(%q<webmock>, ["= 1.9"])
46
- end
47
- else
48
- s.add_dependency(%q<activesupport>, [">= 0"])
49
- s.add_dependency(%q<json>, [">= 0"])
50
- s.add_dependency(%q<rest-client>, [">= 0"])
51
- s.add_dependency(%q<coveralls>, [">= 0"])
52
- s.add_dependency(%q<ci_reporter_rspec>, [">= 0"])
53
- s.add_dependency(%q<mocha>, [">= 0"])
54
- s.add_dependency(%q<rake>, [">= 0"])
55
- s.add_dependency(%q<rspec>, ["~> 2.11"])
56
- s.add_dependency(%q<vcr>, [">= 0"])
57
- s.add_dependency(%q<webmock>, ["= 1.9"])
58
- end
25
+ s.add_dependency 'faraday'
26
+ s.add_dependency 'faraday_middleware'
27
+ s.add_dependency 'hashie'
59
28
  end
@@ -0,0 +1,148 @@
1
+ # Examples
2
+ In this directory you can find examples which you may find helpful to reference in development. If you have some useful snippets, please feel free to open a PR into the appropriate file(s).
3
+
4
+ #### Resource Reference
5
+ For reference on the individual resources and the schema of the objects, please visit [developer.bigcommerce.com](https://developer.bigcommerce.com).
6
+
7
+ ## Configuration
8
+ #### [Private Apps](configuration/legacy_auth.rb)
9
+ Public apps (also known as Single-Click Apps) must use OAuth authentication.
10
+
11
+ #### [Public Apps](configuration/oauth.rb)
12
+ To develop a custom integration for one store, your app needs to use Basic Authentication.
13
+
14
+ ## Content
15
+ #### [Blog Posts](content/blog_post.rb)
16
+ A content entry in the store’s blog
17
+
18
+ #### [Blog Tags](content/blog_tag.rb)
19
+ Index of tags used on the store’s blog.
20
+
21
+ #### [Redirects](content/redirect.rb)
22
+ A 301 redirect, mapping from a given URL path to another URL
23
+
24
+ ## Customers
25
+ #### [Customers](customers/customer.rb)
26
+ Identity and account details for customers shopping on Bigcommerce stores
27
+
28
+ #### [Customer Addresses](customers/customer_address.rb)
29
+ Postal address belonging to a Customer
30
+
31
+ #### [Customer Groups](customers/customer_group.rb)
32
+ Grouping of customers who share the same level of access and discounts at a store
33
+
34
+ ## Geography
35
+ #### [Countries](geography/country.rb)
36
+ A country or territory, identifiable by an ISO 3166 country code
37
+
38
+ #### [States](geography/state.rb)
39
+ A state or province, identifiable by an ISO 3166 subdivision code
40
+
41
+ ## Marketing
42
+ #### [Coupons](marketing/coupon.rb)
43
+ Applies a category or product discount to an order for customers who enter a given code
44
+
45
+ ## Orders
46
+ #### [Orders](orders/order.rb)
47
+ The order object contains a record of the purchase agreement between a shopper and a merchant.
48
+
49
+ #### [Order Coupons](orders/order_coupon.rb)
50
+ Coupon code applied to an order
51
+
52
+ #### [Order Messages](orders/order_message.rb)
53
+ Messages associated with an order.
54
+
55
+ #### [Order Products](orders/order_product.rb)
56
+ Product line items associated with an order.
57
+
58
+ #### [Order Shipping Addresses](orders/order_shipping_address.rb)
59
+ Shipping addresses associated with an order.
60
+
61
+ #### [Order Statuses](orders/order_status.rb)
62
+ Statuses that can be assigned to orders. Each status represents a state in the fulfilment workflow.
63
+
64
+ #### [Order Taxes](orders/order_tax.rb)
65
+ Taxes applied to an order.
66
+
67
+ #### [Shipments](orders/shipment.rb)
68
+ Shipping package consignments tracked from an order.
69
+
70
+ ## Payments
71
+ #### [Payment Methods](payments/payment_methods.rb)
72
+ Enabled payment methods.
73
+
74
+ ## Products
75
+ #### [Brands](products/brand.rb)
76
+ Brand facets for identifying and categorising products according to their manufacturer or company metonym.
77
+
78
+ #### [Bulk Pricing Rules](products/bulk_pricing_rule.rb)
79
+ Bulk pricing rules applied to a product.
80
+
81
+ #### [Categories](products/category.rb)
82
+ Index of hierarchical categories used to organise and group products.
83
+
84
+ #### [Configurable Fields ](products/configurable_field.rb)
85
+ Configurable fields associated with a product.
86
+
87
+ #### [Custom Fields](products/custom_field.rb)
88
+ Custom fields associated with a product.
89
+
90
+ #### [Google Product Search Mappings](products/google_product_search_mapping.rb)
91
+ Custom fields associated with a product.
92
+
93
+ #### [Options](products/option.rb)
94
+ Shared attributes that control value facets on a product.
95
+
96
+ #### [Option Sets](products/option_set.rb)
97
+ A reusable set of option facets that can be applied to products.
98
+
99
+ #### [Option Set Options](products/option_set_option.rb)
100
+ Options belonging to an option set.
101
+
102
+ #### [Option Values](products/option_value.rb)
103
+ Values that can be selected for an option.
104
+
105
+ #### [Products](products/product.rb)
106
+ Catalog of saleable items in the store.
107
+
108
+ #### [Product Images](products/product_image.rb)
109
+ Images associated with a product.
110
+
111
+ #### [Product Options](products/product_option.rb)
112
+ Options associated directly with a product.
113
+
114
+ #### [Product Reviews](products/product_review.rb)
115
+ Reviews associated to a product.
116
+
117
+ #### [Product Rules](products/product_rule.rb)
118
+ Rules that modify the default behaviour of products.
119
+
120
+ #### [Product Videos](products/product_video.rb)
121
+ Embedded videos displayed on product listings.
122
+
123
+ #### [SKUs](products/sku.rb)
124
+ Stock Keeping Unit identifiers associated with products.
125
+
126
+ ## Shipping
127
+ #### [Shipping Methods](shipping/shipping_method.rb)
128
+ List of enabled shipping methods.
129
+
130
+ ## Store
131
+ #### [Store Information](store/store_info.rb)
132
+ Metadata that describes the store.
133
+
134
+ ## System
135
+ #### [Time](system/time.rb)
136
+ Timestamp ping to check the system status.
137
+
138
+ ## Tax
139
+ #### [Tax Classes](tax/tax_class.rb)
140
+ Applies a category or product discount to an order for customers who enter a given code
141
+
142
+ ## Webhooks
143
+ #### [Webhooks](webhooks/webhook.rb)
144
+ Applies a category or product discount to an order for customers who enter a given code
145
+
146
+ ## Exception Handling
147
+ #### [Exceptions](exception_handling.rb)
148
+ All the errors we will throw with a convenient method to rescue the errors and take an action for each type
@@ -0,0 +1,12 @@
1
+ require 'bigcommerce'
2
+
3
+ Bigcommerce.configure do |config|
4
+ config.auth = 'legacy'
5
+ # You will get this url when registering for an API key
6
+ config.url = ENV['BC_API_ENDPOINT_LEGACY']
7
+ config.username = ENV['BC_USERNAME']
8
+ config.api_key = ENV['BC_API_KEY']
9
+ end
10
+
11
+ puts Bigcommerce::System.time
12
+ puts Bigcommerce.api_limit
@@ -0,0 +1,9 @@
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
+ puts Bigcommerce::System.time
@@ -0,0 +1,39 @@
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
+ # List blog posts
10
+ @posts = Bigcommerce::BlogPost.all(page: 1)
11
+ puts @posts
12
+
13
+ # Get a blog post
14
+ puts Bigcommerce::BlogPost.find(@posts[0].id)
15
+
16
+ # Get a count of blog posts
17
+ puts Bigcommerce::BlogPost.count
18
+
19
+ # Create a blog post
20
+ @post = Bigcommerce::BlogPost.create(
21
+ title: 'Brand new producrts for sale!',
22
+ body: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do \
23
+ eiusmod tempor incididunt ut labore et dolore magna aliqua. \
24
+ Excepteur sint occaecat cupidatat non proident, sunt in culpa qui \
25
+ officia deserunt mollit anim id est laborum.'
26
+ )
27
+ puts @post
28
+
29
+ # Update a blog post
30
+ puts Bigcommerce::BlogPost.update(
31
+ @post.id,
32
+ title: 'Oops wrong title.'
33
+ )
34
+
35
+ # Delete a blog post
36
+ puts Bigcommerce::BlogPost.destroy(@post.id)
37
+
38
+ # Delete all blog posts
39
+ # puts Bigcommerce::BlogPost.destroy_all
@@ -0,0 +1,10 @@
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
+ # List blog tags
10
+ puts Bigcommerce::BlogTag.all
@@ -0,0 +1,43 @@
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
+ # List redirects
10
+ @redirects = Bigcommerce::Redirect.all(page: 1)
11
+ puts @redirects
12
+
13
+ # Get a redirect
14
+ puts Bigcommerce::Redirect.find(@redirects[0].id)
15
+
16
+ # Get a count of redirects
17
+ puts Bigcommerce::Redirect.count
18
+
19
+ # Create a redirect
20
+ @redirect = Bigcommerce::Redirect.create(
21
+ path: '/womens_clothing',
22
+ forward: {
23
+ type: 'category',
24
+ ref: 3
25
+ }
26
+ )
27
+ puts @redirect
28
+
29
+ # Update a redirect
30
+ puts Bigcommerce::Redirect.update(
31
+ @redirect.id,
32
+ path: '/womens_clothing',
33
+ forward: {
34
+ type: 'category',
35
+ ref: 3
36
+ }
37
+ )
38
+
39
+ # Delete a redirect
40
+ puts Bigcommerce::Redirect.destroy(@redirect.id)
41
+
42
+ # Delete all redirects
43
+ # puts Bigcommerce::Redirect.destroy_all
@@ -0,0 +1,36 @@
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
+ # List customers
10
+ puts Bigcommerce::Customer.all(page: 1)
11
+
12
+ # Get a customer
13
+ puts Bigcommerce::Customer.find(1)
14
+
15
+ # Get a count of customers
16
+ puts Bigcommerce::Customer.count
17
+
18
+ # Create a customer
19
+ @customer = Bigcommerce::Customer.create(
20
+ first_name: 'Karl',
21
+ last_name: 'The Fog',
22
+ email: 'test@example.com'
23
+ )
24
+ puts @customer
25
+
26
+ # Update a customer
27
+ puts Bigcommerce::Customer.update(
28
+ @customer.id,
29
+ first_name: 'Karrrl'
30
+ )
31
+
32
+ # Delete a customer
33
+ puts Bigcommerce::Customer.destroy(@customer.id)
34
+
35
+ # Delete all customers
36
+ # puts Bigcommerce::Customer.destroy_all
@@ -0,0 +1,50 @@
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
+ @customer = Bigcommerce::Customer.all[0]
10
+
11
+ # List a customer address
12
+ @customer_addresses = Bigcommerce::CustomerAddress.all(@customer.id)
13
+ puts @customer_addresses
14
+
15
+ # Get a customer address
16
+ puts Bigcommerce::CustomerAddress.find(@customer.id, @customer_addresses[0].id)
17
+
18
+ # Get a count of customer addresses
19
+ puts Bigcommerce::CustomerAddress.count(@customer.id)
20
+
21
+ # Get a count of all customer addresses for all customers
22
+ puts Bigcommerce::CustomerAddress.count_all
23
+
24
+ # Create a customer address
25
+ @customer_address = Bigcommerce::CustomerAddress.create(
26
+ @customer.id,
27
+ first_name: 'Foo',
28
+ last_name: 'Bar',
29
+ phone: '5555555555',
30
+ street_1: '685 Market St.',
31
+ city: 'San Francisco',
32
+ state: 'California',
33
+ zip: '94019',
34
+ country: 'United States'
35
+ )
36
+ puts @customer_address
37
+
38
+ # Update a customer address
39
+ puts Bigcommerce::CustomerAddress.update(
40
+ @customer.id,
41
+ @customer_address.id,
42
+ first_name: 'Foo',
43
+ last_name: 'Bar'
44
+ )
45
+
46
+ # Delete a customer address
47
+ puts Bigcommerce::CustomerAddress.destroy(@customer.id, @customer_address.id)
48
+
49
+ # Delete all customer addresses
50
+ # puts Bigcommerce::CustomerAddress.destroy_all(@customer.id)