GithubHelp home page GithubHelp logo

siliconsenthil / bigcommerce-api-ruby Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qkos/bigcommerce-api-ruby

0.0 2.0 0.0 320 KB

Connect Ruby applications with the Bigcommerce Platform

Home Page: https://developer.bigcommerce.com

License: MIT License

Ruby 100.00%

bigcommerce-api-ruby's Introduction

Bigcommerce API V2 - Ruby Client

Gem Version Build Status Dependency Status Code Climate Coverage Status

This library provides a wrapper around the Bigcommerce REST API for use within Ruby apps or via the console.

Note

If you find anything that is missing or needs clean up, please feel free to fork it and submit a changes with your pull request.

Requirements

  • Ruby 1.9+

To connect to the API, you need the following credentials:

  • Secure URL pointing to a Bigcommerce store
  • Username of an authorized admin user of the store
  • API key for the user

A valid API key is required to authenticate requests. To grant API access for a user, go to Control Panel > Users > Edit User and make sure that the 'Enable API access?' checkbox is ticked.

Installation

Download the lib folder and copy it to a path accessible within your app, or install the package directly from Rubygems:

gem install bigcommerce

Note that the RubyGems version of this gem might be outdated. You can install the gem directly from this repo. If you are using Rails, you can point your Gemfile to this git repo directly or do a local install of the gem by -

rake build
gem install pkg/bigcommerce-*.gem

Configuration

To use the API client in your Ruby code, provide the required credentials as follows:

require 'bigcommerce'

api = Bigcommerce::Api.new({
	:store_url => "https://store.mybigcommerce.com",
	:username  => "admin",
	:api_key   => "d81aada4c19c34d913e18f07fd7f36ca"
})

If you want to enable SSL certificates -

require 'bigcommerce'
api = Bigcommerce::Api.new({
	:store_url => "https://store.mybigcommerce.com",
	:username  => "admin",
	:api_key   => "d81aada4c19c34d913e18f07fd7f36ca"
	:ssl_client_cert  =>  OpenSSL::X509::Certificate.new(File.read("cert.pem")),
  	:ssl_client_key   =>  OpenSSL::PKey::RSA.new(File.read("key.pem"), "passphrase, if any"),
  	:ssl_ca_file      =>  "ca_certificate.pem",
  	:verify_ssl       =>  OpenSSL::SSL::VERIFY_PEER
})

Remember that the fields :ssl_client_cert, :ssl_client_key, :ssl_ca_file and :verify_ssl are all required when enabling SSL certificates.

Connecting to the store

Ping the time method to check that your configuration is working and you can connect successfully to the store:

ping = api.time

Usage

The API object acts as a gateway to all top level resources in the V2 API.

Fetch Data

orders = api.orders
orders = api.orders({:min_id=>100,:max_id=>101})
orders = api.orders(:is_deleted => true)

products = api.products
products = api.products(:description=>"iphone", :condition=>"New")

options = api.options
options = api.options(:type=>"MT")
...

Create Data

api.create_products({:name => "Spiderman - The best return",:price => 9.99,:categories => [17],:type =>"physical",:availability => "available", :weight => 1})

api.update_products(31,{:name => "marvel comics spiderman",:sku => "marvel-spidey-1", :inventory_tracking => "simple", :inventory_level => 500})

api.update_orders(101,{:status_id => 12, :is_deleted => true})

Update Data

api.update_products(31,{:name => "marvel comics spiderman",:sku => "marvel-spidey-1", :inventory_tracking => "simple", :inventory_level => 500})

api.update_optionsets(13,{:name => "Marvel toys"})

bigcommerce-api-ruby's People

Contributors

alexnesbitt avatar bradx3 avatar damncabbage avatar imerica avatar maetl avatar mikelarkin avatar pospischil avatar saranyan avatar sebastianszturo avatar sgerrand avatar squish avatar turnrye avatar winfred avatar zubin 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.