Giter Club home page Giter Club logo

big_commerce's Introduction

BigCommerce

This is a client library for the BigCommerce API.

Installation

Add big_commerce to the app dependencies in mix.exs:

def deps do
  [
    {:big_commerce, "~> 0.1.0"}
  ]
end

Documentation is on HexDocs. To generate a local copy, run mix docs.

Configuration

HTTP client

Optional dependencies

By default Tesla uses httpc to make HTTP client calls because it is included in Erlang/OTP and does not require installation of any additional dependency. It is not, however, recommended to use it in production environment as it does not validate SSL certificates among other issues.

Change the adapter to e.g. hackney globally in config/config.exs:

config :tesla, :adapter, Tesla.Adapter.Hackney

and add it as a dependency in mix.exs:

{:hackney, "~> 1.18"},

OpenTelemetry integration

Add the following lines to your application start:

OpentelemetryTesla.setup()

Logging

When the Elixir Logger log level is set to :debug, the Tesla Logger will show full request and response info. This can be pretty noisy. If you want to disable detailed request/response logging, set debug: false in your config:

config :tesla, Tesla.Middleware.Logger, debug: false

Logging configuration is evaluated at compile time, so Tesla must be recompiled for the configuration to take effect:

mix deps.clean --build tesla
mix deps.compile tesla

Usage

Talking to the BigCommerce API requires a store_hash, which identifies the specific store, and an access_token which authenticates the client.

First create an API client, which will then be used for calls to the API:

client = BigCommerce.client(store_hash: "123456", access_token: "abc123")

A good way to do this is create a config section in your app:

config :myapp, :big_commerce_client,
    store_hash = "123456",
    access_token = "abc123"

Then in code, you can do:

client_config = Application.get_env(:myapp, :big_commerce_client)
client = BigCommerce.client(client_config)

After you have the client, make api calls like this:

BigCommerce.Catalog.get_products(client)

big_commerce's People

Contributors

reachfh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.