Skip to content

Commit

Permalink
Merge V1 branch and fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
maetl committed Mar 29, 2013
2 parents 33e4a10 + b759e0a commit 5d93135
Show file tree
Hide file tree
Showing 10 changed files with 514 additions and 133 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@

# ci_reporter
/spec/reports

#Ignore compiled gems
*.gem

85 changes: 56 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ Ruby apps or via the console.

Note
----

**The Ruby Client is still in alpha and core features of the API may be
unsupported and undocumented.**
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.8.7+
- Rubygems
- JSON
- Ruby 1.9+

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

Expand All @@ -25,7 +21,7 @@ To connect to the API, you need the following credentials:

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

Installation
------------
Expand All @@ -37,6 +33,13 @@ install the package directly from Rubygems:
gem install bigcommerce
```

Note - the current gem version is 1.0. The Rubygems version might be older. 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 -

```
gem build bigcommerce
gem install bigcommerce-1.0.gem
```

Configuration
-------------

Expand All @@ -46,12 +49,28 @@ follows:
```
require 'bigcommerce'
api = Bigcommerce::Api.new({
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 requrired when enabling SSL certs.

Connecting to the store
-----------------------
Expand All @@ -68,27 +87,35 @@ Usage

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

Fetch Data
```
$ irb
>
> api = Bigcommerce::Api.new(...)
>
> api.get_products.each { |product| puts product.name }
>
> api.get_customers.each { |customer| puts customer.email }
>
> puts api.get_orders_count
>
> category = api.get_category(11)
> category.name = "Laptops"
> category.update
>
> brand = Bigcommerce::Api::Brand.new
> brand.name = "Samsung"
> brand.create
>
> option = api.get_option(22)
> option.delete
>
orders = api.get_orders
orders = api.get_orders({:min_id=>100,:max_id=>101})
orders = api.get_orders(:is_deleted => true)
products = api.get_products
products = api.get_products(:description=>"iphone", :condition=>"New")
options = api.get_options
options = api.get_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"})
```

1 change: 1 addition & 0 deletions bigcommerce.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require File.expand_path('../lib/bigcommerce/version', __FILE__)
Gem::Specification.new do |s|
s.add_dependency('activesupport')
s.add_dependency('json')
s.add_dependency('rest-client')
s.add_development_dependency("ci_reporter")
s.add_development_dependency("fakeweb")
s.add_development_dependency("mocha")
Expand Down
3 changes: 2 additions & 1 deletion lib/bigcommerce.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "cgi"
require "json"
require "net/https"
# require "net/https"
require 'rest-client'
require "uri"
require 'bigcommerce/api'
require 'bigcommerce/connection'
Expand Down
Loading

0 comments on commit 5d93135

Please sign in to comment.