You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+14-2
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,23 @@
1
1
## Next Release
2
+
Your contribution here.
2
3
3
-
* Your contribution here.
4
-
*[#101](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/101): Fix #100 when exception and env.body is a string. - [@gregory](https://github.com/gregory).
Please note that this is the start of a new major release which breaks all backward compatibility.
8
8
9
+
*[#123](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/123): Add thread safe method to query resources - [@pedelman](https://github.com/pedelman).
10
+
*[#121](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/121): Update product resources and examples - [@pedelman](https://github.com/pedelman).
11
+
*[#122](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/122): Update order resources and examples - [@pedelman](https://github.com/pedelman).
12
+
*[#120](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/120): Add attributes to store information resource - [@pedelman](https://github.com/pedelman).
*[#113](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/113): Update SKU resource per developer docs - [@pedelman](https://github.com/pedelman).
19
+
*[#103](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/103): Add banner & gift cert resources - [@bc-AlyssNoland](https://github.com/bc-AlyssNoland).
20
+
*[#101](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/101): Fix #100 when exception and env.body is a string. - [@gregory](https://github.com/gregory).
9
21
*[#89](https://github.com/bigcommerce/bigcommerce-api-ruby/pull/89): Complete rewrite of Bigcommerce API Client. - [@pedelman](https://github.com/pedelman).
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).
10
-
11
-
#### :warning: A note about the current client: :warning:
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
-
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.
7
+
This is the official BigCommerce API client to support our Stores API. You can find more information about becoming a BigCommerce developer here: [developer.bigcommerce.com](http://developer.bigcommerce.com).
15
8
16
9
17
10
## Installation
18
-
Bigcommerce is available on Rubygems:
11
+
BigCommerce is available on [RubyGems](https://rubygems.org/gems/bigcommerce).
19
12
20
13
```sh
21
-
gem install bigcommerce --pre
14
+
gem install bigcommerce
22
15
```
23
16
24
17
You can also add it to your Gemfile.
25
18
26
19
```rb
27
-
gem 'bigcommerce', '>= 1.0.0.beta'
20
+
gem 'bigcommerce', '~> 1.0.0'
28
21
```
29
22
23
+
## Requirements
24
+
- Ruby 2.0.0 or newer. Please refer to the `.travis.yml` to see which versions we officially support.
25
+
30
26
## Getting Started
31
-
In order to make requests to our API, you must register as a developer and have your credentials ready.
27
+
In order to make requests to our API, you must register as a developer and have your credentials ready.
32
28
33
-
We currently have two different authentication schemes you can use depending on your use-case.
29
+
Its also very important to note that for the OAuth authentication mechanism, the resources you have acccess to depend on the scopes which your application has been granted by the merchant. For more information about the Store API scopes, see: [OAuth Scopes](https://developer.bigcommerce.com/api/scopes).
34
30
35
-
#### Public Apps
36
-
Public apps can be submitted to Bigcommerce App Store, allowing other businesses to install it in their Bigcommerce stores.
31
+
##Authentication
32
+
We currently have two different authentication schemes you can use depending on your use case.
OAuth apps can be submitted to [BigCommerce App Store](https://www.bigcommerce.com/apps), allowing other merchants to install it in their BigCommerce store.
39
36
40
-
#### Private Apps
41
-
To develop a custom integration for one store, your app needs to use Basic Authentication.
In order to authenticate the API client, you will need to configure the client like this:
45
+
In order to authenticate the API client, you will need to configure the client like the following.
50
46
51
-
#### Single Click (Public Apps):
47
+
###OAuth App
52
48
53
49
-```client_id```: Obtained from the "My Apps" section on the [developer portal](http://developer.bigcommerce.com).
54
50
-```access_token```: Obtained after a token exchange in the auth callback.
55
51
-```store_hash```: Also obtained after the token exchange.
56
52
57
53
```rb
58
54
Bigcommerce.configure do |config|
59
-
config.store_hash ='store_hash'
60
-
config.client_id ='client_id'
61
-
config.access_token ='access_token'
55
+
config.store_hash =ENV['BC_STORE_HASH']
56
+
config.client_id =ENV['BC_CLIENT_ID']
57
+
config.access_token =ENV['BC_ACCESS_TOKEN']
62
58
end
63
59
```
64
60
65
-
#### Private Apps:
61
+
###Basic Authentication (Legacy)
66
62
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.
63
+
To get all the basic auth credentials, simply visit your store admin page and navigate to the `Advanced Settings > Legacy API Settings`. Once there, you can create a new legacy api account to authenticate with.
68
64
69
65
```rb
70
66
Bigcommerce.configure do |config|
71
67
config.auth ='legacy'
72
-
config.url ='https://api_path.com'
73
-
config.username ='username'
74
-
config.api_key ='api_key'
68
+
config.url =ENV['BC_API_ENDPOINT_LEGACY']
69
+
config.username =ENV['BC_USERNAME']
70
+
config.api_key =ENV['BC_API_KEY']
75
71
end
76
72
```
77
73
78
-
__SSL Configuration:__
74
+
__SSL Configuration__
79
75
80
76
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.
81
77
@@ -96,5 +92,71 @@ For more information about configuring SSL with Faraday, please see the followin
-[Setting up SSL certificates](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates)
98
94
95
+
96
+
## Usage
97
+
For full examples on using the API client, please see the [examples folder](examples) and refer to the [developer documentation](https://developer.bigcommerce.com/api).
98
+
99
+
Example:
100
+
101
+
```rb
102
+
# Configure the client to talk to a given store
103
+
Bigcommerce.configure do |config|
104
+
config.store_hash =ENV['BC_STORE_HASH']
105
+
config.client_id =ENV['BC_CLIENT_ID']
106
+
config.access_token =ENV['BC_ACCESS_TOKEN']
107
+
end
108
+
109
+
# Make an API request for a given resource
110
+
Bigcommerce::System.time
111
+
=> #<Bigcommerce::System time=1466801314>
112
+
```
113
+
114
+
### Thread Safety
115
+
116
+
The `Bigcommerce.configure` method is NOT thread safe. This mechanism is designed for applications or cli where thread safety is not a concern. If you need to guarantee thread safety, we support another mechanism to make threadsafe API requests.
117
+
118
+
Rather then setting up a single `connection` for all API requests, you will want to construct a new connection for each thread. If you can make sure that each of these connections is stored in a thread safe manner, you can pass the `connection` as you query the resource.
119
+
120
+
This connection is nothing more than a `Faraday::Connection` so if you want to write your own, or use your own adapers, you can feel free. Please refer to the [connection class](https://github.com/bigcommerce/bigcommerce-api-ruby/blob/master/lib/bigcommerce/connection.rb) for more details.
0 commit comments