-
-
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.
Fixes: #170
- Loading branch information
Showing
7 changed files
with
83 additions
and
1 deletion.
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
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,30 @@ | ||
'use strict'; | ||
|
||
const assign = require('lodash/assign'); | ||
|
||
/** | ||
* Creates an AccessScope instance. | ||
* | ||
* @param {Shopify} shopify Reference to the Shopify instance | ||
* @constructor | ||
* @public | ||
*/ | ||
function AccessScope(shopify) { | ||
this.shopify = shopify; | ||
|
||
this.name = 'access_scopes'; | ||
} | ||
|
||
/** | ||
* Retrieves a list of access scopes associated to the access token. | ||
* | ||
* @return {Promise} Promise that resolves with the result | ||
* @public | ||
*/ | ||
AccessScope.prototype.list = function list() { | ||
const path = `/admin/oauth/${this.name}.json`; | ||
const url = assign({ path }, this.shopify.baseUrl); | ||
return this.shopify.request(url, 'GET', this.name); | ||
}; | ||
|
||
module.exports = AccessScope; |
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,24 @@ | ||
describe('Shopify#accessScope', () => { | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
|
||
const fixtures = require('./fixtures/access-scope'); | ||
const common = require('./common'); | ||
|
||
const shopify = common.shopify; | ||
const scope = common.scope; | ||
|
||
afterEach(() => expect(scope.isDone()).to.be.true); | ||
|
||
it('gets a list of access scopes associated to the access token', () => { | ||
const output = fixtures.res.list; | ||
|
||
scope | ||
.get('/admin/oauth/access_scopes.json') | ||
.reply(200, output); | ||
|
||
return shopify.accessScope.list() | ||
.then(data => expect(data).to.deep.equal(output.access_scopes)); | ||
}); | ||
}); |
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,3 @@ | ||
'use strict'; | ||
|
||
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,3 @@ | ||
'use strict'; | ||
|
||
exports.list = require('./list'); |
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,13 @@ | ||
{ | ||
"access_scopes": [ | ||
{ | ||
"handle": "read_products" | ||
}, | ||
{ | ||
"handle": "write_orders" | ||
}, | ||
{ | ||
"handle": "read_orders" | ||
} | ||
] | ||
} |