Skip to content

Commit 32d5bf3

Browse files
committed
updates to sitemap and content list queries, upped version
1 parent de25f87 commit 32d5bf3

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@agility/content-fetch",
3-
"version": "0.1.8",
3+
"version": "0.1.9",
44
"description": "JavaScript library for the Agility Fetch API (node and browser)",
55
"main": "dist/agility-content-fetch.node.js",
66
"scripts": {

src/methods/getSitemapFlat.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import utils from '../utils'
44
* The sitemap, returned in a flat list, where the dictionary key is the page path. This method is ideal for page routing.
55
* @memberof AgilityFetch.Client
66
* @param {Object} requestParams - The parameters for the API request.
7-
* @param {number} requestParams.channelID - The channelID of the sitemap to return. If you only have one channel, your channelID is likely *1*.
7+
* @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*.
88
* @returns {Promise<AgilityFetch.Types.SitemapFlat>} - The sitemap response in a flat format.
99
* @example
1010
*
@@ -17,7 +17,7 @@ import utils from '../utils'
1717
* });
1818
*
1919
* api.getSitemapFlat({
20-
* channelID: 1
20+
* channelName: 'website'
2121
* })
2222
* .then(function(sitemap) {
2323
* console.log(sitemap);
@@ -32,8 +32,7 @@ function getSitemapFlat(requestParams) {
3232
validateRequestParams(requestParams);
3333

3434
const req = {
35-
//url: `/Sitemap/Flat/${requestParams.channelID}`,
36-
url: `/Sitemap/Flat`,
35+
url: `/Sitemap/Flat/${requestParams.channelName}`,
3736
method: 'get',
3837
baseURL: utils.buildRequestUrlPath(this.config),
3938
headers: utils.buildAuthHeader(this.config),
@@ -44,8 +43,8 @@ function getSitemapFlat(requestParams) {
4443
}
4544

4645
function validateRequestParams(requestParams) {
47-
if(!requestParams.channelID) {
48-
throw new TypeError('You must include a channelID in your request params.');
46+
if(!requestParams.channelName) {
47+
throw new TypeError('You must include a channelName in your request params.');
4948
} else {
5049
return;
5150
}

src/methods/getSitemapNested.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import utils from '../utils'
44
* Gets the sitemap as an array in a nested format, ideal for generating menus.
55
* @memberof AgilityFetch.Client
66
* @param {Object} requestParams - The parameters for the API request.
7-
* @param {number} requestParams.channelID - The channelID of the sitemap to return. If you only have one channel, your channelID is likely *1*.
7+
* @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*.
88
* @returns {Promise<AgilityFetch.Types.SitemapNested>} - The array of sitemap items returned.
99
* @example
1010
*
@@ -17,7 +17,7 @@ import utils from '../utils'
1717
* });
1818
*
1919
* api.getSitemapNested({
20-
* channelID: 1
20+
* channelName: 'website'
2121
* })
2222
* .then(function(sitemap) {
2323
* console.log(sitemap);
@@ -32,9 +32,7 @@ function getSitemapNested(requestParams) {
3232
validateRequestParams(requestParams);
3333

3434
const req = {
35-
//HACK
36-
//url: `/Sitemap/Nested/${requestParams.channelID}`,
37-
url: `/Sitemap/Nested`,
35+
url: `/Sitemap/Nested/${requestParams.channelName}`,
3836
method: 'get',
3937
baseURL: utils.buildRequestUrlPath(this.config),
4038
headers: utils.buildAuthHeader(this.config),
@@ -45,8 +43,8 @@ function getSitemapNested(requestParams) {
4543
}
4644

4745
function validateRequestParams(requestParams) {
48-
if(!requestParams.channelID) {
49-
throw new TypeError('You must include a channelID in your request params.');
46+
if(!requestParams.channelName) {
47+
throw new TypeError('You must include a channelName in your request params.');
5048
}
5149
}
5250

test/api.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ describe('Api', function() {
155155
referenceName: 'posts'
156156
})
157157
.then(function(contentList) {
158-
assert.strictEqual(contentList[0].contentID, 24);
159-
assert.strictEqual(contentList[1].contentID, 25);
158+
assert.strictEqual(contentList.items[0].contentID, 24);
159+
assert.strictEqual(contentList.items[1].contentID, 25);
160160
done();
161161
})
162162
.catch(done);
@@ -168,8 +168,8 @@ describe('Api', function() {
168168
referenceName: 'posts'
169169
})
170170
.then(function(contentList) {
171-
assert.strictEqual(contentList[0].contentID, 24);
172-
assert.strictEqual(contentList[1].contentID, 25);
171+
assert.strictEqual(contentList.items[0].contentID, 24);
172+
assert.strictEqual(contentList.items[1].contentID, 25);
173173
done();
174174
})
175175
.catch(done);
@@ -235,7 +235,7 @@ describe('Api', function() {
235235
it('should retrieve a sitemap in a flat format in live mode', function(done) {
236236
var api = createApiClient();
237237
api.getSitemapFlat({
238-
channelID: 1
238+
channelName: 'website'
239239
})
240240
.then(function(sitemap) {
241241
assert.strictEqual(sitemap['/home'].pageID, 1);
@@ -247,7 +247,7 @@ describe('Api', function() {
247247
it('should retrieve a sitemap in a flat format in preview mode', function(done) {
248248
var api = createPreviewApiClient();
249249
api.getSitemapFlat({
250-
channelID: 1
250+
channelName: 'website'
251251
})
252252
.then(function(sitemap) {
253253
assert.strictEqual(sitemap['/home'].pageID, 1);
@@ -256,7 +256,7 @@ describe('Api', function() {
256256
.catch(done);
257257
})
258258

259-
it('should throw error if channelID not passed as argument for getSitemapFlat', function(done) {
259+
it('should throw error if channelName not passed as argument for getSitemapFlat', function(done) {
260260
expect(function() {
261261
var api = createApiClient();
262262
api.getSitemapFlat({
@@ -276,7 +276,7 @@ describe('Api', function() {
276276
it('should retrieve a sitemap in a nested format in live mode', function(done) {
277277
var api = createApiClient();
278278
api.getSitemapNested({
279-
channelID: 1
279+
channelName: 'website'
280280
})
281281
.then(function(sitemap) {
282282
assert.strictEqual(sitemap[0].pageID, 1);
@@ -288,7 +288,7 @@ describe('Api', function() {
288288
it('should retrieve a sitemap in a nested format in preview mode', function(done) {
289289
var api = createPreviewApiClient();
290290
api.getSitemapNested({
291-
channelID: 1
291+
channelName: 'website'
292292
})
293293
.then(function(sitemap) {
294294
assert.strictEqual(sitemap[0].pageID, 1);
@@ -297,7 +297,7 @@ describe('Api', function() {
297297
.catch(done);
298298
})
299299

300-
it('should throw error if channelID not passed as argument for getSitemapNested', function(done) {
300+
it('should throw error if channelName not passed as argument for getSitemapNested', function(done) {
301301
expect(function() {
302302
var api = createApiClient();
303303
api.getSitemapNested({

0 commit comments

Comments
 (0)