@people.io/ppl-api-client-js
Advanced tools
Comparing version 1.1.1 to 1.2.0
const client = require('./lib/httpClient'); | ||
const userAuthUrl = 'https://api.people.io/v1/auth/grant/'; | ||
async function getAudiences(name, { limit = 10000, page = 0, token, apiKey, clientId } = {}) { | ||
async function getAudiences(name, { limit = 100, page = 0, token, apiKey, clientId } = {}) { | ||
return client.execute('get', 'audiences', { name, limit, page }, { token, apiKey, clientId }); | ||
} | ||
async function getAudienceGroups(name, { limit = 10000, page = 0, token, apiKey, clientId } = {}) { | ||
async function getAudienceGroups(name, { limit = 100, page = 0, token, apiKey, clientId } = {}) { | ||
return client.execute('get', 'audienceGroups', { name, limit, page }, { token, apiKey, clientId }); | ||
} | ||
async function getUserAudiences(audienceGroupId, { token, apiKey, clientId } = {} ) { | ||
return client.execute('get', 'userAudiences', { audienceGroupId }, { token, apiKey, clientId }); | ||
async function getUserAudiences({ token, apiKey, clientId, limit = 100, audienceGroupId } = {} ) { | ||
return client.execute('get', 'userAudiences', { audienceGroupId, limit }, { token, apiKey, clientId }); | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -47,5 +47,10 @@ const axios = require('axios'); | ||
data = filterData(data); | ||
var url = `${config.apiUrl}${params.endpoint}`; | ||
if (method === 'get' && Object.keys(data).length > 0) { | ||
url = `${url}?${querystring.stringify(data)}`; | ||
} | ||
const request = { | ||
method: method, | ||
url: `${config.apiUrl}${params.endpoint}`, | ||
url, | ||
headers: { | ||
@@ -59,3 +64,3 @@ 'Content-Type': 'application/json', | ||
if (Object.keys(data).length > 0) { | ||
if (method !== 'get' && Object.keys(data).length > 0) { | ||
request.data = data | ||
@@ -62,0 +67,0 @@ } |
{ | ||
"name": "@people.io/ppl-api-client-js", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Simple client for people.io api", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -63,3 +63,3 @@ # ppl-api-client-js | ||
* `getAudienceGroups(name, { limit, page, token, apiKey, clientId })` | ||
* `getUserAudiences(audienceGroupId, { token, apiKey, clientId })` | ||
* `getUserAudiences({ audienceGroupId, limit, token, apiKey, clientId })` | ||
* `getUserIdToken({ token, apiKey, clientId })` | ||
@@ -66,0 +66,0 @@ * `getUserAuthURL(scope, desination, { clientId, state })` |
@@ -52,7 +52,7 @@ const chaiAsPromised = require("chai-as-promised"); | ||
it('Throws an error if missing api key', function () { | ||
return expect(client.getUserAudiences('Brands', { token })).be.eventually.rejectedWith(Error, mockValues.configErrors.apiKey); | ||
return expect(client.getUserAudiences({ token })).be.eventually.rejectedWith(Error, mockValues.configErrors.apiKey); | ||
}); | ||
it('Throws an error if missing client id', function () { | ||
return expect(client.getUserAudiences('Brands', { token , apiKey })).be.eventually.rejectedWith(Error, mockValues.configErrors.clientId); | ||
return expect(client.getUserAudiences({ token , apiKey })).be.eventually.rejectedWith(Error, mockValues.configErrors.clientId); | ||
}); | ||
@@ -59,0 +59,0 @@ }); |
@@ -57,3 +57,3 @@ const chaiAsPromised = require("chai-as-promised"); | ||
it('Can list audiences', function () { | ||
moxios.stubRequest('https://api.people.io/v1/audiences', mockValues.apiResponses.audiences); | ||
moxios.stubRequest('https://api.people.io/v1/audiences?limit=100&page=0', mockValues.apiResponses.audiences); | ||
return expect(client.getAudiences()).to.eventually.be.fulfilled; | ||
@@ -63,3 +63,3 @@ }); | ||
it('Can inspect a audience group', function () { | ||
moxios.stubRequest('https://api.people.io/v1/audiences/groups', mockValues.apiResponses.audienceGroups); | ||
moxios.stubRequest('https://api.people.io/v1/audiences/groups?limit=100&page=0', mockValues.apiResponses.audienceGroups); | ||
return expect(client.getAudienceGroups()).to.eventually.be.fulfilled; | ||
@@ -69,3 +69,3 @@ }); | ||
it('Can list audiences for a user', function () { | ||
moxios.stubRequest('https://api.people.io/v1/users/audiences', mockValues.apiResponses.userAudiences); | ||
moxios.stubRequest('https://api.people.io/v1/users/audiences?limit=100', mockValues.apiResponses.userAudiences); | ||
return expect(client.getUserAudiences()).to.eventually.be.fulfilled; | ||
@@ -72,0 +72,0 @@ }); |
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
17472
273