Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 34 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,32 @@ orbs:
defaults: &defaults
notify_failure: false

ruby_3_0_defaults: &ruby_3_0_defaults
ruby_3_2_defaults: &ruby_3_2_defaults
<<: *defaults
e:
name: ruby/ruby
ruby-version: '3.0'
ruby-version: "3.2"

ruby_3_1_defaults: &ruby_3_1_defaults
ruby_3_3_defaults: &ruby_3_3_defaults
<<: *defaults
e:
name: ruby/ruby
ruby-version: '3.1'
ruby-version: "3.3"

ruby_3_2_defaults: &ruby_3_2_defaults
ruby_3_4_defaults: &ruby_3_4_defaults
<<: *defaults
e:
name: ruby/ruby
ruby-version: '3.2'
ruby-version: "3.4"

ruby_3_4_defaults: &ruby_3_4_defaults
ruby_4_0_defaults: &ruby_4_0_defaults
<<: *defaults
e:
name: ruby/ruby
ruby-version: '3.4'
ruby-version: "4.0"

workflows:
version: 2
ruby_3_0:
jobs:
- ruby/bundle-audit:
<<: *ruby_3_0_defaults
name: ruby-3_0-bundle_audit
- ruby/rubocop:
<<: *ruby_3_0_defaults
name: ruby-3_0-rubocop
- ruby/rspec-unit:
<<: *ruby_3_0_defaults
name: ruby-3_0-rspec_unit
db: false
ruby_3_1:
jobs:
- ruby/bundle-audit:
<<: *ruby_3_1_defaults
name: ruby-3_1-bundle_audit
- ruby/rubocop:
<<: *ruby_3_1_defaults
name: ruby-3_1-rubocop
- ruby/rspec-unit:
<<: *ruby_3_1_defaults
name: ruby-3_1-rspec_unit
db: false
code-climate: false
ruby_3_2:
jobs:
- ruby/bundle-audit:
Expand All @@ -71,6 +46,19 @@ workflows:
name: ruby-3_2-rspec_unit
db: false
code-climate: false
ruby_3_3:
jobs:
- ruby/bundle-audit:
<<: *ruby_3_3_defaults
name: ruby-3_3-bundle_audit
- ruby/rubocop:
<<: *ruby_3_3_defaults
name: ruby-3_3-rubocop
- ruby/rspec-unit:
<<: *ruby_3_3_defaults
name: ruby-3_3-rspec_unit
db: false
code-climate: false
ruby_3_4:
jobs:
- ruby/bundle-audit:
Expand All @@ -84,3 +72,16 @@ workflows:
name: ruby-3_4-rspec_unit
db: false
code-climate: false
ruby_4_0:
jobs:
- ruby/bundle-audit:
<<: *ruby_4_0_defaults
name: ruby-4_0-bundle_audit
- ruby/rubocop:
<<: *ruby_4_0_defaults
name: ruby-4_0-rubocop
- ruby/rspec-unit:
<<: *ruby_4_0_defaults
name: ruby-4_0-rspec_unit
db: false
code-climate: false
58 changes: 30 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
[![Test Coverage](https://api.codeclimate.com/v1/badges/d1ba1b74a2a74a26e8b4/test_coverage)](https://codeclimate.com/github/bigcommerce/bigcommerce-api-ruby/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/d1ba1b74a2a74a26e8b4/maintainability)](https://codeclimate.com/github/bigcommerce/bigcommerce-api-ruby/maintainability)

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).

This is the official BigCommerce API client to support our Stores API. You can find more information about becoming a
BigCommerce developer on the [docs site](https://docs.bigcommerce.com).

## Installation

BigCommerce is available on [RubyGems](https://rubygems.org/gems/bigcommerce).

```sh
Expand All @@ -27,34 +27,33 @@ gem 'bigcommerce', '~> 1.0'
- Ruby 2.7.5 or newer (Ruby 3.0+ is preferred)

## Getting Started

To make requests to our API, you must register as a developer and have your credentials ready.

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).
scopes that the merchant has granted to your application. For more information about Store API scopes,
see: [OAuth Scopes](https://docs.bigcommerce.com/developer/docs/overview/api-fundamentals/api-accounts#oauth-scopes).

## Authentication

We currently have two different authentication schemes that you can select, depending on your use case.

### OAuth
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.

__[More Information](https://developer.bigcommerce.com/api/using-oauth-intro)__

### Basic Authentication (Legacy)
To develop a custom integration for one store, your app needs to use Basic Authentication.
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.

__[More Information](https://developer.bigcommerce.com/api/legacy/basic-auth)__
**[More Information](https://docs.bigcommerce.com/developer/docs/overview/api-fundamentals/api-accounts#authentication)**

## Configuration

To authenticate your API client, you will need to configure the client like the following examples.

### OAuth App

- ```client_id```: Obtained from the on the BigCommerce [Developer Portal's](http://developer.bigcommerce.com) "My Apps" section.
- ```access_token```: Obtained after a token exchange in the auth callback.
- ```store_hash```: Also obtained after the token exchange.
- `client_id`: Obtained from the on the BigCommerce [Developer Portal's](https://build.bigcommerce.com) Apps section.
- `access_token`: Obtained after a token exchange in the auth callback.
- `store_hash`: Also obtained after the token exchange.

```rb
Bigcommerce.configure do |config|
Expand All @@ -66,10 +65,9 @@ end

### Basic Authentication (Legacy)

To get all the basic auth credentials, simply visit your store admin page, and navigate to the
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.


```rb
Bigcommerce.configure do |config|
config.auth = 'legacy'
Expand All @@ -79,9 +77,9 @@ Bigcommerce.configure do |config|
end
```

__SSL Configuration__
**SSL Configuration**

If you are using your own, self-signed, certificate, you can pass SSL options to Faraday. This is not required, but
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.

```rb
Expand All @@ -102,12 +100,13 @@ For more information about configuring SSL with Faraday, please see the followin
- [Faraday: Setting up SSL certificates](https://github.com/lostisland/faraday/wiki/Setting-up-SSL-certificates)

### Customer Login API
If you want to generate tokens for storefront login using the Customer Login API, you need to configure your app's

If you want to generate tokens for storefront login using the Customer Login API, you need to configure your app's
client secret.

- ```store_hash```: The store hash of the store you are operating against.
- ```client_id```: Obtained from the on the BigCommerce [Developer Portal's](http://developer.bigcommerce.com) "My Apps" section.
- ```client_secret```: Obtained from the on the BigCommerce [Developer Portal's](http://developer.bigcommerce.com) "My Apps" section.
- `store_hash`: The store hash of the store you are operating against.
- `client_id`: Obtained from the on the BigCommerce [Developer Portal's](https://build.bigcommerce.com) Apps section.
- `client_secret`: Obtained from the on the BigCommerce [Developer Portal's](https://build.bigcommerce.com) Apps section.

```rb
Bigcommerce.configure do |config|
Expand All @@ -118,8 +117,9 @@ end
```

## Usage
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).

For full examples of using the API client, please see the [examples folder](examples) and refer to
BigCommerce's [developer documentation](https://docs.bigcommerce.com/).

Example:

Expand All @@ -138,15 +138,15 @@ Bigcommerce::System.time

### Thread Safety

The `Bigcommerce.configure` method is NOT thread-safe. This mechanism is designed for applications or
The `Bigcommerce.configure` method is NOT thread-safe. This mechanism is designed for applications or
CLIs (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:

Rather then setting up a single `connection` for all API requests, 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
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.

This connection is nothing more than a `Faraday::Connection` – so if you want to write your own, or to use your own
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.

##### OAuth
Expand Down Expand Up @@ -189,7 +189,9 @@ Bigcommerce::System.raw_request(:get, 'time', connection: connection_legacy)
```

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md)

## License

See [LICENSE.md](LICENSE.md)