From 05bd9ae820dfda0cd38a9a5aef66ea894eaa5b7f Mon Sep 17 00:00:00 2001 From: Matt Olson Date: Fri, 13 Mar 2015 10:10:48 -0700 Subject: [PATCH 1/2] Prepare for 0.10.3 release --- CHANGELOG.md | 1 + LICENSE => LICENSE.txt | 4 +- MANIFEST.in | 2 +- README.md | 101 ---------------------------------- README.rst | 120 +++++++++++++++++++++++++++++++++++++++++ setup.py | 47 +++++++++------- 6 files changed, 151 insertions(+), 124 deletions(-) rename LICENSE => LICENSE.txt (95%) delete mode 100644 README.md create mode 100644 README.rst diff --git a/CHANGELOG.md b/CHANGELOG.md index 1415fb0..3f3308d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### 0.10.3 * [jtallieu] Add support for Google product mappings endpoint +* [mattolson] Add counts for all resources and subresources that support it * [mattolson] Refactor to allow override of paths; Extract delete_all into a separate class * [sebaacuna] Add support for Product count * [mattolson] Allow override of auth endpoint with environment var diff --git a/LICENSE b/LICENSE.txt similarity index 95% rename from LICENSE rename to LICENSE.txt index 80f6f71..d4eb7e3 100644 --- a/LICENSE +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (C) BigCommerce, 2013. +Copyright (C) BigCommerce, 2015. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -17,4 +17,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in index 4b3b35e..bde247b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ -include *.txt *.md +include *.txt *.md *.rst exclude scripts/* diff --git a/README.md b/README.md deleted file mode 100644 index 1b0b1ad..0000000 --- a/README.md +++ /dev/null @@ -1,101 +0,0 @@ -Bigcommerce API V2 - Python Client -================================== - -[![Build Status](https://travis-ci.org/bigcommerce/bigcommerce-api-python.png?branch=master)](https://travis-ci.org/bigcommerce/bigcommerce-api-python) -[![Package Version](https://pypip.in/v/bigcommerce/badge.png)](https://pypi.python.org/pypi/bigcommerce) -[![Downloads](https://pypip.in/d/bigcommerce/badge.png)](https://pypi.python.org/pypi/bigcommerce) - -Wrapper over the `requests` library for communicating with the Bigcommerce v2 API. - -Install with `pip install bigcommerce` or `easy_install bigcommerce`. Tested with -python 2.7 and 3.3, and only requires `requests` and `streql`. - -## Usage - -### Connecting - -```python -import bigcommerce - -# OAuth2-based connection -# Access_token is optional, if you don't have one you can use oauth_fetch_token (see below) -api = bigcommerce.api.BigcommerceApi(client_id='', store_hash='', access_token='') - -# Legacy Basic authentication -api = bigcommerce.api.BigcommerceApi(host='store.mybigcommerce.com', basic_auth=('username', 'api token')) -``` - -`BigcommerceApi` also provides two helper methods for connection with OAuth2: - -* `api.oauth_fetch_token(client_secret, code, context, scope, redirect_uri)` -- fetches and - returns an access token for your application. As a side effect, configures `api` to be ready for use. - -* `BigcommerceApi.oauth_verify_payload(signed_payload, client_secret)` -- Returns user data from a signed - payload. - -### Accessing and objects - -The `api` object provides access to each API resource, each of which provides CRUD operations, -depending on capabilities of the resource: - -```python -api.Products.all() # GET /products -api.Products.get(1) # GET /products/1 -api.Products.create(name='', type='', ...) # POST /products -api.Products.get(1).update(price='199.90') # PUT /products/1 -api.Products.delete_all() # DELETE /products -api.Products.get(1).delete() # DELETE /products/1 -``` - -The client provides full access to subresources, both as independent resources: - -``` -api.ProductOptions.get(1) # GET /products/1/options -api.ProductOptions.get(1, 2) # GET /products/1/options/2 -``` - -And as helper methods on the parent resoource: - -``` -api.Products.get(1).options() # GET /products/1/options -api.Products.get(1).options(1) # GET /products/1/options/1 -``` - -These subresources implement CRUD methods in exactly the same way as regular resources: -``` -api.Products.get(1).options(1).delete() -``` - -### Filters - -Filters can be applied to `all` methods as keyword arguments: - -```python -customer = api.Customers.all(first_name='John', last_name='Smith')[0] -orders = api.Orders.all(customer_id=customer.id) -``` - -### Error handling - -Minimal validation of data is performed by the client, instead deferring this to the server. -A `HttpException` will be raised for any unusual status code: - -* 3xx status code: `RedirectionException` -* 4xx status code: `ClientRequestException` -* 5xx status code: `ServerException` - -## The low level API - -The high level API provided by `bigcommerce.api.BigcommerceApi` is a wrapper around a lower level -api in `bigcommerce.connection`. This can be accessed through `api.connection`, and provides helper -methods for get/post/put/delete operations. - -## Further documentation - -Full documentation of the API is available at -[developer.bigcommerce.com](http://developer.bigcommerce.com) - -## To do - -* Count endpoints -* Automatic enumeration of multiple page responses diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..0cec6f0 --- /dev/null +++ b/README.rst @@ -0,0 +1,120 @@ +Bigcommerce API Python Client +================================== + +|Build Status| |Package Version| |Downloads| + +Wrapper over the ``requests`` library for communicating with the Bigcommerce v2 API. + +Install with ``pip install bigcommerce`` or ``easy_install bigcommerce``. Tested with +python 2.7 and 3.4, and only requires ``requests`` and ``streql``. + +Usage +----- + +Connecting +~~~~~~~~~~ + +.. code:: python + + import bigcommerce + + # Public apps (OAuth) + # Access_token is optional, if you don't have one you can use oauth_fetch_token (see below) + api = bigcommerce.api.BigcommerceApi(client_id='', store_hash='', access_token='') + + # Private apps (Basic Auth) + api = bigcommerce.api.BigcommerceApi(host='store.mybigcommerce.com', basic_auth=('username', 'api token')) + +``BigcommerceApi`` also provides two helper methods for connection with OAuth2: + +- ``api.oauth_fetch_token(client_secret, code, context, scope, redirect_uri)`` + -- fetches and returns an access token for your application. As a + side effect, configures ``api`` to be ready for use. + +- ``BigcommerceApi.oauth_verify_payload(signed_payload, client_secret)`` + -- Returns user data from a signed payload. + +Accessing and objects +~~~~~~~~~~~~~~~~~~~~~ + +The ``api`` object provides access to each API resource, each of which +provides CRUD operations, depending on capabilities of the resource: + +.. code:: python + + api.Products.all() # GET /products + api.Products.get(1) # GET /products/1 + api.Products.create(name='', type='', ...) # POST /products + api.Products.get(1).update(price='199.90') # PUT /products/1 + api.Products.delete_all() # DELETE /products + api.Products.get(1).delete() # DELETE /products/1 + api.Products.count() # GET /products/count + +The client provides full access to subresources, both as independent +resources: + +:: + + api.ProductOptions.get(1) # GET /products/1/options + api.ProductOptions.get(1, 2) # GET /products/1/options/2 + +And as helper methods on the parent resoource: + +:: + + api.Products.get(1).options() # GET /products/1/options + api.Products.get(1).options(1) # GET /products/1/options/1 + +These subresources implement CRUD methods in exactly the same way as +regular resources: + +:: + + api.Products.get(1).options(1).delete() + +Filters +~~~~~~~ + +Filters can be applied to ``all`` methods as keyword arguments: + +.. code:: python + + customer = api.Customers.all(first_name='John', last_name='Smith')[0] + orders = api.Orders.all(customer_id=customer.id) + +Error handling +~~~~~~~~~~~~~~ + +Minimal validation of data is performed by the client, instead deferring +this to the server. A ``HttpException`` will be raised for any unusual +status code: + +- 3xx status code: ``RedirectionException`` +- 4xx status code: ``ClientRequestException`` +- 5xx status code: ``ServerException`` + +The low level API +~~~~~~~~~~~~~~~~~ + +The high level API provided by ``bigcommerce.api.BigcommerceApi`` is a +wrapper around a lower level api in ``bigcommerce.connection``. This can +be accessed through ``api.connection``, and provides helper methods for +get/post/put/delete operations. + +Further documentation +--------------------- + +Full documentation of the API is available on the Bigcommerce +`Developer Portal `__ + +To do +----- + +- Automatic enumeration of multiple page responses + +.. |Build Status| image:: https://travis-ci.org/bigcommerce/bigcommerce-api-python.png?branch=master + :target: https://travis-ci.org/bigcommerce/bigcommerce-api-python +.. |Package Version| image:: https://pypip.in/v/bigcommerce/badge.png + :target: https://pypi.python.org/pypi/bigcommerce +.. |Downloads| image:: https://pypip.in/d/bigcommerce/badge.png + :target: https://pypi.python.org/pypi/bigcommerce diff --git a/setup.py b/setup.py index a3aad14..bcbe7ee 100644 --- a/setup.py +++ b/setup.py @@ -6,27 +6,34 @@ def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup( - name = "bigcommerce", - version = "0.10.2", + name = 'bigcommerce', + version = '0.10.3', - packages=find_packages(), - package_data = {'' : ['LICENSE', 'README.md']}, - install_requires = ['requests>=2.1.0', - 'streql>=3.0.2'], - author = "Bigcommerce Engineering", - author_email = "vip@bigcommerce.com", - description = "Connect Python applications with the Bigcommerce API", - license = "MIT", - keywords = "bigcommerce api client", - url = "https://github.com/bigcommerce/bigcommerce-api-python", + packages = find_packages(), + install_requires = ['requests>=2.1.0', 'streql>=3.0.2'], - long_description=read('README.md'), - classifiers=[ - "Development Status :: 3 - Alpha", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Office/Business", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python", - "Programming Language :: Python :: 3" + url = 'https://github.com/bigcommerce/bigcommerce-api-python', + download_url = 'https://github.com/bigcommerce/bigcommerce-api-python/releases', + + author = 'Bigcommerce Engineering', + author_email = 'api@bigcommerce.com', + + description = 'Connect Python applications with the Bigcommerce API', + long_description = read('README.rst'), + license = 'MIT', + + keywords = ['bigcommerce', 'api', 'v2', 'client'], + classifiers = [ + 'Development Status :: 4 - Beta', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Office/Business', + 'Topic :: Internet :: WWW/HTTP', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.4' ], ) From 44aeefcd0cd72df016c2cd0df5f64a0bd4fa2c3d Mon Sep 17 00:00:00 2001 From: Gabe Limon Date: Fri, 13 Mar 2015 11:39:35 -0700 Subject: [PATCH 2/2] Renamed to 0.11.0 --- CHANGELOG.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f3308d..34ecd9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 0.10.3 +### 0.11.0 * [jtallieu] Add support for Google product mappings endpoint * [mattolson] Add counts for all resources and subresources that support it diff --git a/setup.py b/setup.py index bcbe7ee..7766a23 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ def read(fname): setup( name = 'bigcommerce', - version = '0.10.3', + version = '0.11.0', packages = find_packages(), install_requires = ['requests>=2.1.0', 'streql>=3.0.2'],