@agility/content-fetch 1.1.1 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/content-fetch",
3
- "version": "1.1.1",
3
+ "version": "1.1.4",
4
4
  "description": "JavaScript library for the Agility Fetch API (node and browser)",
5
5
  "main": "dist/agility-content-fetch.node.js",
6
6
  "scripts": {
@@ -16,7 +16,12 @@
16
16
  "type": "git",
17
17
  "url": "git+https://github.com/agility/agility-content-fetch-js-sdk.git"
18
18
  },
19
- "author": "James Vidler",
19
+ "author": "Agility CMS",
20
+ "contributors": [
21
+ "James Vidler",
22
+ "Joel Varty",
23
+ "Joshua Isaac"
24
+ ],
20
25
  "license": "MIT",
21
26
  "bugs": {
22
27
  "url": "https://github.com/agility/agility-content-fetch-js-sdk/issues"
package/src/api-client.js CHANGED
@@ -21,7 +21,7 @@ const defaultConfig = {
21
21
  isPreview: false,
22
22
  guid: null,
23
23
  apiKey: null,
24
- languageCode: null,
24
+ locale: null,
25
25
  headers: {},
26
26
  requiresGuidInHeaders: false,
27
27
  debug: false,
@@ -103,26 +103,11 @@ export default function createClient(userConfig) {
103
103
  adapter = cache.adapter;
104
104
  }
105
105
 
106
- const https= require("https")
107
-
108
106
  let api = null;
109
107
 
110
- if (https.Agent) {
111
- //create apply the adapter to our axios instance
112
- api = axios.create({
113
- httpsAgent: new https.Agent({
114
- rejectUnauthorized: false
115
- }),
116
- adapter: adapter,
117
- })
118
- } else {
119
- //we can't use the https.Agent
120
- api = axios.create({
121
- adapter: adapter,
122
- })
123
- }
124
-
125
-
108
+ api = axios.create({
109
+ adapter: adapter,
110
+ })
126
111
 
127
112
  //the function that actually makes ALL our requests
128
113
  function makeRequest(reqConfig) {
@@ -140,6 +125,10 @@ export default function createClient(userConfig) {
140
125
  data['fromCache'] = true;
141
126
  }
142
127
 
128
+ if (config.debug) {
129
+ data['agilityResponseHeaders'] = response.headers;
130
+ }
131
+
143
132
  return data;
144
133
 
145
134
 
@@ -5,7 +5,8 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
5
5
  * @memberof AgilityFetch.Client.Content
6
6
  * @param {Object} requestParams - The paramters for the API request.
7
7
  * @param {number} requestParams.contentID - The contentID of the requested item in this language.
8
- * @param {string} requestParams.languageCode - The language code of the content you want to retrieve.
8
+ * @param {string} requestParams.locale - The locale code of the content you want to retrieve.
9
+ * @param {string} requestParams.languageCode DEPRECATED: Use locale instead - The language code of the content you want to retrieve.
9
10
  * @param {number} [requestParams.contentLinkDepth] - The depth, representing the levels in which you want linked content auto-resolved. Default is **1**.
10
11
  * @param {boolean} [requestParams.expandAllContentLinks] - Whether or not to expand entire linked content references, includings lists and items that are rendered in the CMS as Grid or Link. Default is **false**
11
12
  * @returns {Promise<AgilityFetch.Types.ContentItem>} - Returns a content item object.
@@ -20,7 +21,7 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
20
21
  *
21
22
  * api.getContentItem({
22
23
  * contentID: 22,
23
- * languageCode: 'en-us'
24
+ * locale: 'en-us'
24
25
  * })
25
26
  * .then(function(contentItem) {
26
27
  * console.log(contentItem);
@@ -40,7 +41,7 @@ function getContentItem(requestParams) {
40
41
  const req = {
41
42
  url: `/item/${requestParams.contentID}?contentLinkDepth=${requestParams.contentLinkDepth}&expandAllContentLinks=${requestParams.expandAllContentLinks}`,
42
43
  method: 'get',
43
- baseURL: buildRequestUrlPath(this.config, requestParams.languageCode),
44
+ baseURL: buildRequestUrlPath(this.config, requestParams.locale ? requestParams.locale : requestParams.languageCode),
44
45
  headers: buildAuthHeader(this.config),
45
46
  params:{}
46
47
  };
@@ -49,8 +50,8 @@ function getContentItem(requestParams) {
49
50
  }
50
51
 
51
52
  function validateRequestParams(requestParams) {
52
- if(!requestParams.languageCode) {
53
- throw new TypeError('You must include a languageCode in your request params.')
53
+ if(!requestParams.languageCode && !requestParams.locale) {
54
+ throw new TypeError('You must include a locale in your request params.')
54
55
  }
55
56
  else if(!requestParams.contentID) {
56
57
  throw new TypeError('You must include a contentID number in your request params.');
@@ -5,10 +5,11 @@ import {buildPathUrl, buildRequestUrlPath, buildAuthHeader } from '../utils'
5
5
  * @memberof AgilityFetch.Client.Content
6
6
  * @param {Object} requestParams - The parameters for the API request.
7
7
  * @param {string} requestParams.referenceName - The unique reference name of the content list you wish to retrieve in the specified language.
8
- * @param {string} requestParams.languageCode - The language code of the content you want to retrieve.
8
+ * @param {string} requestParams.locale - The locale code of the content you want to retrieve.
9
+ * @param {string} requestParams.languageCode - DEPRECATED: Use locale instead - The language code of the content you want to retrieve.
9
10
  * @param {number} [requestParams.contentLinkDepth] - The depth, representing the levels in which you want linked content auto-resolved. Default is **1**.
10
11
  * @param {boolean} [requestParams.expandAllContentLinks] - Whether or not to expand entire linked content references, includings lists and items that are rendered in the CMS as Grid or Link. Default is **false**
11
- * @param {number} [requestParams.take] - The maximum number of items to retrieve in this request. Default is **10**. Maximum allowed is **50**.
12
+ * @param {number} [requestParams.take] - The maximum number of items to retrieve in this request. Default is **10**. Maximum allowed is **250**.
12
13
  * @param {number} [requestParams.skip] - The number of items to skip from the list. Default is **0**. Used for implementing pagination.
13
14
  * @param {string} [requestParams.sort] - The field to sort the results by. Example **fields.title** or **properties.modified**.
14
15
  * @param {AgilityFetch.Types.SortDirection} [requestParams.direction] - The direction to sort the results by.
@@ -16,17 +17,17 @@ import {buildPathUrl, buildRequestUrlPath, buildAuthHeader } from '../utils'
16
17
  * @param {AgilityFetch.Types.FilterLogicOperator} [requestParams.filtersLogicOperator] - The logic operator to combine multiple filters.
17
18
  * @returns {Promise<AgilityFetch.Types.ContentList>} - Returns a list of content items.
18
19
  * @example
19
- *
20
+ *
20
21
  * import agility from '@agility/content-fetch'
21
- *
22
+ *
22
23
  * const api = agility.getApi({
23
24
  * guid: 'ade6cf3c',
24
25
  * apiKey: 'defaultlive.201ffdd0841cacad5bb647e76547e918b0c9ecdb8b5ddb3cf92e9a79b03623cb',
25
26
  * });
26
- *
27
+ *
27
28
  * api.getContentList({
28
29
  * referenceName: 'posts',
29
- * languageCode: 'en-us',
30
+ * locale: 'en-us',
30
31
  * take: 50,
31
32
  * skip: 0,
32
33
  * sort: 'properties.modified',
@@ -41,7 +42,7 @@ import {buildPathUrl, buildRequestUrlPath, buildAuthHeader } from '../utils'
41
42
  *
42
43
  * api.getContentList({
43
44
  * referenceName: 'posts',
44
- * languageCode: 'en-us',
45
+ * locale: 'en-us',
45
46
  * take: 50,
46
47
  * skip: 0,
47
48
  * filters: [
@@ -69,12 +70,12 @@ function getContentList(requestParams) {
69
70
  const req = {
70
71
  url: buildPathUrl("list", requestParams.referenceName, requestParams.skip, requestParams.take, requestParams.sort, requestParams.direction, requestParams.filters, requestParams.filtersLogicOperator, requestParams.contentLinkDepth, requestParams.expandAllContentLinks),
71
72
  method: 'get',
72
- baseURL: buildRequestUrlPath(this.config, requestParams.languageCode),
73
+ baseURL: buildRequestUrlPath(this.config, requestParams.locale ? requestParams.locale : requestParams.languageCode),
73
74
  headers: buildAuthHeader(this.config),
74
75
  params:{}
75
76
  };
76
-
77
- return this.makeRequest(req);
77
+
78
+ return this.makeRequest(req);
78
79
  }
79
80
 
80
81
  function sanitizeReferenceName(referenceName) {
@@ -82,8 +83,8 @@ function sanitizeReferenceName(referenceName) {
82
83
  }
83
84
 
84
85
  function validateRequestParams(requestParams) {
85
- if(!requestParams.languageCode) {
86
- throw new TypeError('You must include a languageCode in your request params.')
86
+ if(!requestParams.languageCode && !requestParams.locale) {
87
+ throw new TypeError('You must include a locale in your request params.')
87
88
  }
88
89
  else if(!requestParams.referenceName) {
89
90
  //must have a referenceName
@@ -94,9 +95,9 @@ function validateRequestParams(requestParams) {
94
95
  } else if((requestParams.take || requestParams.take == 0) && !isNaN(requestParams.take) && requestParams.take < 1) {
95
96
  //take parameter must be greater than 0
96
97
  throw new TypeError('Take parameter must be greater than 0.');
97
- } else if(requestParams.take && !isNaN(requestParams.take) && requestParams.take > 50) {
98
- //take parameter cannot be greater than 50
99
- throw new TypeError('Take parameter must be 50 or less.');
98
+ } else if(requestParams.take && !isNaN(requestParams.take) && requestParams.take > 250) {
99
+ //take parameter cannot be greater than 250
100
+ throw new TypeError('Take parameter must be 250 or less.');
100
101
  } else if(requestParams.skip && isNaN(requestParams.skip)) {
101
102
  //skip parameter must be a number
102
103
  throw new TypeError('Skip parameter must be a number.');
@@ -5,7 +5,8 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
5
5
  * @memberof AgilityFetch.Client.Pages
6
6
  * @param {Object} requestParams - The parameters for the API request.
7
7
  * @param {number} requestParams.pageID - The unique page ID of the page you wish to retrieve in the current language.
8
- * @param {string} requestParams.languageCode - The language code of the content you want to retrieve.
8
+ * @param {string} requestParams.locale - The locale code of the content you want to retrieve.
9
+ * @param {string} requestParams.languageCode - DEPRECATED: Use locale instead - The language code of the content you want to retrieve.
9
10
  * @param {boolean} [requestParams.expandAllContentLinks] - Whether or not to expand entire linked content references, includings lists and items that are rendered in the CMS as Grid or Link. Default is **false**
10
11
  * @param {number} [requestParams.contentLinkDepth] - The depth, representing the levels in which you want linked content auto-resolved. Default is **2**.
11
12
  * @returns {Promise<AgilityFetch.Types.Page>} - Returns a page item object.
@@ -20,7 +21,7 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
20
21
  *
21
22
  * api.getPage({
22
23
  * pageID: 1,
23
- * languageCode: 'en-us'
24
+ * locale: 'en-us'
24
25
  * })
25
26
  * .then(function(page) {
26
27
  * console.log(page);
@@ -39,7 +40,7 @@ function getPage(requestParams) {
39
40
  const req = {
40
41
  url: `/page/${requestParams.pageID}?contentLinkDepth=${requestParams.contentLinkDepth}&expandAllContentLinks=${requestParams.expandAllContentLinks}`,
41
42
  method: 'get',
42
- baseURL: buildRequestUrlPath(this.config, requestParams.languageCode),
43
+ baseURL: buildRequestUrlPath(this.config, requestParams.locale ? requestParams.locale : requestParams.languageCode),
43
44
  headers: buildAuthHeader(this.config),
44
45
  params:{}
45
46
  };
@@ -48,8 +49,8 @@ function getPage(requestParams) {
48
49
  }
49
50
 
50
51
  function validateRequestParams(requestParams) {
51
- if(!requestParams.languageCode) {
52
- throw new TypeError('You must include a languageCode in your request params.')
52
+ if(!requestParams.languageCode && !requestParams.locale) {
53
+ throw new TypeError('You must include a locale in your request params.')
53
54
  } else if(!requestParams.pageID) {
54
55
  throw new TypeError('You must include a pageID in your request params.');
55
56
  } else if(requestParams.expandAllContentLinks && typeof requestParams.expandAllContentLinks !== 'boolean') {
@@ -5,7 +5,8 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
5
5
  * @memberof AgilityFetch.Client.Pages
6
6
  * @param {Object} requestParams - The parameters for the API request.
7
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*.
8
- * @param {string} requestParams.languageCode - The language code of the content you want to retrieve.
8
+ * @param {string} requestParams.locale - The locale code of the content you want to retrieve.
9
+ * @param {string} requestParams.languageCode - DEPRECATED: Use locale instead - The language code of the content you want to retrieve.
9
10
  * @returns {Promise<AgilityFetch.Types.SitemapFlat>} - The sitemap response in a flat format.
10
11
  * @example
11
12
  *
@@ -18,7 +19,7 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
18
19
  *
19
20
  * api.getSitemapFlat({
20
21
  * channelName: 'website',
21
- * languageCode: 'en-us'
22
+ * locale: 'en-us'
22
23
  * })
23
24
  * .then(function(sitemap) {
24
25
  * console.log(sitemap);
@@ -35,7 +36,7 @@ function getSitemapFlat(requestParams) {
35
36
  const req = {
36
37
  url: `/sitemap/flat/${requestParams.channelName}`,
37
38
  method: 'get',
38
- baseURL: buildRequestUrlPath(this.config, requestParams.languageCode),
39
+ baseURL: buildRequestUrlPath(this.config, requestParams.locale ? requestParams.locale : requestParams.languageCode),
39
40
  headers: buildAuthHeader(this.config),
40
41
  params:{}
41
42
  };
@@ -44,8 +45,8 @@ function getSitemapFlat(requestParams) {
44
45
  }
45
46
 
46
47
  function validateRequestParams(requestParams) {
47
- if(!requestParams.languageCode) {
48
- throw new TypeError('You must include a languageCode in your request params.')
48
+ if(!requestParams.languageCode && !requestParams.locale) {
49
+ throw new TypeError('You must include a locale in your request params.')
49
50
  } else if(!requestParams.channelName) {
50
51
  throw new TypeError('You must include a channelName in your request params.');
51
52
  } else {
@@ -5,7 +5,8 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
5
5
  * @memberof AgilityFetch.Client.Pages
6
6
  * @param {Object} requestParams - The parameters for the API request.
7
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*.
8
- * @param {string} requestParams.languageCode - The language code of the content you want to retrieve.
8
+ * @param {string} requestParams.locale - The locale code of the content you want to retrieve.
9
+ * @param {string} requestParams.languageCode - DEPRECATED: Use locale instead - The language code of the content you want to retrieve.
9
10
  * @returns {Promise<AgilityFetch.Types.SitemapNested>} - The array of sitemap items returned.
10
11
  * @example
11
12
  *
@@ -18,7 +19,7 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
18
19
  *
19
20
  * api.getSitemapNested({
20
21
  * channelName: 'website',
21
- * languageCode: 'en-us'
22
+ * locale: 'en-us'
22
23
  * })
23
24
  * .then(function(sitemap) {
24
25
  * console.log(sitemap);
@@ -35,7 +36,7 @@ function getSitemapNested(requestParams) {
35
36
  const req = {
36
37
  url: `/sitemap/nested/${requestParams.channelName}`,
37
38
  method: 'get',
38
- baseURL: buildRequestUrlPath(this.config, requestParams.languageCode),
39
+ baseURL: buildRequestUrlPath(this.config, requestParams.locale ? requestParams.locale : requestParams.languageCode),
39
40
  headers: buildAuthHeader(this.config),
40
41
  params:{}
41
42
  };
@@ -44,8 +45,8 @@ function getSitemapNested(requestParams) {
44
45
  }
45
46
 
46
47
  function validateRequestParams(requestParams) {
47
- if(!requestParams.languageCode) {
48
- throw new TypeError('You must include a languageCode in your request params.')
48
+ if(!requestParams.languageCode && !requestParams.locale) {
49
+ throw new TypeError('You must include a locale in your request params.')
49
50
  } else if(!requestParams.channelName) {
50
51
  throw new TypeError('You must include a channelName in your request params.');
51
52
  }
@@ -5,7 +5,8 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
5
5
  * @memberof AgilityFetch.Client.Sync
6
6
  * @param {Object} requestParams - The paramters for the API request.
7
7
  * @param {number} requestParams.syncToken - The sync token provided in the response to a previous sync API call. To start a new sync, use the value of '0'.
8
- * @param {string} requestParams.languageCode - The language code of the content you want to retrieve.
8
+ * @param {string} requestParams.locale - The locale code of the content you want to retrieve.
9
+ * @param {string} requestParams.languageCode - DEPRECATED: Use locale instead - The language code of the content you want to retrieve.
9
10
  * @param {number} [requestParams.pageSize] - The number of items to return back with each call. Default is 500.
10
11
  * @returns {Promise<AgilityFetch.Types.SyncContent>} - Returns a list of content item objects.
11
12
  * @example
@@ -19,7 +20,7 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
19
20
  *
20
21
  * api.getSyncContent({
21
22
  * syncToken: '0', //to start a new sync
22
- * languageCode: 'en-us',
23
+ * locale: 'en-us',
23
24
  * pageSize: 500
24
25
  * })
25
26
  * .then(function(contentList) {
@@ -39,7 +40,7 @@ function getSyncContent(requestParams) {
39
40
  const req = {
40
41
  url: `/sync/items?pageSize=${requestParams.pageSize}&syncToken=${requestParams.syncToken}`,
41
42
  method: 'get',
42
- baseURL: buildRequestUrlPath(this.config, requestParams.languageCode),
43
+ baseURL: buildRequestUrlPath(this.config, requestParams.locale ? requestParams.locale : requestParams.languageCode),
43
44
  headers: buildAuthHeader(this.config),
44
45
  params: {}
45
46
  };
@@ -48,8 +49,8 @@ function getSyncContent(requestParams) {
48
49
  }
49
50
 
50
51
  function validateRequestParams(requestParams) {
51
- if (!requestParams.languageCode) {
52
- throw new TypeError('You must include a languageCode in your request params.')
52
+ if (!requestParams.languageCode && !requestParams.locale) {
53
+ throw new TypeError('You must include a locale in your request params.')
53
54
  }
54
55
  else if (requestParams.syncToken == undefined || requestParams.syncToken == null) {
55
56
  throw new TypeError('You must include a syncToken value your request params. Use zero (0) to start a new sync.');
@@ -5,7 +5,8 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
5
5
  * @memberof AgilityFetch.Client.Sync
6
6
  * @param {Object} requestParams - The paramters for the API request.
7
7
  * @param {number} requestParams.syncToken - The sync token provided in the response to a previous sync API call. To start a new sync, use the value of '0'.
8
- * @param {string} requestParams.languageCode - The language code of the content you want to retrieve.
8
+ * @param {string} requestParams.locale - The locale code of the content you want to retrieve.
9
+ * @param {string} requestParams.languageCode - DEPRECATED: Use locale instead - The language code of the content you want to retrieve.
9
10
  * @param {number} [requestParams.pageSize] - The number of items to return back with each call. Default is 1000.
10
11
  * @returns {Promise<AgilityFetch.Types.Page>} - Returns a list of content item objects.
11
12
  * @example
@@ -19,7 +20,7 @@ import { buildRequestUrlPath, buildAuthHeader } from '../utils'
19
20
  *
20
21
  * api.getSyncPages({
21
22
  * syncToken: '0', //to start a new sync
22
- * languageCode: 'en-us',
23
+ * locale: 'en-us',
23
24
  * pageSize: 500
24
25
  * })
25
26
  * .then(function(pages) {
@@ -39,7 +40,7 @@ function getSyncPages(requestParams) {
39
40
  const req = {
40
41
  url: `/sync/pages?pageSize=${requestParams.pageSize}&syncToken=${requestParams.syncToken}`,
41
42
  method: 'get',
42
- baseURL: buildRequestUrlPath(this.config, requestParams.languageCode),
43
+ baseURL: buildRequestUrlPath(this.config, requestParams.locale ? requestParams.locale : requestParams.languageCode),
43
44
  headers: buildAuthHeader(this.config),
44
45
  params: {}
45
46
  };
@@ -48,8 +49,8 @@ function getSyncPages(requestParams) {
48
49
  }
49
50
 
50
51
  function validateRequestParams(requestParams) {
51
- if (!requestParams.languageCode) {
52
- throw new TypeError('You must include a languageCode in your request params.')
52
+ if (!requestParams.languageCode && !requestParams.locale) {
53
+ throw new TypeError('You must include a locale in your request params.')
53
54
  }
54
55
  else if (requestParams.syncToken == undefined || requestParams.syncToken == null) {
55
56
  throw new TypeError('You must include a syncToken value your request params. Use zero (0) to start a new sync.');
@@ -2,7 +2,7 @@
2
2
  * Defines a **Content List** in the CMS.
3
3
  * @typedef ContentList
4
4
  * @memberof AgilityFetch.Types
5
- * @property {Array.<AgilityFetch.Types.ContentItem>} items - The paginated array of items returned by the request. Default *take* is **10** unless otherwise specified (Maximum allowed it **50**)
5
+ * @property {Array.<AgilityFetch.Types.ContentItem>} items - The paginated array of items returned by the request. Default *take* is **10** unless otherwise specified (Maximum allowed it **250**)
6
6
  * @property {number} totalCount - The total amount of items in the list. Use this along with *skip* and *take* for pagination.
7
7
  */
8
8
 
package/src/utils.js CHANGED
@@ -6,7 +6,7 @@ function logDebug(consoleMessage) {
6
6
  console.log('\x1b[33m%s\x1b[0m', consoleMessage);
7
7
  }
8
8
 
9
- function buildRequestUrlPath(config, languageCode) {
9
+ function buildRequestUrlPath(config, locale) {
10
10
  let apiFetchOrPreview = null;
11
11
 
12
12
  if(config.isPreview === true || config.isPreview === 'true') {
@@ -15,7 +15,7 @@ function buildRequestUrlPath(config, languageCode) {
15
15
  apiFetchOrPreview = 'fetch';
16
16
  }
17
17
 
18
- let urlPath = `${config.baseUrl}/${apiFetchOrPreview}/${languageCode}`;
18
+ let urlPath = `${config.baseUrl}/${apiFetchOrPreview}/${locale}`;
19
19
  return urlPath;
20
20
  }
21
21
 
@@ -9,7 +9,8 @@ const apiKeyPreview = 'UnitTestsPreview.69e6bca345ced0b7ca5ab358b351ea5c870790a5
9
9
  function createApiClient() {
10
10
  var api = agility.getApi({
11
11
  guid: guid,
12
- apiKey: apiKeyFetch
12
+ apiKey: apiKeyFetch,
13
+ baseUrl: `https://api-dev.aglty.io/${guid}`
13
14
  });
14
15
  return api;
15
16
  }
@@ -28,7 +29,8 @@ function createCachedApiClient() {
28
29
  apiKey: apiKeyFetch,
29
30
  caching: {
30
31
  maxAge: 5 * 60 * 1000 //==5mins
31
- }
32
+ },
33
+ baseUrl: `https://api-dev.aglty.io/${guid}`
32
34
  });
33
35
  return api;
34
36
  }
@@ -37,7 +39,8 @@ function createPreviewApiClient() {
37
39
  var api = agility.getApi({
38
40
  guid: guid,
39
41
  apiKey: apiKeyPreview,
40
- isPreview: true
42
+ isPreview: true,
43
+ baseUrl: `https://api-dev.aglty.io/${guid}`
41
44
  });
42
45
  return api;
43
46
  }
@@ -26,7 +26,7 @@ describe('getContentItem:', function() {
26
26
  var api = createApiClient();
27
27
  api.getContentItem({
28
28
  contentID: ref.updatesMadeToPublishedContentItemID,
29
- languageCode: 'en-us'
29
+ locale: 'en-us'
30
30
  })
31
31
  .then(function(contentItem) {
32
32
  assert.strictEqual(contentItem.contentID, ref.updatesMadeToPublishedContentItemID, 'retrieved content item we asked for');
@@ -40,7 +40,7 @@ describe('getContentItem:', function() {
40
40
  var api = createPreviewApiClient();
41
41
  api.getContentItem({
42
42
  contentID: ref.updatesMadeToPublishedContentItemID,
43
- languageCode: 'en-us'
43
+ locale: 'en-us'
44
44
  })
45
45
  .then(function(contentItem) {
46
46
  assert.strictEqual(contentItem.contentID, ref.updatesMadeToPublishedContentItemID, 'retrieved content item we asked for');
@@ -54,7 +54,7 @@ describe('getContentItem:', function() {
54
54
  var api = createCachedApiClient();
55
55
  api.getContentItem({
56
56
  contentID: ref.updatesMadeToPublishedContentItemID,
57
- languageCode: 'en-us'
57
+ locale: 'en-us'
58
58
  })
59
59
  .then(function(contentItem) {
60
60
 
@@ -63,7 +63,7 @@ describe('getContentItem:', function() {
63
63
 
64
64
  api.getContentItem({
65
65
  contentID: ref.updatesMadeToPublishedContentItemID,
66
- languageCode: 'en-us'
66
+ locale: 'en-us'
67
67
  })
68
68
  .then(function(contentItem2) {
69
69
 
@@ -82,7 +82,7 @@ describe('getContentItem:', function() {
82
82
  var api = createApiClient();
83
83
  api.getContentItem({
84
84
  someOtherParam: 22,
85
- languageCode: 'en-us'
85
+ locale: 'en-us'
86
86
  })
87
87
  .then(function(contentItem) {
88
88
  assert.strictEqual(contentItem.contentID, 22);
@@ -93,7 +93,7 @@ describe('getContentItem:', function() {
93
93
  done();
94
94
  })
95
95
 
96
- it('should throw error if languageCode not passed as argument for getContentItem', function(done) {
96
+ it('should throw error if locale not passed as argument for getContentItem', function(done) {
97
97
  expect(function() {
98
98
  var api = createApiClient();
99
99
  api.getContentItem({
@@ -113,7 +113,7 @@ describe('getContentItem:', function() {
113
113
  var api = createApiClient();
114
114
  api.getContentItem({
115
115
  contentID: 22,
116
- languageCode: 'en-us',
116
+ locale: 'en-us',
117
117
  contentLinkDepth: 'something'
118
118
  })
119
119
  .then(function(contentItem) {
@@ -130,7 +130,7 @@ describe('getContentItem:', function() {
130
130
  var api = createApiClient();
131
131
  api.getContentItem({
132
132
  contentID: 22,
133
- languageCode: 'en-us',
133
+ locale: 'en-us',
134
134
  expandAllContentLinks: 'something'
135
135
  })
136
136
  .then(function(contentItem) {
@@ -146,7 +146,7 @@ describe('getContentItem:', function() {
146
146
  var api = createApiClient();
147
147
  api.getContentItem({
148
148
  contentID: 65, //item within listwithnestedcontentlinks
149
- languageCode: 'en-us',
149
+ locale: 'en-us',
150
150
  expandAllContentLinks: true
151
151
  })
152
152
  .then(function(contentItem) {
@@ -160,7 +160,7 @@ describe('getContentItem:', function() {
160
160
  var api = createApiClient();
161
161
  api.getContentItem({
162
162
  contentID: 65, //item within listwithnestedcontentlinks
163
- languageCode: 'en-us',
163
+ locale: 'en-us',
164
164
  expandAllContentLinks: false
165
165
  })
166
166
  .then(function(contentItem) {
@@ -174,7 +174,7 @@ describe('getContentItem:', function() {
174
174
  var api = createApiClient();
175
175
  api.getContentItem({
176
176
  contentID: 65, //item within listwithnestedcontentlinks
177
- languageCode: 'en-us',
177
+ locale: 'en-us',
178
178
  })
179
179
  .then(function(contentItem) {
180
180
  assert.strictEqual(Array.isArray(contentItem.fields.posts), false);
@@ -187,7 +187,7 @@ describe('getContentItem:', function() {
187
187
  var api = createApiClientWithNewCdn();
188
188
  api.getContentItem({
189
189
  contentID: 4, //item within jssdklist
190
- languageCode: 'en-us',
190
+ locale: 'en-us',
191
191
  })
192
192
  .then(function(contentItem) {
193
193
  assert.strictEqual(contentItem.fields.title, 'JS SDK Item - DO NOT DELETE');