bigcommerce 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +32 -30
- data/bigcommerce.gemspec +2 -2
- data/lib/bigcommerce/connection.rb +2 -2
- data/lib/bigcommerce/middleware/auth.rb +10 -8
- data/lib/bigcommerce/middleware/http_exception.rb +7 -1
- data/lib/bigcommerce/request.rb +1 -1
- data/lib/bigcommerce/resources/customers/customer.rb +1 -0
- data/lib/bigcommerce/version.rb +1 -1
- data/lib/bigcommerce.rb +2 -1
- metadata +14 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b85e649ea8b069cb792e147e901165cd5f81c8975ac434bf0182d369d07f0eb7
|
|
4
|
+
data.tar.gz: 89e5a3dff01013f56c51bf8aa5eaa3ef21c0af3e8304ccd6b2d72e4315d5117f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c715fd627a137ff3a2a3e18d230bab0eeb0e4622574c123f08391fa483b3f342c34c68d8e05377d4db824997d76aaebaf6cb82145ae209c7658422db4a0e19a9
|
|
7
|
+
data.tar.gz: 61ed2eaa4b6d5bb724ded917e40a881187523d0cb9df63c87833d2eaa109bc0c165e7bc0510dd5388f5016ea6313454d7947698827a0a9d55b6395780fab60f4
|
data/README.md
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
[](https://codeclimate.com/github/bigcommerce/bigcommerce-api-ruby/test_coverage)
|
|
6
6
|
[](https://codeclimate.com/github/bigcommerce/bigcommerce-api-ruby/maintainability)
|
|
7
7
|
|
|
8
|
-
This is the official BigCommerce API client to support our Stores API. You can find more information about becoming a
|
|
9
|
-
BigCommerce developer
|
|
10
|
-
|
|
8
|
+
This is the official BigCommerce API client to support our Stores API. You can find more information about becoming a
|
|
9
|
+
BigCommerce developer on the [docs site](https://docs.bigcommerce.com).
|
|
11
10
|
|
|
12
11
|
## Installation
|
|
12
|
+
|
|
13
13
|
BigCommerce is available on [RubyGems](https://rubygems.org/gems/bigcommerce).
|
|
14
14
|
|
|
15
15
|
```sh
|
|
@@ -19,42 +19,41 @@ gem install bigcommerce
|
|
|
19
19
|
You can also add it to your Gemfile.
|
|
20
20
|
|
|
21
21
|
```rb
|
|
22
|
-
gem 'bigcommerce', '~>
|
|
22
|
+
gem 'bigcommerce', '~> 2.0'
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Requirements
|
|
26
26
|
|
|
27
|
-
- Ruby 2
|
|
27
|
+
- Ruby 3.2 or newer
|
|
28
28
|
|
|
29
29
|
## Getting Started
|
|
30
|
+
|
|
30
31
|
To make requests to our API, you must register as a developer and have your credentials ready.
|
|
31
32
|
|
|
32
33
|
Also very important: For the OAuth authentication mechanism, the resources to which you have acccess depend on the
|
|
33
|
-
scopes that the merchant has granted to your application. For more information about Store API scopes,
|
|
34
|
-
see: [OAuth Scopes](https://
|
|
34
|
+
scopes that the merchant has granted to your application. For more information about Store API scopes,
|
|
35
|
+
see: [OAuth Scopes](https://docs.bigcommerce.com/developer/docs/overview/api-fundamentals/api-accounts#oauth-scopes).
|
|
35
36
|
|
|
36
37
|
## Authentication
|
|
38
|
+
|
|
37
39
|
We currently have two different authentication schemes that you can select, depending on your use case.
|
|
38
40
|
|
|
39
41
|
### OAuth
|
|
40
|
-
OAuth apps can be submitted to [BigCommerce App Store](https://www.bigcommerce.com/apps), allowing other merchants to install these apps in their
|
|
41
|
-
BigCommerce stores.
|
|
42
|
-
|
|
43
|
-
__[More Information](https://developer.bigcommerce.com/api/using-oauth-intro)__
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
OAuth apps can be submitted to [BigCommerce App Store](https://www.bigcommerce.com/apps), allowing other merchants to install these apps in their
|
|
44
|
+
BigCommerce stores.
|
|
47
45
|
|
|
48
|
-
|
|
46
|
+
**[More Information](https://docs.bigcommerce.com/developer/docs/overview/api-fundamentals/api-accounts#authentication)**
|
|
49
47
|
|
|
50
48
|
## Configuration
|
|
49
|
+
|
|
51
50
|
To authenticate your API client, you will need to configure the client like the following examples.
|
|
52
51
|
|
|
53
52
|
### OAuth App
|
|
54
53
|
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
54
|
+
- `client_id`: Obtained from the on the BigCommerce [Developer Portal's](https://build.bigcommerce.com) Apps section.
|
|
55
|
+
- `access_token`: Obtained after a token exchange in the auth callback.
|
|
56
|
+
- `store_hash`: Also obtained after the token exchange.
|
|
58
57
|
|
|
59
58
|
```rb
|
|
60
59
|
Bigcommerce.configure do |config|
|
|
@@ -66,10 +65,9 @@ end
|
|
|
66
65
|
|
|
67
66
|
### Basic Authentication (Legacy)
|
|
68
67
|
|
|
69
|
-
To get all the basic auth credentials, simply visit your store admin page, and navigate to the
|
|
68
|
+
To get all the basic auth credentials, simply visit your store admin page, and navigate to the
|
|
70
69
|
`Advanced Settings` > `Legacy API Settings`. Once there, you can create a new legacy API account on which to authenticate.
|
|
71
70
|
|
|
72
|
-
|
|
73
71
|
```rb
|
|
74
72
|
Bigcommerce.configure do |config|
|
|
75
73
|
config.auth = 'legacy'
|
|
@@ -79,9 +77,9 @@ Bigcommerce.configure do |config|
|
|
|
79
77
|
end
|
|
80
78
|
```
|
|
81
79
|
|
|
82
|
-
|
|
80
|
+
**SSL Configuration**
|
|
83
81
|
|
|
84
|
-
If you are using your own, self-signed, certificate, you can pass SSL options to Faraday. This is not required, but
|
|
82
|
+
If you are using your own, self-signed, certificate, you can pass SSL options to Faraday. This is not required, but
|
|
85
83
|
might be useful in special edge cases.
|
|
86
84
|
|
|
87
85
|
```rb
|
|
@@ -102,12 +100,13 @@ For more information about configuring SSL with Faraday, please see the followin
|
|
|
102
100
|
- [Faraday: Setting up SSL certificates](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates)
|
|
103
101
|
|
|
104
102
|
### Customer Login API
|
|
105
|
-
|
|
103
|
+
|
|
104
|
+
If you want to generate tokens for storefront login using the Customer Login API, you need to configure your app's
|
|
106
105
|
client secret.
|
|
107
106
|
|
|
108
|
-
-
|
|
109
|
-
-
|
|
110
|
-
-
|
|
107
|
+
- `store_hash`: The store hash of the store you are operating against.
|
|
108
|
+
- `client_id`: Obtained from the on the BigCommerce [Developer Portal's](https://build.bigcommerce.com) Apps section.
|
|
109
|
+
- `client_secret`: Obtained from the on the BigCommerce [Developer Portal's](https://build.bigcommerce.com) Apps section.
|
|
111
110
|
|
|
112
111
|
```rb
|
|
113
112
|
Bigcommerce.configure do |config|
|
|
@@ -118,8 +117,9 @@ end
|
|
|
118
117
|
```
|
|
119
118
|
|
|
120
119
|
## Usage
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
|
|
121
|
+
For full examples of using the API client, please see the [examples folder](examples) and refer to
|
|
122
|
+
BigCommerce's [developer documentation](https://docs.bigcommerce.com/).
|
|
123
123
|
|
|
124
124
|
Example:
|
|
125
125
|
|
|
@@ -138,15 +138,15 @@ Bigcommerce::System.time
|
|
|
138
138
|
|
|
139
139
|
### Thread Safety
|
|
140
140
|
|
|
141
|
-
The `Bigcommerce.configure` method is NOT thread-safe. This mechanism is designed for applications or
|
|
141
|
+
The `Bigcommerce.configure` method is NOT thread-safe. This mechanism is designed for applications or
|
|
142
142
|
CLIs (command-line interfaces) where thread safety is not a concern. If you need to guarantee thread safety, we support
|
|
143
143
|
this alternative mechanism to make thread-safe API requests:
|
|
144
144
|
|
|
145
145
|
Rather then setting up a single `connection` for all API requests, construct a new connection for each thread.
|
|
146
|
-
If you can ensure that each of these connections is stored in a thread-safe manner, you can pass the `connection` as
|
|
146
|
+
If you can ensure that each of these connections is stored in a thread-safe manner, you can pass the `connection` as
|
|
147
147
|
you query the resource.
|
|
148
148
|
|
|
149
|
-
This connection is nothing more than a `Faraday::Connection` – so if you want to write your own, or to use your own
|
|
149
|
+
This connection is nothing more than a `Faraday::Connection` – so if you want to write your own, or to use your own
|
|
150
150
|
adapters, you can feel free. Please refer to this gem's [connection class](https://github.com/bigcommerce/bigcommerce-api-ruby/blob/master/lib/bigcommerce/connection.rb) for more details.
|
|
151
151
|
|
|
152
152
|
##### OAuth
|
|
@@ -189,7 +189,9 @@ Bigcommerce::System.raw_request(:get, 'time', connection: connection_legacy)
|
|
|
189
189
|
```
|
|
190
190
|
|
|
191
191
|
## Contributing
|
|
192
|
+
|
|
192
193
|
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
193
194
|
|
|
194
195
|
## License
|
|
196
|
+
|
|
195
197
|
See [LICENSE.md](LICENSE.md)
|
data/bigcommerce.gemspec
CHANGED
|
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
|
|
|
19
19
|
s.require_paths = ['lib']
|
|
20
20
|
s.files = Dir['README.md', 'lib/**/*', 'bigcommerce.gemspec']
|
|
21
21
|
|
|
22
|
-
s.add_dependency 'faraday', '
|
|
23
|
-
s.add_dependency '
|
|
22
|
+
s.add_dependency 'faraday', '>= 2.14', '< 3.0'
|
|
23
|
+
s.add_dependency 'faraday-gzip', '~> 3.0'
|
|
24
24
|
s.add_dependency 'hashie', '>= 3.4', '~> 4'
|
|
25
25
|
s.add_dependency 'jwt', '>= 1.5.4', '~> 2'
|
|
26
26
|
end
|
|
@@ -16,12 +16,12 @@ module Bigcommerce
|
|
|
16
16
|
conn.request :json
|
|
17
17
|
conn.headers = HEADERS
|
|
18
18
|
if config.auth == LEGACY_AUTH_MODE
|
|
19
|
-
conn.
|
|
19
|
+
conn.request :authorization, :basic, config.username, config.api_key
|
|
20
20
|
else
|
|
21
21
|
conn.use Bigcommerce::Middleware::Auth, config
|
|
22
22
|
end
|
|
23
|
+
conn.request :gzip
|
|
23
24
|
conn.use Bigcommerce::Middleware::HttpException
|
|
24
|
-
conn.use FaradayMiddleware::Gzip
|
|
25
25
|
conn.adapter Faraday.default_adapter
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -6,17 +6,19 @@ module Bigcommerce
|
|
|
6
6
|
X_AUTH_CLIENT_HEADER = 'X-Auth-Client'
|
|
7
7
|
X_AUTH_TOKEN_HEADER = 'X-Auth-Token'
|
|
8
8
|
|
|
9
|
-
def initialize(app, options = {})
|
|
10
|
-
@app = app
|
|
11
|
-
@options = options
|
|
12
|
-
super(app)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
9
|
def call(env)
|
|
16
|
-
env[:request_headers][X_AUTH_CLIENT_HEADER] =
|
|
17
|
-
env[:request_headers][X_AUTH_TOKEN_HEADER] =
|
|
10
|
+
env[:request_headers][X_AUTH_CLIENT_HEADER] = option_value(:client_id)
|
|
11
|
+
env[:request_headers][X_AUTH_TOKEN_HEADER] = option_value(:access_token)
|
|
18
12
|
@app.call env
|
|
19
13
|
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def option_value(key)
|
|
18
|
+
return @options[key] if @options.key?(key)
|
|
19
|
+
|
|
20
|
+
@options[key.to_s]
|
|
21
|
+
end
|
|
20
22
|
end
|
|
21
23
|
end
|
|
22
24
|
end
|
|
@@ -4,9 +4,15 @@ require 'bigcommerce/exception'
|
|
|
4
4
|
|
|
5
5
|
module Bigcommerce
|
|
6
6
|
module Middleware
|
|
7
|
-
class HttpException < Faraday::
|
|
7
|
+
class HttpException < Faraday::Middleware
|
|
8
8
|
include Bigcommerce::HttpErrors
|
|
9
9
|
|
|
10
|
+
def call(env)
|
|
11
|
+
@app.call(env).on_complete do |response_env|
|
|
12
|
+
on_complete(response_env)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
10
16
|
def on_complete(env)
|
|
11
17
|
throw_http_exception! env[:status].to_i, env
|
|
12
18
|
env
|
data/lib/bigcommerce/request.rb
CHANGED
data/lib/bigcommerce/version.rb
CHANGED
data/lib/bigcommerce.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bigcommerce
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- BigCommerce Engineering
|
|
@@ -13,30 +13,36 @@ dependencies:
|
|
|
13
13
|
name: faraday
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- - "
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.14'
|
|
19
|
+
- - "<"
|
|
17
20
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
21
|
+
version: '3.0'
|
|
19
22
|
type: :runtime
|
|
20
23
|
prerelease: false
|
|
21
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
25
|
requirements:
|
|
23
|
-
- - "
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '2.14'
|
|
29
|
+
- - "<"
|
|
24
30
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
31
|
+
version: '3.0'
|
|
26
32
|
- !ruby/object:Gem::Dependency
|
|
27
|
-
name:
|
|
33
|
+
name: faraday-gzip
|
|
28
34
|
requirement: !ruby/object:Gem::Requirement
|
|
29
35
|
requirements:
|
|
30
36
|
- - "~>"
|
|
31
37
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
38
|
+
version: '3.0'
|
|
33
39
|
type: :runtime
|
|
34
40
|
prerelease: false
|
|
35
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
42
|
requirements:
|
|
37
43
|
- - "~>"
|
|
38
44
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
45
|
+
version: '3.0'
|
|
40
46
|
- !ruby/object:Gem::Dependency
|
|
41
47
|
name: hashie
|
|
42
48
|
requirement: !ruby/object:Gem::Requirement
|