bigcommerce 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 699fc230ea09d9242c9cbfb7e1d2183891127627
4
- data.tar.gz: 94e9e4eeb4a9b8cdf53ff2bd26f78612d8457d25
3
+ metadata.gz: f89e22fe6e4042c5231912f0594eccc6e20cf2d2
4
+ data.tar.gz: e72dc04e6ea9894c47740882e89edfc14ceb84ae
5
5
  SHA512:
6
- metadata.gz: 131581aaa53a9933c978f7649530128857e7a46e467c091b77effc27828ca895388bc78edfdd0cf5bb58bb14f8041a55417b90f52af98aab82480c3748563cc0
7
- data.tar.gz: 88d65c0fa84ad4d4968e58b7780eaac14408d5ad123eafe1c1b158c04822ade1007cbf3c460c95235765efdb548baa0c34a4778b9a60283b8f45c4efa07479a1
6
+ metadata.gz: ab56f2ab83b837201fc23c4e749633b47702a0ef48d081854b14ce220760f130675200a1513f2a8ba516419a2cf44b2e2da120289ab458130de333e5756f8077
7
+ data.tar.gz: b35e6c9009776ad58a0565d8d8785de254dfba5f1cadd10980c8c133d7fa70038485008c15bbcd6cf9f5f11f8e886b940c45ce269cb8e9a51e995207a70a53c9
data/README.md CHANGED
@@ -17,22 +17,22 @@ gem install bigcommerce
17
17
  You can also add it to your Gemfile.
18
18
 
19
19
  ```rb
20
- gem 'bigcommerce', '~> 1.0.0'
20
+ gem 'bigcommerce', '~> 1.0'
21
21
  ```
22
22
 
23
23
  ## Requirements
24
24
  - Ruby 2.0.0 or newer. Please refer to the `.travis.yml` to see which versions we officially support.
25
25
 
26
26
  ## Getting Started
