chrome-store-api
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -49,2 +49,3 @@ /** | ||
* @param {String} itemId | ||
* @param {String} target either undefined | default | trusted | ||
* @returns {Promise<ChromeStorePublishInfo>} | ||
@@ -55,7 +56,7 @@ */ | ||
key: 'publish', | ||
value: function publish(itemId) { | ||
value: function publish(itemId, target) { | ||
var _this = this; | ||
return this.tokenManager.get().then(function (token) { | ||
return itemsApi.publish(token, itemId); | ||
return itemsApi.publish(token, itemId, target); | ||
}).then(function (data) { | ||
@@ -62,0 +63,0 @@ return _this.retry(data, itemsApi.publish, [itemId]); |
@@ -90,9 +90,10 @@ /** | ||
* @param {String} itemId | ||
* @param {String} target | ||
* @returns {Promise<ChromeStorePublishInfo>} | ||
*/ | ||
function publish(token, itemId) { | ||
function publish(token, itemId, target) { | ||
return _qIoHttp2['default'].request({ | ||
method: 'POST', | ||
url: _configIndex2['default'].API_PUBLISH_URL.replace('{itemId}', itemId), | ||
url: _configIndex2['default'].API_PUBLISH_URL.replace('{itemId}', itemId) + (target === 'trusted' ? '?publishTarget=trustedTesters' : ''), | ||
headers: getHeaders(token) | ||
@@ -99,0 +100,0 @@ }).then(_utilsIndex.formatResponse).then((0, _utilsIndex.toLog)(log, 'publish')); |
{ | ||
"name": "chrome-store-api", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Chrome webstore API", | ||
@@ -5,0 +5,0 @@ "main": "out/index.js", |
@@ -104,1 +104,13 @@ [![Build Status](https://travis-ci.org/acvetkov/chrome-store-api.svg?branch=master)](https://travis-ci.org/acvetkov/chrome-store-api) | ||
``` | ||
#### publish for trusted users only | ||
```js | ||
api.publish('extension-id', 'trusted') | ||
.then(function (data) { | ||
console.log(data); | ||
}) | ||
.catch(function (err) { | ||
console.log(err); | ||
}); | ||
``` |
@@ -25,7 +25,8 @@ /** | ||
* @param {String} itemId | ||
* @param {String} target either undefined | default | trusted | ||
* @returns {Promise<ChromeStorePublishInfo>} | ||
*/ | ||
publish (itemId) { | ||
publish (itemId, target) { | ||
return this.tokenManager.get() | ||
.then(token => itemsApi.publish(token, itemId)) | ||
.then(token => itemsApi.publish(token, itemId, target)) | ||
.then(data => this.retry(data, itemsApi.publish, [itemId])) | ||
@@ -32,0 +33,0 @@ .then(checkResponseErrors) |
@@ -73,8 +73,10 @@ /** | ||
* @param {String} itemId | ||
* @param {String} target | ||
* @returns {Promise<ChromeStorePublishInfo>} | ||
*/ | ||
export function publish(token, itemId) { | ||
export function publish(token, itemId, target) { | ||
return http.request({ | ||
method: 'POST', | ||
url: config.API_PUBLISH_URL.replace('{itemId}', itemId), | ||
url: config.API_PUBLISH_URL.replace('{itemId}', itemId) | ||
+ (target === 'trusted' ? '?publishTarget=trustedTesters' : ''), | ||
headers: getHeaders(token) | ||
@@ -94,4 +96,4 @@ }) | ||
Authorization: `Bearer ${token}`, | ||
'x-goog-api-version': 2 | ||
'x-goog-api-version': 2, | ||
}; | ||
} |
@@ -260,2 +260,14 @@ /** | ||
it('should publish to trusted users', function () { | ||
nock('https://accounts.google.com') | ||
.post('/o/oauth2/token', GET_BODY) | ||
.reply(200, fixtureTokenGet.ok); | ||
nock('https://www.googleapis.com') | ||
.post(`/chromewebstore/v1.1/items/${ITEM_ID}/publish?publishTarget=trustedTesters`) | ||
.reply(200, fixturePublish.ok); | ||
return assert.eventually.deepEqual(this.api.publish(ITEM_ID, 'trusted'), fixturePublish.ok); | ||
}); | ||
it('should reject with 401', function () { | ||
@@ -262,0 +274,0 @@ nock('https://accounts.google.com') |
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
81793
2226
116