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,15 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ # http://docs.travis-ci.com/user/workers/container-based-infrastructure/
5
+ sudo: false
6
+
7
+ rvm:
8
+ - jruby-head
9
+ - ruby-head
10
+ - rbx-2.2.10
11
+ - 2.2.1
12
+ - 2.1.5
13
+ - 2.0.0
14
+ - 1.9.3
15
+ - jruby-19mode
@@ -0,0 +1,11 @@
1
+ ## Next Release
2
+
3
+ * Your contribution here.
4
+
5
+ ## 1.0.0
6
+ Please note that this is the start of a new major release which breaks all backward compatibility.
7
+
8
+ * [#89](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/89): Complete rewrite of Bigcommerce API Client. - [@pedelman](https://github.com/pedelman).
9
+
10
+ ## 0.x (Legacy)
11
+ For the old version of the API Client please view the [0.x branch](https://github.com/bigcommerce/bigcommerce-api-ruby/tree/0.x).
@@ -0,0 +1,119 @@
1
+ # Contributing to Bigcommerce
2
+
3
+
4
+ We would love to see contributors! You're encouraged to submit [pull requests](https://github.com/bigcommerce/bigcommerce-api-ruby/pulls), [propose features, and discuss issues](https://github.com/bigcommerce/bigcommerce-api-ruby/issues).
5
+
6
+ #### Fork the Project
7
+
8
+ Fork the [project on Github](https://github.com/bigcommerce/bigcommerce-api-ruby) and check out your copy.
9
+
10
+ ```
11
+ git clone your_forked_version_of_bigcommerce_api_ruby
12
+ cd bigcommerce-api-ruby
13
+ git remote add upstream https://github.com/bigcommerce/bigcommerce-api-ruby.git
14
+ ```
15
+
16
+ #### Create a Feature Branch
17
+
18
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
19
+
20
+ ```
21
+ git checkout master
22
+ git pull upstream master
23
+ git checkout -b my-feature-branch
24
+ ```
25
+
26
+ #### Bundle Install and Test
27
+
28
+ Ensure that you can build the project and run tests.
29
+
30
+ ```
31
+ bundle install
32
+ bundle exec rake
33
+ ```
34
+
35
+ #### Installing the gem locally (useful to run examples)
36
+
37
+ This will build the gem locally into the pkg directory, you can then install it manually by targeting that directory specifically.
38
+
39
+ ```
40
+ bundle exec rake build
41
+ gem install pkg/bigcommerce-1.x.x.gem
42
+ ```
43
+
44
+ #### Write Tests
45
+
46
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/bigcommerce](spec/bigcommerce).
47
+
48
+ We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
49
+
50
+ #### Write Code
51
+
52
+ Implement your feature or bug fix.
53
+
54
+ Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop), run `bundle exec rubocop` and fix any style issues highlighted.
55
+
56
+ Make sure that `bundle exec rake` completes without errors.
57
+
58
+ #### Write Documentation
59
+
60
+ Document any external behavior in the [README](README.md).
61
+
62
+ #### Update Changelog
63
+
64
+ Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account.
65
+
66
+ #### Commit Changes
67
+
68
+ Make sure git knows your name and email address:
69
+
70
+ ```
71
+ git config --global user.name "Your Name"
72
+ git config --global user.email "contributor@example.com"
73
+ ```
74
+
75
+ Writing good commit logs is important. A commit log should describe what changed and why.
76
+
77
+ ```
78
+ git add ...
79
+ git commit
80
+ ```
81
+
82
+ #### Push
83
+
84
+ ```
85
+ git push origin my-feature-branch
86
+ ```
87
+
88
+ #### Make a Pull Request
89
+
90
+ Go to https://github.com/contributor/bigcommerce-api-ruby and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
91
+
92
+ #### Rebase
93
+
94
+ If you've been working on a change for a while, rebase with upstream/master.
95
+
96
+ ```
97
+ git fetch upstream
98
+ git rebase upstream/master
99
+ git push origin my-feature-branch -f
100
+ ```
101
+
102
+ #### Update CHANGELOG Again
103
+
104
+ Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
105
+
106
+ ```
107
+ * [#123](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/123): Added products resource - [@contributor](https://github.com/contributor).
108
+ ```
109
+
110
+ Amend your previous commit and force push the changes.
111
+
112
+ ```
113
+ git commit --amend
114
+ git push origin my-feature-branch -f
115
+ ```
116
+
117
+ #### Check on Your Pull Request
118
+
119
+ Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
@@ -0,0 +1,7 @@
1
+ ### Bigcommerce 💙 Open Source
2
+
3
+ Many thanks to the contributors and authors of the following libraries!
4
+
5
+ - [Faraday](https://github.com/lostisland/faraday) Simple, but flexible HTTP client library, with support for multiple backends. - [MIT](https://github.com/lostisland/faraday/blob/master/LICENSE.md)
6
+ - [Faraday Middleware](https://github.com/lostisland/faraday_middleware) Various Faraday middlewares for Faraday-based API wrappers. - [MIT](https://github.com/lostisland/faraday_middleware/blob/master/LICENSE.md)
7
+ - [Hashie](https://github.com/intridea/hashie) Hashie is a collection of classes and mixins that make hashes more powerful. - [MIT](https://github.com/intridea/hashie/blob/master/LICENSE)
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ group :development do
5
+ gem 'pry'
6
+ gem 'rubocop'
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ end
10
+
11
+ group :test do
12
+ gem 'rspec'
13
+ gem 'simplecov'
14
+ gem 'coveralls'
15
+ end
@@ -0,0 +1,22 @@
1
+ guard 'rspec', all_on_start: false, cmd: 'bundle exec rspec' do
2
+ # Watch spec directory
3
+ watch(/^spec\/.+_spec\.rb/)
4
+
5
+ # Watch lib/*.rb
6
+ watch(/^lib\/(.+)\.rb/) do |m|
7
+ "spec/bigcommerce/#{m[1]}_spec.rb"
8
+ end
9
+
10
+ # Watch lib/bigcommerce/*.rb
11
+ watch(%r{^lib/bigcommerce/(.+).rb$}) do |m|
12
+ "spec/bigcommerce/unit/#{m[1]}_spec.rb"
13
+ end
14
+
15
+ # Watch lib/bigcommerce/(middleware|resources)/*.rb
16
+ watch(%r{^lib/bigcommerce/(middleware|resources)/(.+).rb$}) do |m|
17
+ "spec/bigcommerce/unit/#{m[1]}/#{m[2]}_spec.rb"
18
+ end
19
+
20
+ # Watch spec_helper
21
+ watch('spec/spec_helper.rb') { 'spec' }
22
+ end
data/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
1
  Copyright (C) Bigcommerce, 2015.
2
2
  All rights reserved.
3
3
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is
9
- furnished to do so, subject to the following conditions:
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the "Software"),
6
+ to deal in the Software without restriction, including without limitation
7
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
+ and/or sell copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following conditions:
10
10
 
11
- The above copyright notice and this permission notice shall be included in
12
- all copies or substantial portions of the Software.
11
+ The above copyright notice and this permission notice shall be included
12
+ in all copies or substantial portions of the Software.
13
13
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- THE SOFTWARE.
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
20
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Bigcommerce API V2 - Ruby Client
1
+ # Bigcommerce
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/bigcommerce.png)](https://rubygems.org/gems/bigcommerce)
4
4
  [![Build Status](https://travis-ci.org/bigcommerce/bigcommerce-api-ruby.png?branch=master)](https://travis-ci.org/bigcommerce/bigcommerce-api-ruby)
@@ -6,104 +6,95 @@
6
6
  [![Code Climate](https://codeclimate.com/github/bigcommerce/bigcommerce-api-ruby.png)](https://codeclimate.com/github/bigcommerce/bigcommerce-api-ruby)
7
7
  [![Coverage Status](https://coveralls.io/repos/bigcommerce/bigcommerce-api-ruby/badge.png?branch=master)](https://coveralls.io/r/bigcommerce/bigcommerce-api-ruby?branch=master)
8
8
 
9
- This library provides a wrapper around the Bigcommerce REST API for use within
10
- Ruby apps or via the console.
9
+ This is the official Bigcommerce API client to support our Rest API. You can find more information about becoming a Bigcommerce developer here: [developer.bigcommerce.com](http://developer.bigcommerce.com).
11
10
 
12
- ### Note
11
+ #### ⚠️ A note about the current client: ⚠️
12
+ This is a preview release of the 1.0.0 version of the Bigcommerce API Client. Please report issues if they come up.
13
13
 
14
- If you find anything that is missing or needs clean up, please feel free to fork
15
- it and submit a changes with your pull request.
14
+ We have introduced a new major version of the API client and it is a complete rewrite (for the better). If you want to see the old version of the API client, please view it here: [Bigcommerce API client v0.x](https://github.com/bigcommerce/bigcommerce-api-ruby/tree/0.x). We recommend that developers upgrade to the latest client, but we will still support our developers who are unable to upgrade.
16
15
 
17
- ## Requirements
18
16
 
19
- - Ruby 1.9+
17
+ ## Installation
18
+ Bigcommerce is available on Rubygems:
20
19
 
21
- To connect to the API, you need the following credentials:
20
+ ```sh
21
+ gem install bigcommerce --pre
22
+ ```
22
23
 
23
- For the OAuth API:
24
+ You can also add it to your Gemfile.
24
25
 
25
- - Create and register an app at [developer.bigcommerce.com](https://developer.bigcommerce.com).
26
- - Have a callback URL defined
27
- - Prepare the `client_id` credential
26
+ ```rb
27
+ gem 'bigcommerce', '>= 1.0.0.beta'
28
+ ```
28
29
 
29
- For the Legacy API:
30
+ ## Getting Started
31
+ In order to make requests to our API, you must register as a developer and have your credentials ready.
30
32
 
31
- - Secure URL pointing to a Bigcommerce store
32
- - Username of an authorized admin user of the store
33
- - API key for the user
33
+ We currently have two different authentication schemes you can use depending on your use-case.
34
34
 
35
- A valid API key is required to authenticate requests. To grant API access for a user, go to Control Panel > Users > Edit User and make sure that the 'Enable API access?' checkbox is ticked.
35
+ #### Public Apps
36
+ Public apps can be submitted to Bigcommerce App Store, allowing other businesses to install it in their Bigcommerce stores.
36
37
 
37
- ## Installation
38
+ [More Information](https://developer.bigcommerce.com/api/using-oauth-intro)
38
39
 
39
- Download the lib folder and copy it to a path accessible within your app, or
40
- install the package directly from Rubygems:
40
+ #### Private Apps
41
+ To develop a custom integration for one store, your app needs to use Basic Authentication.
41
42
 
42
- ```sh
43
- gem install bigcommerce
44
- ```
43
+ [More Information](https://developer.bigcommerce.com/api/legacy/basic-auth)
45
44
 
46
- ## Configuration
45
+ ## Usage
46
+ For full examples on using the API client, please see the [examples folder](examples).
47
47
 
48
- #### OAuth Authentication
48
+ ## Configuration
49
+ In order to authenticate the API client, you will need to configure the client like this:
49
50
 
50
- In order to create a new Bigcommerce application, please visit [developer.bigcommerce.com](https://developer.bigcommerce.com). Its free to sign up and only takes a moment. Once you have created your app, you can get a `client_id`.
51
+ #### Single Click (Public Apps):
51
52
 
52
- To use the API client in your Ruby code, provide the required credentials as
53
- follows:
53
+ - ```client_id```: Obtained from the "My Apps" section on the [developer portal](http://developer.bigcommerce.com).
54
+ - ```access_token```: Obtained after a token exchange in the auth callback.
55
+ - ```store_hash```: Also obtained after the token exchange.
54
56
 
55
57
  ```rb
56
- require 'bigcommerce'
57
-
58
- api = Bigcommerce::Api.new({
59
- :store_hash => 'STORE_HASH',
60
- :client_id => 'CLIENT_ID',
61
- :access_token => 'ACCESS_TOKEN'
62
- })
58
+ Bigcommerce.configure do |config|
59
+ config.store_hash = 'store_hash'
60
+ config.client_id = 'client_id'
61
+ config.access_token = 'access_token'
62
+ end
63
63
  ```
64
64
 
65
- __NOTE:__ You do not need extra SSL certificates when connecting to the OAuth version of the api.
66
-
67
- #### Legacy Credentials
65
+ #### Private Apps:
68
66
 
69
- To use the API client with the legacy credentials you can visit the main store page and under the "Setup & Tools" dropdown, you will see a link for the legacy API credentials.
67
+ To get all the private app credentials, simply visit your store admin page and navigate to the Settings > Legacy API Settings. Once there, you can create a new username to authenticate with.
70
68
 
71
69
  ```rb
72
- require 'bigcommerce'
73
-
74
- api = Bigcommerce::Api.new({
75
- :store_url => "https://store.mybigcommerce.com",
76
- :username => "username",
77
- :api_key => "api_key"
78
- })
70
+ Bigcommerce.configure do |config|
71
+ config.auth = 'legacy'
72
+ config.url = 'https://api_path.com'
73
+ config.username = 'username'
74
+ config.api_key = 'api_key'
75
+ end
79
76
  ```
80
77
 
81
- You can also enable SSL for the Legacy API.
78
+ __SSL Configuration:__
82
79
 
83
- ```rb
84
- require 'bigcommerce'
85
-
86
- api = Bigcommerce::Api.new({
87
- :store_url => "https://store.mybigcommerce.com",
88
- :username => "username",
89
- :api_key => "api_key",
90
- :ssl_client_cert => OpenSSL::X509::Certificate.new(File.read("cert.pem")),
91
- :ssl_client_key => OpenSSL::PKey::RSA.new(File.read("key.pem"), "passphrase, if any"),
92
- :ssl_ca_file => "ca_certificate.pem",
93
- :verify_ssl => OpenSSL::SSL::VERIFY_PEER
94
- })
95
- ```
96
- Remember that the fields `:ssl_client_cert`, `:ssl_client_key`, `:ssl_ca_file`
97
- and `:verify_ssl` are all required when enabling SSL certificates.
98
-
99
- ## Connecting to the store
100
-
101
- Once you have authenticated with the OAuth or Legacy credentials, ping the time method to check that your configuration is working and you can connect successfully to the store:
80
+ If you are using your own self-signed certificate, you can pass SSL options to Faraday. This is not required, but may be useful in special edge cases.
102
81
 
103
82
  ```rb
104
- ping = api.time()
83
+ Bigcommerce.configure do |config|
84
+ config.auth = 'legacy'
85
+ config.url = 'https://api_path.com'
86
+ config.username = 'username'
87
+ config.api_key = 'api_key'
88
+ config.ssl = {
89
+ # Faraday options here
90
+ }
91
+ end
105
92
  ```
106
93
 
107
- ## Reference
94
+ For more information about configuring SSL with Faraday, please see the following:
95
+
96
+ - [Faraday SSL example](https://gist.github.com/mislav/938183)
97
+ - [Setting up SSL certificates](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates)
108
98
 
109
- For full reference about the resources and supported endpoints, please see [developer.bigcommerce.com](https://developer.bigcommerce.com).
99
+ ## Contributing
100
+ See [CONTRIBUTING.md](CONTRIBUTING.md)
@@ -0,0 +1,64 @@
1
+ # Releasing Bigcommerce API Client
2
+
3
+ There're no particular rules about when to release the Bigcommerce API client. Release bug fixes frequently, features not so frequently, and breaking API changes rarely.
4
+
5
+ ### Before A Release
6
+
7
+ Run tests, check that all tests succeed locally.
8
+
9
+ ```sh
10
+ bundle install
11
+ bundle exec rake
12
+ ```
13
+
14
+ This will ensure both style and that all the specs pass locally. Next, check that the last build succeeded in [Travis CI](https://travis-ci.org/bigcommerce/bigcommerce-api-ruby) for all supported platforms.
15
+
16
+ Increment the version, modify [lib/bigcommerce/version.rb](lib/bigcommerce/version.rb).
17
+
18
+ * Increment the third number (minor version) if the release has bug fixes and/or very minor features, only (eg. change `1.0.1` to `1.0.2`).
19
+ * Increment the second number (patch version) if the release contains major features or breaking API changes (eg. change `1.0.10` to `1.1.0`).
20
+
21
+ Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
22
+
23
+ ```markdown
24
+ 1.1.0 (4/13/2015)
25
+ =================
26
+ ```
27
+
28
+ Commit your changes.
29
+
30
+ ```sh
31
+ git add CHANGELOG.md lib/bigcommerce/version.rb
32
+ git commit -m "Preparing for release, 1.1.0."
33
+ git push origin master
34
+ ```
35
+
36
+ ### Release 🎉
37
+
38
+ ```sh
39
+ $ rake release
40
+
41
+ bigcommerce 1.1.0 built to pkg/bigcommerce-1.1.0.gem.
42
+ Tagged v1.1.0.
43
+ Pushed git commits and tags.
44
+ Pushed bigcommerce 1.1.0 to rubygems.org.
45
+ ```
46
+
47
+ ### Prepare for the Next Version
48
+
49
+ Add the next release to [CHANGELOG.md](CHANGELOG.md).
50
+
51
+ ```markdown
52
+ Next Release
53
+ ============
54
+
55
+ * Your contribution here.
56
+ ```
57
+
58
+ Commit your changes.
59
+
60
+ ```sh
61
+ git add CHANGELOG.md README.md
62
+ git commit -m "Preparing for next release."
63
+ git push origin master
64
+ ```