-
Notifications
You must be signed in to change notification settings - Fork 7
removed depreciation from consignment apis #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fixes/ritik/addedDeleteFieldForProductType
Are you sure you want to change the base?
Changes from all commits
0ff3978
b6231e9
21ed534
5ceb36e
595411a
c8e78d5
6bf25b9
553d737
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,7 +198,7 @@ var fetchStockOrdersForSuppliers = function(args, connectionInfo, retryCounter) | |
| log.debug('retry # ' + retryCounter); | ||
| } | ||
|
|
||
| var path = '/api/consignment'; | ||
| var path = '/api/2.0/consignments'; | ||
| var vendUrl = 'https://' + connectionInfo.domainPrefix + '.vendhq.com' + path; | ||
| var authString = 'Bearer ' + connectionInfo.accessToken; | ||
| log.debug('GET ' + vendUrl); | ||
|
|
@@ -215,8 +215,12 @@ var fetchStockOrdersForSuppliers = function(args, connectionInfo, retryCounter) | |
| page_size: args.pageSize.value // eslint-disable-line camelcase | ||
| } | ||
| }; | ||
|
|
||
| return utils.sendRequest(options, args, connectionInfo, fetchStockOrdersForSuppliers, retryCounter); | ||
| return utils.sendRequest(options, args, connectionInfo, fetchStockOrdersForSuppliers, retryCounter) | ||
| .then(function(response){ | ||
| return response.data; | ||
| }).catch(function(error){ | ||
| throw error; | ||
| }); | ||
| }; | ||
|
|
||
| // TODO: need to add a test | ||
|
|
@@ -251,7 +255,7 @@ var fetchConsignment = function(args, connectionInfo, retryCounter) { | |
| log.debug('retry # ' + retryCounter); | ||
| } | ||
|
|
||
| var path = '/api/1.0/consignment/' + args.apiId.value; | ||
| var path = '/api/2.0/consignments/' + args.apiId.value; | ||
| var vendUrl = 'https://' + connectionInfo.domainPrefix + '.vendhq.com' + path; | ||
| log.debug('Requesting vend consignment ' + vendUrl); | ||
| var authString = 'Bearer ' + connectionInfo.accessToken; | ||
|
|
@@ -264,8 +268,12 @@ var fetchConsignment = function(args, connectionInfo, retryCounter) { | |
| 'Accept': 'application/json' | ||
| } | ||
| }; | ||
|
|
||
| return utils.sendRequest(options, args, connectionInfo, fetchConsignment, retryCounter); | ||
| return utils.sendRequest(options, args, connectionInfo, fetchConsignment, retryCounter) | ||
| .then(function(response){ | ||
| return response.data; | ||
| }).catch(function(error){ | ||
| throw error; | ||
| }); | ||
| }; | ||
|
|
||
| // TODO: need to add a test | ||
|
|
@@ -275,8 +283,7 @@ var fetchProductsByConsignment = function(args, connectionInfo, retryCounter) { | |
| } else { | ||
| log.debug('retry # ' + retryCounter); | ||
| } | ||
|
|
||
| var path = '/api/consignment_product'; | ||
| var path = `/api/2.0/consignments/${args.consignmentId.value}/products`; | ||
| var vendUrl = 'https://' + connectionInfo.domainPrefix + '.vendhq.com' + path; | ||
| log.debug('Requesting vend product ' + vendUrl); | ||
| var authString = 'Bearer ' + connectionInfo.accessToken; | ||
|
|
@@ -295,7 +302,12 @@ var fetchProductsByConsignment = function(args, connectionInfo, retryCounter) { | |
| } | ||
| }; | ||
|
|
||
| return utils.sendRequest(options, args, connectionInfo, fetchProductsByConsignment, retryCounter); | ||
| return utils.sendRequest(options, args, connectionInfo, fetchProductsByConsignment, retryCounter) | ||
| .then(function(response){ | ||
| return response.data; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a catch block |
||
| }).catch(function(error){ | ||
| throw error; | ||
| }); | ||
| }; | ||
|
|
||
| // TODO: need to add a test | ||
|
|
@@ -445,8 +457,7 @@ var fetchConsignmentProductById = function(args, connectionInfo, retryCounter) | |
| }; | ||
|
|
||
| var createConsignmentProduct = function(args, connectionInfo, retryCounter) { | ||
| log.debug('inside createConsignmentProduct()'); | ||
|
|
||
| log.debug('inside createConsignmentProduct()'+ JSON.stringify(args)); | ||
| var body = null; | ||
| if (args && args.body) { | ||
| body = args.body; | ||
|
|
@@ -456,23 +467,19 @@ var createConsignmentProduct = function(args, connectionInfo, retryCounter) { | |
| return Promise.reject('missing required arguments for createConsignmentProduct()'); | ||
| } | ||
| body = { | ||
| 'consignment_id': args.consignmentId.value, | ||
| 'product_id': args.productId.value, | ||
| 'count': args.count.value, | ||
| 'cost': args.cost.value, | ||
| 'sequence_number': args.sequenceNumber.value, | ||
| 'received': args.received.value, | ||
| }; | ||
| } | ||
|
|
||
|
|
||
| if (!retryCounter) { | ||
| retryCounter = 0; | ||
| } else { | ||
| log.debug('retry # ' + retryCounter); | ||
| } | ||
|
|
||
| var path = '/api/consignment_product'; | ||
| var path = `/api/2.0/consignments/${args.body.consignment_id}/products`; | ||
| //var path = '/api/consignment_product'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get rid of commented code or add reason for commenting |
||
| var vendUrl = 'https://' + connectionInfo.domainPrefix + '.vendhq.com' + path; | ||
| var authString = 'Bearer ' + connectionInfo.accessToken; | ||
|
|
||
|
|
@@ -490,14 +497,16 @@ var createConsignmentProduct = function(args, connectionInfo, retryCounter) { | |
|
|
||
| return utils.sendRequest(options, args, connectionInfo, createConsignmentProduct, retryCounter) | ||
| .then(function(response){ | ||
| if(!response.id){ | ||
| if(!response.data.product_id){ | ||
| var error = new Error("Error adding consignment product"); | ||
| response.statusCode = 500; | ||
| error.response = response; | ||
| return Promise.reject(error); | ||
| } | ||
| return Promise.resolve(response); | ||
| }); | ||
| return Promise.resolve(response.data); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. catch block required |
||
| }).catch(function(error){ | ||
| throw error; | ||
| }) | ||
| }; | ||
|
|
||
| var createStockOrder = function(args, connectionInfo, retryCounter) { | ||
|
|
@@ -513,7 +522,7 @@ var createStockOrder = function(args, connectionInfo, retryCounter) { | |
| log.debug('retry # ' + retryCounter); | ||
| } | ||
|
|
||
| var path = '/api/consignment'; | ||
| var path = '/api/2.0/consignments'; | ||
| var vendUrl = 'https://' + connectionInfo.domainPrefix + '.vendhq.com' + path; | ||
| var authString = 'Bearer ' + connectionInfo.accessToken; | ||
|
|
||
|
|
@@ -537,7 +546,12 @@ var createStockOrder = function(args, connectionInfo, retryCounter) { | |
| }; | ||
| log.debug(options.method + ' ' + options.url); | ||
|
|
||
| return utils.sendRequest(options, args, connectionInfo, createStockOrder, retryCounter); | ||
| return utils.sendRequest(options, args, connectionInfo, createStockOrder, retryCounter) | ||
| .then(function(response){ | ||
| return response.data; | ||
| }).catch(function(error){ | ||
| throw error; | ||
| }) | ||
| }; | ||
|
|
||
| // TODO: need to add a test | ||
|
|
@@ -553,8 +567,8 @@ var updateConsignmentProduct = function(args, connectionInfo, retryCounter) { | |
| } else { | ||
| log.debug('retry # ' + retryCounter); | ||
| } | ||
|
|
||
| var path = '/api/consignment_product/' + args.apiId.value; | ||
| var path = `/api/2.0/consignments/${args.body.vendConsignmentId}/products/${args.body.value.product_id}`; | ||
| //var path = '/api/consignment_product/' + args.apiId.value; | ||
| var vendUrl = 'https://' + connectionInfo.domainPrefix + '.vendhq.com' + path; | ||
| var authString = 'Bearer ' + connectionInfo.accessToken; | ||
| var body = args.body.value; | ||
|
|
@@ -572,7 +586,12 @@ var updateConsignmentProduct = function(args, connectionInfo, retryCounter) { | |
| log.debug(options.method + ' ' + options.url); | ||
| log.debug( { message: 'body', body: options.json } ); | ||
|
|
||
| return utils.sendRequest(options, args, connectionInfo, updateConsignmentProduct, retryCounter); | ||
| return utils.sendRequest(options, args, connectionInfo, updateConsignmentProduct, retryCounter) | ||
| .then(function(response){ | ||
| return response.data; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. catch block |
||
| }).catch(function(error){ | ||
| throw error; | ||
| }) | ||
| }; | ||
|
|
||
| var markStockOrderAsSent = function(args, connectionInfo, retryCounter) { | ||
|
|
@@ -588,7 +607,7 @@ var markStockOrderAsSent = function(args, connectionInfo, retryCounter) { | |
| log.debug('retry # ' + retryCounter); | ||
| } | ||
|
|
||
| var path = '/api/consignment/' + args.apiId.value; | ||
| var path = '/api/2.0/consignments/' + args.apiId.value; | ||
| var vendUrl = 'https://' + connectionInfo.domainPrefix + '.vendhq.com' + path; | ||
| var authString = 'Bearer ' + connectionInfo.accessToken; | ||
| var body = args.body.value; | ||
|
|
@@ -606,8 +625,12 @@ var markStockOrderAsSent = function(args, connectionInfo, retryCounter) { | |
| }; | ||
| log.debug(options.method + ' ' + options.url); | ||
| log.debug( { message: 'body', body: options.json } ); | ||
|
|
||
| return utils.sendRequest(options, args, connectionInfo, markStockOrderAsSent, retryCounter); | ||
| return utils.sendRequest(options, args, connectionInfo, markStockOrderAsSent, retryCounter) | ||
| .then(function(response){ | ||
| return response.data; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. catch block |
||
| }).catch(function(error){ | ||
| throw error; | ||
| }) | ||
| }; | ||
|
|
||
| var markStockOrderAsReceived = function(args, connectionInfo, retryCounter) { | ||
|
|
@@ -623,7 +646,7 @@ var markStockOrderAsReceived = function(args, connectionInfo, retryCounter) { | |
| log.debug('retry # ' + retryCounter); | ||
| } | ||
|
|
||
| var path = '/api/consignment/' + args.apiId.value; | ||
| var path = '/api/2.0/consignments/' + args.apiId.value; | ||
| var vendUrl = 'https://' + connectionInfo.domainPrefix + '.vendhq.com' + path; | ||
| var authString = 'Bearer ' + connectionInfo.accessToken; | ||
| var body = args.body.value; | ||
|
|
@@ -642,7 +665,12 @@ var markStockOrderAsReceived = function(args, connectionInfo, retryCounter) { | |
| log.debug(options.method + ' ' + options.url); | ||
| log.debug( { message: 'body', body: options.json } ); | ||
|
|
||
| return utils.sendRequest(options, args, connectionInfo, markStockOrderAsReceived, retryCounter); | ||
| return utils.sendRequest(options, args, connectionInfo, markStockOrderAsReceived, retryCounter) | ||
| .then(function(response){ | ||
| return response.data; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. catch block |
||
| }).catch(function(error){ | ||
| throw error; | ||
| }) | ||
| }; | ||
|
|
||
| var deleteStockOrder = function(args, connectionInfo, retryCounter) { | ||
|
|
@@ -659,7 +687,7 @@ var deleteStockOrder = function(args, connectionInfo, retryCounter) { | |
| } | ||
|
|
||
| log.debug(args.apiId.value); | ||
| var path = '/api/consignment/' + args.apiId.value; | ||
| var path = '/api/2.0/consignments/' + args.apiId.value; | ||
| log.debug(path); | ||
| var vendUrl = 'https://' + connectionInfo.domainPrefix + '.vendhq.com' + path; | ||
| var authString = 'Bearer ' + connectionInfo.accessToken; | ||
|
|
@@ -675,7 +703,12 @@ var deleteStockOrder = function(args, connectionInfo, retryCounter) { | |
| }; | ||
| log.debug(options.method + ' ' + options.url); | ||
|
|
||
| return utils.sendRequest(options, args, connectionInfo, deleteStockOrder, retryCounter); | ||
| return utils.sendRequest(options, args, connectionInfo, deleteStockOrder, retryCounter) | ||
| .then(function(response){ | ||
| return response; | ||
| }).catch(function(error){ | ||
| throw error; | ||
| }) | ||
| }; | ||
|
|
||
| var deleteConsignmentProduct = function(args, connectionInfo, retryCounter) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you considered creating a new path instead of replacing the existing ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No