@@ -8,13 +8,13 @@ import getUserAgent from './core/Util.js'
88import contentstackClient from './contentstackClient.js'
99import httpClient from './core/contentstackHTTPClient.js'
1010const regionHostMap = {
11- NA : 'api.contentstack.io' ,
12- EU : 'eu-api.contentstack.com' ,
13- AU : 'au-api.contentstack.com' ,
14- AZURE_NA : 'azure-na-api.contentstack.com' ,
15- AZURE_EU : 'azure-eu-api.contentstack.com' ,
16- GCP_NA : 'gcp-na-api.contentstack.com' ,
17- GCP_EU : 'gcp-eu-api.contentstack.com'
11+ NA : 'api.contentstack.io' ,
12+ EU : 'eu-api.contentstack.com' ,
13+ AU : 'au-api.contentstack.com' ,
14+ AZURE_NA : 'azure-na-api.contentstack.com' ,
15+ AZURE_EU : 'azure-eu-api.contentstack.com' ,
16+ GCP_NA : 'gcp-na-api.contentstack.com' ,
17+ GCP_EU : 'gcp-eu-api.contentstack.com'
1818}
1919
2020/**
@@ -169,56 +169,56 @@ const regionHostMap = {
169169 * @prop {string= } params.integration - Integration name and version e.g react/version
170170 * @returns Contentstack.Client
171171 */
172- export function client ( params = { } ) {
173- let defaultHostName
172+ export function client ( params = { } ) {
173+ let defaultHostName
174174
175- if ( params . region ) {
176- const region = params . region . toUpperCase ( )
177- if ( ! regionHostMap [ region ] ) {
178- throw new Error ( `Invalid region '${ params . region } ' provided. Allowed regions are: ${ Object . keys ( regionHostMap ) . join ( ', ' ) } ` )
179- }
180- defaultHostName = regionHostMap [ region ]
181- } else if ( params . host ) {
182- defaultHostName = params . host
183- } else {
184- defaultHostName = regionHostMap [ 'NA' ]
175+ if ( params . region ) {
176+ const region = params . region . toUpperCase ( )
177+ if ( ! regionHostMap [ region ] ) {
178+ throw new Error ( `Invalid region '${ params . region } ' provided. Allowed regions are: ${ Object . keys ( regionHostMap ) . join ( ', ' ) } ` )
185179 }
180+ defaultHostName = regionHostMap [ region ]
181+ } else if ( params . host ) {
182+ defaultHostName = params . host
183+ } else {
184+ defaultHostName = regionHostMap [ 'NA' ]
185+ }
186186
187- const defaultParameter = {
188- defaultHostName : defaultHostName
189- }
187+ const defaultParameter = {
188+ defaultHostName : defaultHostName
189+ }
190190
191- const sdkAgent = `contentstack-management-javascript/${ packages . version } `
192- const userAgentHeader = getUserAgent ( sdkAgent ,
193- params . application ,
194- params . integration ,
195- params . feature
196- )
197- const requiredHeaders = {
198- 'X-User-Agent' : sdkAgent ,
199- 'User-Agent' : userAgentHeader
200- }
191+ const sdkAgent = `contentstack-management-javascript/${ packages . version } `
192+ const userAgentHeader = getUserAgent ( sdkAgent ,
193+ params . application ,
194+ params . integration ,
195+ params . feature
196+ )
197+ const requiredHeaders = {
198+ 'X-User-Agent' : sdkAgent ,
199+ 'User-Agent' : userAgentHeader
200+ }
201201
202- if ( params . authtoken ) {
203- requiredHeaders . authtoken = params . authtoken
204- }
205- if ( params . authorization ) {
206- requiredHeaders . authorization = params . authorization
207- }
208- if ( params . early_access ) {
209- requiredHeaders . early_access = params . early_access . join ( ',' )
210- }
211- params = {
212- ...defaultParameter ,
213- ...clonedeep ( params )
214- }
202+ if ( params . authtoken ) {
203+ requiredHeaders . authtoken = params . authtoken
204+ }
205+ if ( params . authorization ) {
206+ requiredHeaders . authorization = params . authorization
207+ }
208+ if ( params . early_access ) {
209+ requiredHeaders . early_access = params . early_access . join ( ',' )
210+ }
211+ params = {
212+ ...defaultParameter ,
213+ ...clonedeep ( params )
214+ }
215215
216- params . headers = {
217- ...params . headers ,
218- ...requiredHeaders
219- }
220- const http = httpClient ( params )
221- return contentstackClient ( {
222- http : http
223- } )
216+ params . headers = {
217+ ...params . headers ,
218+ ...requiredHeaders
219+ }
220+ const http = httpClient ( params )
221+ return contentstackClient ( {
222+ http : http
223+ } )
224224}
0 commit comments