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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91c155920d961947d4e7a2184fa2ffad660590d636bd70723d9eec87d4709f3b
4
- data.tar.gz: dc8618135e2e88f8b2fa39954179d24ff56f435fa50185f4dd85baceb11684ef
3
+ metadata.gz: b85e649ea8b069cb792e147e901165cd5f81c8975ac434bf0182d369d07f0eb7
4
+ data.tar.gz: 89e5a3dff01013f56c51bf8aa5eaa3ef21c0af3e8304ccd6b2d72e4315d5117f
5
5
  SHA512:
6
- metadata.gz: d3790b83072b92e5477bcdf2dffe1d13ca0da2beb501706dac775307701b68efc39c5168852309990f5255501d87c8178674820b0e6072ffe4208b439081ec2a
7
- data.tar.gz: 411c3da75158d702890e5f764e44e708dabf2a713880f36af0283a40b05fff5b158eeea016a39b9253f1429dbb7322ec8c8737963696c3671fa960b65bcb394d
6
+ metadata.gz: c715fd627a137ff3a2a3e18d230bab0eeb0e4622574c123f08391fa483b3f342c34c68d8e05377d4db824997d76aaebaf6cb82145ae209c7658422db4a0e19a9
7
+ data.tar.gz: 61ed2eaa4b6d5bb724ded917e40a881187523d0cb9df63c87833d2eaa109bc0c165e7bc0510dd5388f5016ea6313454d7947698827a0a9d55b6395780fab60f4
data/README.md CHANGED
@@ -5,11 +5,11 @@
5
5
  [![Test Coverage](https://api.codeclimate.com/v1/badges/d1ba1b74a2a74a26e8b4/test_coverage)](https://codeclimate.com/github/bigcommerce/bigcommerce-api-ruby/test_coverage)
6
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/d1ba1b74a2a74a26e8b4/maintainability)](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 here: [developer.bigcommerce.com](http://developer.bigcommerce.com).
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', '~> 1.0'
22
+ gem 'bigcommerce', '~> 2.0'
23
23
  ```
24
24
 
25
25
  ## Requirements
26
26
 
27
- - Ruby 2.7.5 or newer (Ruby 3.0+ is preferred)
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://developer.bigcommerce.com/api/scopes).
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
- ### Basic Authentication (Legacy)
46
- To develop a custom integration for one store, your app needs to use Basic Authentication.
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
- __[More Information](https://developer.bigcommerce.com/api/legacy/basic-auth)__
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
- - ```client_id```: Obtained from the on the BigCommerce [Developer Portal's](http://developer.bigcommerce.com) "My Apps" section.
56
- - ```access_token```: Obtained after a token exchange in the auth callback.
57
- - ```store_hash```: Also obtained after the token exchange.
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
- __SSL Configuration__
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
- If you want to generate tokens for storefront login using the Customer Login API, you need to configure your app's
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
- - ```store_hash```: The store hash of the store you are operating against.
109
- - ```client_id```: Obtained from the on the BigCommerce [Developer Portal's](http://developer.bigcommerce.com) "My Apps" section.
110
- - ```client_secret```: Obtained from the on the BigCommerce [Developer Portal's](http://developer.bigcommerce.com) "My Apps" section.
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
- For full examples of using the API client, please see the [examples folder](examples) and refer to
122
- BigCommerce's [developer documentation](https://developer.bigcommerce.com/api).
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', '~> 1.1.0'
23
- s.add_dependency 'faraday_middleware', '~> 1.0'
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.use Faraday::Request::BasicAuthentication, config.username, config.api_key
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] = @options[:client_id]
17
- env[:request_headers][X_AUTH_TOKEN_HEADER] = @options[:access_token]
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::Response::Middleware
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
@@ -46,7 +46,7 @@ module Bigcommerce
46
46
  private
47
47
 
48
48
  def build_response_object(response)
49
- json = parse response.body
49
+ json = parse(response.body)
50
50
  if json.is_a? Array
51
51
  json.map { |obj| new obj }
52
52
  else
@@ -28,6 +28,7 @@ module Bigcommerce
28
28
  property :addresses
29
29
  property :tax_exempt_category
30
30
  property :accepts_marketing
31
+ property :form_fields
31
32
 
32
33
  def self.count(params = {})
33
34
  get 'customers/count', params
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bigcommerce
4
- VERSION = '1.1.0'
4
+ VERSION = '2.0.0'
5
5
  end
data/lib/bigcommerce.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'hashie'
4
- require 'faraday_middleware'
4
+ require 'faraday'
5
+ require 'faraday/gzip'
5
6
  require_relative 'bigcommerce/version'
6
7
  require_relative 'bigcommerce/config'
7
8
  require_relative 'bigcommerce/connection'
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: 1.1.0
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: 1.1.0
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: 1.1.0
31
+ version: '3.0'
26
32
  - !ruby/object:Gem::Dependency
27
- name: faraday_middleware
33
+ name: faraday-gzip
28
34
  requirement: !ruby/object:Gem::Requirement
29
35
  requirements:
30
36
  - - "~>"
31
37
  - !ruby/object:Gem::Version
32
- version: '1.0'
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: '1.0'
45
+ version: '3.0'
40
46
  - !ruby/object:Gem::Dependency
41
47
  name: hashie
42
48
  requirement: !ruby/object:Gem::Requirement