Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agility/content-fetch",
"version": "0.1.8",
"version": "0.1.9",
"description": "JavaScript library for the Agility Fetch API (node and browser)",
"main": "dist/agility-content-fetch.node.js",
"scripts": {
Expand Down
11 changes: 5 additions & 6 deletions src/methods/getSitemapFlat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import utils from '../utils'
* The sitemap, returned in a flat list, where the dictionary key is the page path. This method is ideal for page routing.
* @memberof AgilityFetch.Client
* @param {Object} requestParams - The parameters for the API request.
* @param {number} requestParams.channelID - The channelID of the sitemap to return. If you only have one channel, your channelID is likely *1*.
* @param {number} requestParams.channelName - The reference name of the digital channel of the sitemap to return. If you only have one channel, your channel reference name is likely *website*.
* @returns {Promise<AgilityFetch.Types.SitemapFlat>} - The sitemap response in a flat format.
* @example
*
Expand All @@ -17,7 +17,7 @@ import utils from '../utils'
* });
*
* api.getSitemapFlat({
* channelID: 1
* channelName: 'website'
* })
* .then(function(sitemap) {
* console.log(sitemap);
Expand All @@ -32,8 +32,7 @@ function getSitemapFlat(requestParams) {
validateRequestParams(requestParams);

const req = {
//url: `/Sitemap/Flat/${requestParams.channelID}`,
url: `/Sitemap/Flat`,
url: `/Sitemap/Flat/${requestParams.channelName}`,
method: 'get',
baseURL: utils.buildRequestUrlPath(this.config),
headers: utils.buildAuthHeader(this.config),
Expand All @@ -44,8 +43,8 @@ function getSitemapFlat(requestParams) {
}

function validateRequestParams(requestParams) {
if(!requestParams.channelID) {
throw new TypeError('You must include a channelID in your request params.');
if(!requestParams.channelName) {
throw new TypeError('You must include a channelName in your request params.');
} else {
return;
}
Expand Down
12 changes: 5 additions & 7 deletions src/methods/getSitemapNested.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import utils from '../utils'
* Gets the sitemap as an array in a nested format, ideal for generating menus.
* @memberof AgilityFetch.Client
* @param {Object} requestParams - The parameters for the API request.
* @param {number} requestParams.channelID - The channelID of the sitemap to return. If you only have one channel, your channelID is likely *1*.
* @param {number} requestParams.channelName - The reference name of the digital channel of the sitemap to return. If you only have one channel, your channel reference name is likely *website*.
* @returns {Promise<AgilityFetch.Types.SitemapNested>} - The array of sitemap items returned.
* @example
*
Expand All @@ -17,7 +17,7 @@ import utils from '../utils'
* });
*
* api.getSitemapNested({
* channelID: 1
* channelName: 'website'
* })
* .then(function(sitemap) {
* console.log(sitemap);
Expand All @@ -32,9 +32,7 @@ function getSitemapNested(requestParams) {
validateRequestParams(requestParams);

const req = {
//HACK
//url: `/Sitemap/Nested/${requestParams.channelID}`,
url: `/Sitemap/Nested`,
url: `/Sitemap/Nested/${requestParams.channelName}`,
method: 'get',
baseURL: utils.buildRequestUrlPath(this.config),
headers: utils.buildAuthHeader(this.config),
Expand All @@ -45,8 +43,8 @@ function getSitemapNested(requestParams) {
}

function validateRequestParams(requestParams) {
if(!requestParams.channelID) {
throw new TypeError('You must include a channelID in your request params.');
if(!requestParams.channelName) {
throw new TypeError('You must include a channelName in your request params.');
}
}

Expand Down
20 changes: 10 additions & 10 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ describe('Api', function() {
referenceName: 'posts'
})
.then(function(contentList) {
assert.strictEqual(contentList[0].contentID, 24);
assert.strictEqual(contentList[1].contentID, 25);
assert.strictEqual(contentList.items[0].contentID, 24);
assert.strictEqual(contentList.items[1].contentID, 25);
done();
})
.catch(done);
Expand All @@ -168,8 +168,8 @@ describe('Api', function() {
referenceName: 'posts'
})
.then(function(contentList) {
assert.strictEqual(contentList[0].contentID, 24);
assert.strictEqual(contentList[1].contentID, 25);
assert.strictEqual(contentList.items[0].contentID, 24);
assert.strictEqual(contentList.items[1].contentID, 25);
done();
})
.catch(done);
Expand Down Expand Up @@ -235,7 +235,7 @@ describe('Api', function() {
it('should retrieve a sitemap in a flat format in live mode', function(done) {
var api = createApiClient();
api.getSitemapFlat({
channelID: 1
channelName: 'website'
})
.then(function(sitemap) {
assert.strictEqual(sitemap['/home'].pageID, 1);
Expand All @@ -247,7 +247,7 @@ describe('Api', function() {
it('should retrieve a sitemap in a flat format in preview mode', function(done) {
var api = createPreviewApiClient();
api.getSitemapFlat({
channelID: 1
channelName: 'website'
})
.then(function(sitemap) {
assert.strictEqual(sitemap['/home'].pageID, 1);
Expand All @@ -256,7 +256,7 @@ describe('Api', function() {
.catch(done);
})

it('should throw error if channelID not passed as argument for getSitemapFlat', function(done) {
it('should throw error if channelName not passed as argument for getSitemapFlat', function(done) {
expect(function() {
var api = createApiClient();
api.getSitemapFlat({
Expand All @@ -276,7 +276,7 @@ describe('Api', function() {
it('should retrieve a sitemap in a nested format in live mode', function(done) {
var api = createApiClient();
api.getSitemapNested({
channelID: 1
channelName: 'website'
})
.then(function(sitemap) {
assert.strictEqual(sitemap[0].pageID, 1);
Expand All @@ -288,7 +288,7 @@ describe('Api', function() {
it('should retrieve a sitemap in a nested format in preview mode', function(done) {
var api = createPreviewApiClient();
api.getSitemapNested({
channelID: 1
channelName: 'website'
})
.then(function(sitemap) {
assert.strictEqual(sitemap[0].pageID, 1);
Expand All @@ -297,7 +297,7 @@ describe('Api', function() {
.catch(done);
})

it('should throw error if channelID not passed as argument for getSitemapNested', function(done) {
it('should throw error if channelName not passed as argument for getSitemapNested', function(done) {
expect(function() {
var api = createApiClient();
api.getSitemapNested({
Expand Down