woocommerce-api
Advanced tools
Comparing version 1.0.4 to 1.1.0
33
index.js
@@ -33,3 +33,3 @@ 'use strict'; | ||
this.classVersion = '1.0.4'; | ||
this.classVersion = '1.1.0'; | ||
this._setDefaultsOptions(opt); | ||
@@ -44,9 +44,10 @@ } | ||
WooCommerceAPI.prototype._setDefaultsOptions = function(opt) { | ||
this.url = opt.url; | ||
this.version = opt.version || 'v3'; | ||
this.isSsl = /^https/i.test(this.url); | ||
this.consumerKey = opt.consumerKey; | ||
this.consumerSecret = opt.consumerSecret; | ||
this.verifySsl = false === opt.verifySsl ? false : true; | ||
this.encoding = opt.encoding || 'utf8'; | ||
this.url = opt.url; | ||
this.version = opt.version || 'v3'; | ||
this.isSsl = /^https/i.test(this.url); | ||
this.consumerKey = opt.consumerKey; | ||
this.consumerSecret = opt.consumerSecret; | ||
this.verifySsl = false === opt.verifySsl ? false : true; | ||
this.encoding = opt.encoding || 'utf8'; | ||
this.queryStringAuth = opt.queryStringAuth || false; | ||
}; | ||
@@ -152,6 +153,14 @@ | ||
if (this.isSsl) { | ||
params.auth = { | ||
user: this.consumerKey, | ||
pass: this.consumerSecret | ||
}; | ||
if (this.queryStringAuth) { | ||
params.qs = { | ||
consumer_key: this.consumerKey, | ||
consumer_secret: this.consumerSecret | ||
}; | ||
} else { | ||
params.auth = { | ||
user: this.consumerKey, | ||
pass: this.consumerSecret | ||
}; | ||
} | ||
if (!this.verifySsl) { | ||
@@ -158,0 +167,0 @@ params.strictSSL = false; |
{ | ||
"name": "woocommerce-api", | ||
"description": "A Node.js wrapper for the WooCommerce REST API", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "lint": "jshint .", |
@@ -36,10 +36,11 @@ # WooCommerce API - Node.js Client | ||
| Option | Type | Required | Description | | ||
| ---------------- | -------- | -------- | --------------------------------------------------------------------------------------------------- | | ||
| `url` | `String` | yes | Your Store URL, example: http://woo.dev/ | | ||
| `consumerKey` | `String` | yes | Your API consumer key | | ||
| `consumerSecret` | `String` | yes | Your API consumer secret | | ||
| `version` | `String` | no | API version, default is `v3` | | ||
| `verifySsl` | `Bool` | no | Verify SSL when connect, use this option as `false` when need to test with self-signed certificates | | ||
| `encoding` | `String` | no | Encoding, default is 'utf-8' | | ||
| Option | Type | Required | Description | | ||
|-------------------|----------|----------|-----------------------------------------------------------------------------------------------------| | ||
| `url` | `String` | yes | Your Store URL, example: http://woo.dev/ | | ||
| `consumerKey` | `String` | yes | Your API consumer key | | ||
| `consumerSecret` | `String` | yes | Your API consumer secret | | ||
| `version` | `String` | no | API version, default is `v3` | | ||
| `verifySsl` | `Bool` | no | Verify SSL when connect, use this option as `false` when need to test with self-signed certificates | | ||
| `encoding` | `String` | no | Encoding, default is 'utf-8' | | ||
| `queryStringAuth` | `Bool` | no | When `true` and using under HTTPS force Basic Authentication as query string, default is `false` | | ||
@@ -76,2 +77,3 @@ ## Methods | ||
- 2016-02-22 - v1.1.0 - Added `queryStringAuth` option to allow Basic Authentication as query string. | ||
- 2015-12-07 - v1.0.4 - Updated dependencies and fixed brackets when sorting query string. | ||
@@ -78,0 +80,0 @@ - 2015-12-07 - v1.0.3 - Added method to properly sort query strings when using oAuth. |
Sorry, the diff of this file is not supported yet
17423
335
82