27
- In order to make requests to our API, you must register as a developer and have your credentials ready.
27
+ To make requests to our API, you must register as a developer and have your credentials ready.
28
28
 
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).
29
+ Also very important: For the OAuth authentication mechanism, the resources to which you have acccess depend on the scopes that the merchant has granted to your application. For more information about Store API scopes, see: [OAuth Scopes](https://developer.bigcommerce.com/api/scopes).
30
30
 
31
31
  ## Authentication
32
- We currently have two different authentication schemes you can use depending on your use case.
32
+ We currently have two different authentication schemes that you can select, depending on your use case.
33
33
 
34
34
  ### OAuth
35
- OAuth apps can be submitted to [BigCommerce App Store](https://www.bigcommerce.com/apps), allowing other merchants to install it in their BigCommerce store.
35
+ OAuth apps can be submitted to [BigCommerce App Store](https://www.bigcommerce.com/apps), allowing other merchants to install these apps in their BigCommerce stores.
36
36
 
37
37
  __[More Information](https://developer.bigcommerce.com/api/using-oauth-intro)__
38
38
 
@@ -42,11 +42,11 @@ To develop a custom integration for one store, your app needs to use Basic Authe
42
42
  __[More Information](https://developer.bigcommerce.com/api/legacy/basic-auth)__
43
43
 
44
44
  ## Configuration
45
- In order to authenticate the API client, you will need to configure the client like the following.
45
+ To authenticate your API client, you will need to configure the client like the following examples.
46
46
 
47
47
  ### OAuth App
48
48
 
49
- - ```client_id```: Obtained from the "My Apps" section on the [developer portal](http://developer.bigcommerce.com).
49
+ - ```client_id```: Obtained from the on the BigCommerce [Developer Portal's](http://developer.bigcommerce.com) "My Apps" section.
50
50
  - ```access_token```: Obtained after a token exchange in the auth callback.
51
51
  - ```store_hash```: Also obtained after the token exchange.
52
52
 
@@ -60,7 +60,7 @@ end
60
60
 
61
61
  ### Basic Authentication (Legacy)
62
62
 
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.
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 on which to authenticate.
64
64
 
65
65
  ```rb
66
66
  Bigcommerce.configure do |config|
@@ -73,7 +73,7 @@ end
73
73
 
74
74
  __SSL Configuration__
75
75
 
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.
76
+ If you are using your own, self-signed, certificate, you can pass SSL options to Faraday. This is not required, but might be useful in special edge cases.
77
77
 
78
78
  ```rb
79
79
  Bigcommerce.configure do |config|
@@ -90,11 +90,25 @@ end
90
90
  For more information about configuring SSL with Faraday, please see the following:
91
91
 
92
92
  - [Faraday SSL example](https://gist.github.com/mislav/938183)
93
- - [Setting up SSL certificates](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates)
93
+ - [Faraday: Setting up SSL certificates](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates)
94
94
 
95
+ ### Customer Login API
96
+ If you want to generate tokens for storefront login using the Customer Login API, you need to configure your app's client secret.
97
+
98
+ - ```store_hash```: The store hash of the store you are operating against.
99
+ - ```client_id```: Obtained from the on the BigCommerce [Developer Portal's](http://developer.bigcommerce.com) "My Apps" section.
100
+ - ```client_secret```: Obtained from the on the BigCommerce [Developer Portal's](http://developer.bigcommerce.com) "My Apps" section.
101
+
102
+ ```rb
103
+ Bigcommerce.configure do |config|
104
+ config.store_hash = ENV['BC_STORE_HASH']
105
+ config.client_id = ENV['BC_CLIENT_ID']
106
+ config.client_secret = ENV['BC_CLIENT_SECRET']
107
+ end
108
+ ```
95
109
 
96
110
  ## 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).
111
+ For full examples of using the API client, please see the [examples folder](examples) and refer to BigCommerce's [developer documentation](https://developer.bigcommerce.com/api).
98
112
 
99
113
  Example:
100
114
 
@@ -113,19 +127,19 @@ Bigcommerce::System.time
113
127
 
114
128
  ### Thread Safety
115
129
 
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.
130
+ The `Bigcommerce.configure` method is NOT thread-safe. This mechanism is designed for applications or CLI's (command-line interfaces) where thread safety is not a concern. If you need to guarantee thread safety, we support this alternative mechanism to make thread-safe API requests:
117
131
 
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.
132
+ Rather then setting up a single `connection` for all API requests, you would construct a new connection for each thread. If you can ensure that each of these connections is stored in a thread-safe manner, you can pass the `connection` as you query the resource.
119
133
 
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.
134
+ This connection is nothing more than a `Faraday::Connection` so if you want to write your own, or to use your own 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.
121
135
 
122
136
  ##### OAuth
123
137
 
124
138
  ```rb
125
139
  connection = Bigcommerce::Connection.build(
126
140
  Bigcommerce::Config.new(
127
- store_hash: ENV['BC_STORE_HASH'],
128
- client_id: ENV['BC_CLIENT_ID'],
141
+ store_hash: ENV['BC_STORE_HASH'],
142
+ client_id: ENV['BC_CLIENT_ID'],
129
143
  access_token: ENV['BC_ACCESS_TOKEN']
130
144
  )
131
145
  )
@@ -143,7 +157,7 @@ Bigcommerce::System.raw_request(:get, 'time', connection: connection)
143
157
  ```rb
144
158
  connection_legacy = Bigcommerce::Connection.build(
145
159
  Bigcommerce::Config.new(
146
- auth: 'legacy',
160
+ auth: 'legacy',
147
161
  url: ENV['BC_API_ENDPOINT_LEGACY'],
148
162
  username: ENV['BC_USERNAME'],
149
163
  api_key: ENV['BC_API_KEY']
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.required_ruby_version = '>= 2.0.0'
10
10
  s.license = 'MIT'
11
11
 
12
- s.authors = ['Patrick Edelman']
12
+ s.authors = ['BigCommerce Engineering']
13
13
  s.homepage = 'https://github.com/bigcommerce/bigcommerce-api-ruby'
14
14
  s.summary = 'Ruby client library for the BigCommerce API'
15
15
  s.description = s.summary
@@ -20,7 +20,8 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency 'bundler'
21
21
  s.add_development_dependency 'rake'
22
22
 
23
- s.add_dependency 'faraday', '~> 0.9'
24
- s.add_dependency 'faraday_middleware', '~> 0.10.0'
23
+ s.add_dependency 'faraday', '~> 0.11'
24
+ s.add_dependency 'faraday_middleware', '~> 0.11'
25
25
  s.add_dependency 'hashie', '~> 3.4'
26
+ s.add_dependency 'jwt', '~> 1.5.4'
26
27
  end
@@ -12,7 +12,7 @@ module Bigcommerce
12
12
  Dir.glob(resources, &method(:require))
13
13
 
14
14
  class << self
15
- attr_reader :api
15
+ attr_reader :api, :config
16
16
 
17
17
  def configure
18
18
  @config = Bigcommerce::Config.new.tap { |h| yield(h) }
@@ -3,11 +3,12 @@ module Bigcommerce
3
3
  HEADERS = {
4
4
  'accept' => 'application/json',
5
5
  'content-type' => 'application/json',
6
- 'user-agent' => 'bigcommerce-api-ruby'
6
+ 'user-agent' => 'bigcommerce-api-ruby',
7
+ 'accept-encoding' => 'gzip'
7
8
  }.freeze
8
9
 
9
10
  def self.build(config)
10
- ssl_options = config.ssl if config.auth == 'legacy'
11
+ ssl_options = config.ssl || {}
11
12
  Faraday.new(url: config.api_url, ssl: ssl_options) do |conn|
12
13
  conn.request :json
13
14
  conn.headers = HEADERS
@@ -17,6 +18,7 @@ module Bigcommerce
17
18
  conn.use Bigcommerce::Middleware::Auth, config
18
19
  end
19
20
  conn.use Bigcommerce::Middleware::HttpException
21
+ conn.use FaradayMiddleware::Gzip
20
22
  conn.adapter Faraday.default_adapter
21
23
  end
22
24
  end
@@ -45,7 +45,7 @@ module Bigcommerce
45
45
  unless env.body.empty?
46
46
  response_headers = begin
47
47
  JSON.parse(env.body, symbolize_names: true)
48
- rescue
48
+ rescue StandardError
49
49
  {}
50
50
  end
51
51
  end
@@ -1,3 +1,6 @@
1
+ require 'jwt'
2
+ require 'securerandom'
3
+
1
4
  # Customer
2
5
  # Identity and account details for customers shopping at a Bigcommerce store.
3
6
  # https://developer.bigcommerce.com/api/stores/v2/customers
@@ -22,9 +25,26 @@ module Bigcommerce
22
25
  property :notes
23
26
  property :addresses
24
27
  property :tax_exempt_category
28
+ property :accepts_marketing
25
29
 
26
30
  def self.count(params = {})
27
31
  get 'customers/count', params
28
32
  end
33
+
34
+ # Generate a token that can be used to log the customer into the storefront.
35
+ # This requires your app to have the store_v2_customers_login scope and to
36
+ # be installed in the store.
37
+ def login_token(config: Bigcommerce.config)
38
+ payload = {
39
+ 'iss' => config.client_id,
40
+ 'iat' => Time.now.to_i,
41
+ 'jti' => SecureRandom.uuid,
42
+ 'operation' => 'customer_login',
43
+ 'store_hash' => config.store_hash,
44
+ 'customer_id' => id
45
+ }
46
+
47
+ JWT.encode(payload, config.client_secret, 'HS256')
48
+ end
29
49
  end
30
50
  end
@@ -6,7 +6,7 @@ module Bigcommerce
6
6
  class Country < Resource
7
7
  include Bigcommerce::ResourceActions.new(
8
8
  uri: 'countries/%d',
9
- disable: [:create, :update, :destroy, :destroy_all]
9
+ disable: %i[create update destroy destroy_all]
10
10
  )
11
11
 
12
12
  property :id
@@ -6,7 +6,7 @@ module Bigcommerce
6
6
  class State < Resource
7
7
  include Bigcommerce::SubresourceActions.new(
8
8
  uri: 'countries/%d/states/%d',
9
- disable: [:create, :update, :destroy, :destroy_all]
9
+ disable: %i[create update destroy destroy_all]
10
10
  )
11
11
 
12
12
  property :id
@@ -6,7 +6,7 @@ module Bigcommerce
6
6
  class OrderCoupon < Resource
7
7
  include Bigcommerce::SubresourceActions.new(
8
8
  uri: 'orders/%d/coupons/%d',
9
- disable: [:create, :update, :destroy, :destroy_all]
9
+ disable: %i[create update destroy destroy_all]
10
10
  )
11
11
 
12
12
  property :id
@@ -6,7 +6,7 @@ module Bigcommerce
6
6
  class OrderMessage < Resource
7
7
  include Bigcommerce::SubresourceActions.new(
8
8
  uri: 'orders/%d/messages/%d',
9
- disable: [:create, :update, :destroy, :destroy_all]
9
+ disable: %i[create update destroy destroy_all]
10
10
  )
11
11
 
12
12
  property :id
@@ -6,7 +6,7 @@ module Bigcommerce
6
6
  class OrderProduct < Resource
7
7
  include Bigcommerce::SubresourceActions.new(
8
8
  uri: 'orders/%d/products/%d',
9
- disable: [:create, :update, :destroy, :destroy_all]
9
+ disable: %i[create update destroy destroy_all]
10
10
  )
11
11
 
12
12
  property :id
@@ -6,7 +6,7 @@ module Bigcommerce
6
6
  class OrderShippingAddress < Resource
7
7
  include Bigcommerce::SubresourceActions.new(
8
8
  uri: 'orders/%d/shipping_addresses/%d',
9
- disable: [:create, :update, :destroy, :destroy_all]
9
+ disable: %i[create update destroy destroy_all]
10
10
  )
11
11
 
12
12
  property :id
@@ -7,7 +7,7 @@ module Bigcommerce
7
7
  class OrderStatus < Resource
8
8
  include Bigcommerce::ResourceActions.new(
9
9
  uri: 'order_statuses/%d',
10
- disable: [:create, :update, :destroy, :destroy_all]
10
+ disable: %i[create update destroy destroy_all]
11
11
  )
12
12
 
13
13
  property :id
@@ -6,7 +6,7 @@ module Bigcommerce
6
6
  class OrderTax < Resource
7
7
  include Bigcommerce::SubresourceActions.new(
8
8
  uri: 'orders/%d/taxes/%d',
9
- disable: [:create, :update, :destroy, :destroy_all]
9
+ disable: %i[create update destroy destroy_all]
10
10
  )
11
11
 
12
12
  property :id
@@ -6,7 +6,7 @@ module Bigcommerce
6
6
  class ConfigurableField < Resource
7
7
  include Bigcommerce::SubresourceActions.new(
8
8
  uri: 'products/%d/configurable_fields/%d',
9
- disable: [:create, :update]
9
+ disable: %i[create update]
10
10
  )
11
11
 
12
12
  property :id
@@ -6,7 +6,7 @@ module Bigcommerce
6
6
  class ProductOption < Resource
7
7
  include Bigcommerce::SubresourceActions.new(
8
8
  uri: 'products/%d/options/%d',
9
- disable: [:create, :update, :destroy, :destroy_all]
9
+ disable: %i[create update destroy destroy_all]
10
10
  )
11
11
 
12
12
  property :id
@@ -6,7 +6,7 @@ module Bigcommerce
6
6
  class ShippingMethod < Resource
7
7
  include Bigcommerce::ResourceActions.new(
8
8
  uri: 'shipping/methods/%d',
9
- disable: [:create, :update, :destroy, :destroy_all]
9
+ disable: %i[create update destroy destroy_all]
10
10
  )
11
11
 
12
12
  property :id
@@ -7,7 +7,7 @@ module Bigcommerce
7
7
  class TaxClass < Resource
8
8
  include Bigcommerce::ResourceActions.new(
9
9
  uri: 'tax_classes/%d',
10
- disable: [:create, :update, :destroy, :destroy_all]
10
+ disable: %i[create update destroy destroy_all]
11
11
  )
12
12
 
13
13
  property :id
@@ -1,3 +1,3 @@
1
1
  module Bigcommerce
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigcommerce
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
- - Patrick Edelman
7
+ - BigCommerce Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-24 00:00:00.000000000 Z
11
+ date: 2017-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.9'
47
+ version: '0.11'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.9'
54
+ version: '0.11'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: faraday_middleware
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.10.0
61
+ version: '0.11'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.10.0
68
+ version: '0.11'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: hashie
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: jwt
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.5.4
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.5.4
83
97
  description: Ruby client library for the BigCommerce API
84
98
  email:
85
99
  executables: []
@@ -161,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
175
  version: '0'
162
176
  requirements: []
163
177
  rubyforge_project:
164
- rubygems_version: 2.4.5.1
178
+ rubygems_version: 2.6.14
165
179
  signing_key:
166
180
  specification_version: 4
167
181
  summary: Ruby client library for the BigCommerce API