shopify-node
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -76,3 +76,3 @@ function ShopifyConnect(params) { | ||
$scope.request = function(access_token, path, method, data, callback) { | ||
var used_args = arguments; | ||
if(access_token === null) { | ||
@@ -101,3 +101,3 @@ return callback({ | ||
if(method === 'post' || method === 'put') { | ||
if(method === 'post' || method === 'put' || method === 'delete') { | ||
opts.headers['Content-Length'] = q.length; | ||
@@ -114,4 +114,17 @@ } | ||
sock.on('end', function() { | ||
var j = JSON.parse(fullData); | ||
callback(null, j); | ||
try { | ||
var j = JSON.parse(fullData); | ||
if(j.errors || j.error) { | ||
j.arguments = used_args; | ||
return callback(j, null); | ||
} | ||
callback(null, j); | ||
} catch(e) { | ||
callback({ | ||
error: true, | ||
message: 'Error on: [' + method + '] ' + path, | ||
details: fullData, | ||
arguments: used_args | ||
}, null); | ||
} | ||
}); | ||
@@ -124,3 +137,3 @@ }); | ||
if(method === 'post' || method === 'put') { | ||
if(method === 'post' || method === 'put' || method === 'delete') { | ||
req.write(q); | ||
@@ -127,0 +140,0 @@ } |
{ | ||
"name": "shopify-node", | ||
"description": "A NodeJS connector for Shopify OAuth2", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"author": { | ||
@@ -30,4 +30,4 @@ "name": "uh-sem-blee, Co. | typefoo", | ||
}, | ||
"_id": "shopify-node@0.1.4", | ||
"_id": "shopify-node@0.1.5", | ||
"_from": "shopify-node@" | ||
} |
@@ -40,3 +40,3 @@ # Shopify Node | ||
secret: '07e3e4d5711054ead625ac7356552660', | ||
redirect: 'http://localhost:9000/#/oauth' | ||
redirect: 'http://localhost:9000/#/oauth', | ||
access_token: '' // your access token to be used | ||
@@ -47,6 +47,11 @@ }); | ||
// GET | ||
shopify.get('/admin/orders.json', function(err, resp) { | ||
if(err) { | ||
console.log(err); | ||
} | ||
console.log(resp); | ||
}); | ||
// POST | ||
var postData = { | ||
@@ -73,5 +78,24 @@ product: { | ||
shopify.post('/admin/products.json', postData, function(err, resp) { | ||
if(err) { | ||
console.log(err); | ||
} | ||
console.log(resp); | ||
}); | ||
// PUT | ||
shopify.put('/admin/products/1234.json', postData, function(err, resp) { | ||
if(err) { | ||
console.log(err); | ||
} | ||
console.log(resp); | ||
}); | ||
// DELETE | ||
shopify.delete('/admin/products/1234.json', function(err, resp) { | ||
if(err) { | ||
console.log(err); | ||
} | ||
console.log(resp); | ||
}); | ||
Built in Carolina & Ohio. www.typefoo.com |
@@ -12,5 +12,2 @@ var prompt = require('prompt'); | ||
var url = shopify.createURL(); | ||
console.log('\n\nGo to the following URL:\n\n' + url + '\n\n'); | ||
prompt.start(); | ||
@@ -33,2 +30,4 @@ | ||
function doAuthorization() { | ||
var url = shopify.createURL(); | ||
console.log('\n\nGo to the following URL:\n\n' + url + '\n\n'); | ||
@@ -49,2 +48,4 @@ prompt.get([ | ||
console.log(access_token); | ||
shopify.setAccessToken(access_token.access_token); | ||
sampleCalls(); | ||
}); | ||
@@ -58,2 +59,5 @@ }); | ||
shopify.get('/admin/orders.json', function(err, resp) { | ||
if(err) { | ||
console.log(err); | ||
} | ||
console.log(resp); | ||
@@ -84,4 +88,23 @@ }); | ||
shopify.post('/admin/products.json', postData, function(err, resp) { | ||
if(err) { | ||
console.log(err); | ||
} | ||
console.log(resp); | ||
}); | ||
// PUT | ||
shopify.put('/admin/products/1234.json', postData, function(err, resp) { | ||
if(err) { | ||
console.log(err); | ||
} | ||
console.log(resp); | ||
}); | ||
// DELETE | ||
shopify.delete('/admin/products/1234.json', function(err, resp) { | ||
if(err) { | ||
console.log(err); | ||
} | ||
console.log(resp); | ||
}); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10189
241
98