-
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
const assign = require('lodash/assign'); | ||
const omit = require('lodash/omit'); | ||
|
||
const base = require('../mixins/base'); | ||
|
||
/** | ||
* Creates a TaxService instance. | ||
* | ||
* @param {Shopify} shopify Reference to the Shopify instance | ||
* @constructor | ||
* @public | ||
*/ | ||
function TaxService(shopify) { | ||
this.shopify = shopify; | ||
|
||
this.name = 'tax_services'; | ||
this.key = 'tax_service'; | ||
} | ||
|
||
assign(TaxService.prototype, omit(base, ['count', 'delete'])); | ||
|
||
/** | ||
* Destroys a tax service. | ||
* | ||
* @param {Number} Tax service ID | ||
* @return {Promise} Promise that resolves with the result | ||
* @public | ||
*/ | ||
TaxService.prototype.delete = function remove(id) { | ||
const url = this.buildUrl(id); | ||
return this.shopify.request(url, 'DELETE', this.key); | ||
}; | ||
|
||
module.exports = TaxService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
|
||
exports.req = require('./req'); | ||
exports.res = require('./res'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"tax_service": { | ||
"name": "My Tax Service", | ||
"url": "https://tax.myservice.com" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
|
||
exports.create = require('./create'); | ||
exports.update = require('./update'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"tax_service": { | ||
"id": 760126902, | ||
"name": "Some new name", | ||
"url": "https://tax-api.avalara.com", | ||
"active": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"tax_service": { | ||
"id": 883755539, | ||
"name": "My Tax Service", | ||
"url": "https://tax.myservice.com", | ||
"active": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"tax_service": { | ||
"id": 760126902, | ||
"name": "Avalara", | ||
"url": "https://tax-api.avalara.com", | ||
"active": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"tax_service": { | ||
"id": 760126902, | ||
"name": "Avalara", | ||
"url": "https://tax-api.avalara.com", | ||
"active": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
exports.create = require('./create'); | ||
exports.delete = require('./delete'); | ||
exports.update = require('./update'); | ||
exports.list = require('./list'); | ||
exports.get = require('./get'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"tax_services": [ | ||
{ | ||
"id": 760126902, | ||
"name": "Avalara", | ||
"url": "https://tax-api.avalara.com", | ||
"active": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"tax_service": { | ||
"id": 760126902, | ||
"name": "Some new name", | ||
"url": "https://tax-api.avalara.com", | ||
"active": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
describe('Shopify#taxService', () => { | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
|
||
const fixtures = require('./fixtures/tax-service'); | ||
const common = require('./common'); | ||
|
||
const shopify = common.shopify; | ||
const scope = common.scope; | ||
|
||
afterEach(() => expect(scope.isDone()).to.be.true); | ||
|
||
it('creates a tax service', () => { | ||
const input = fixtures.req.create; | ||
const output = fixtures.res.create; | ||
|
||
scope | ||
.post('/admin/tax_services.json', input) | ||
.reply(201, output); | ||
|
||
return shopify.taxService.create(input.tax_service) | ||
.then(data => expect(data).to.deep.equal(output.tax_service)); | ||
}); | ||
|
||
it('updates a tax service', () => { | ||
const input = fixtures.req.update; | ||
const output = fixtures.res.update; | ||
|
||
scope | ||
.put('/admin/tax_services/760126902.json', input) | ||
.reply(200, output); | ||
|
||
return shopify.taxService.update(760126902, input.tax_service) | ||
.then(data => expect(data).to.deep.equal(output.tax_service)); | ||
}); | ||
|
||
it('gets a list of all tax services', () => { | ||
const output = fixtures.res.list; | ||
|
||
scope | ||
.get('/admin/tax_services.json') | ||
.reply(200, output); | ||
|
||
return shopify.taxService.list() | ||
.then(data => expect(data).to.deep.equal(output.tax_services)); | ||
}); | ||
|
||
it('gets a single tax service by its ID', () => { | ||
const output = fixtures.res.get; | ||
|
||
scope | ||
.get('/admin/tax_services/760126902.json') | ||
.reply(200, output); | ||
|
||
return shopify.taxService.get(760126902) | ||
.then(data => expect(data).to.deep.equal(output.tax_service)); | ||
}); | ||
|
||
it('deletes a tax service', () => { | ||
const output = fixtures.res.delete; | ||
|
||
scope | ||
.delete('/admin/tax_services/760126902.json') | ||
.reply(200, output); | ||
|
||
return shopify.taxService.delete(760126902) | ||
.then(data => expect(data).to.deep.equal(output.tax_service)); | ||
}); | ||
}); |