@@ -50,6 +50,8 @@ export default class Stack {
50
50
this . config = config ;
51
51
this . cachePolicy = CacheProvider . policies . IGNORE_CACHE ;
52
52
this . provider = CacheProvider . providers ( 'localstorage' ) ;
53
+ console . error ( stack_arguments . length ) ;
54
+
53
55
switch ( stack_arguments . length ) {
54
56
case 1 :
55
57
if ( typeof stack_arguments [ 0 ] === "object" && typeof stack_arguments [ 0 ] . api_key === "string" && typeof stack_arguments [ 0 ] . delivery_token === "string" && typeof stack_arguments [ 0 ] . environment === "string" ) {
@@ -62,7 +64,36 @@ export default class Stack {
62
64
} else {
63
65
console . error ( "Kindly provide valid object parameters. The specified API Key, Delivery Token, or Environment Name is invalid." ) ;
64
66
}
65
- case 3 , 4 , 5 :
67
+ case 3 :
68
+ if ( typeof stack_arguments [ 0 ] === "string" && typeof stack_arguments [ 1 ] === "string" && typeof stack_arguments [ 2 ] === "string" ) {
69
+ this . headers = {
70
+ api_key : stack_arguments [ 0 ] ,
71
+ access_token : stack_arguments [ 1 ]
72
+ } ;
73
+ this . environment = stack_arguments [ 2 ] ;
74
+ return this ;
75
+ } else {
76
+ console . error ( "Kindly provide valid string parameters." ) ;
77
+ }
78
+ case 4 :
79
+ if ( typeof stack_arguments [ 0 ] === "string" && typeof stack_arguments [ 1 ] === "string" && typeof stack_arguments [ 2 ] === "string" ) {
80
+ this . headers = {
81
+ api_key : stack_arguments [ 0 ] ,
82
+ access_token : stack_arguments [ 1 ]
83
+ } ;
84
+ this . environment = stack_arguments [ 2 ] ;
85
+ return this ;
86
+ } else {
87
+ console . error ( "Kindly provide valid string parameters." ) ;
88
+ }
89
+ if ( stack_arguments [ 3 ] ) {
90
+ if ( typeof stack_arguments [ 3 ] === "string" && stack_arguments [ 3 ] . region !== "us" && stack_arguments [ 3 ] . region === "eu" ) {
91
+ config [ 'host' ] = stack_arguments [ 0 ] . region + "-" + "cdn.contentstack.com" ;
92
+ } else if ( typeof stack_arguments [ 3 ] === 'object' ) {
93
+ this . fetchOptions = stack_arguments [ 3 ]
94
+ }
95
+ }
96
+ case 5 :
66
97
if ( typeof stack_arguments [ 0 ] === "string" && typeof stack_arguments [ 1 ] === "string" && typeof stack_arguments [ 2 ] === "string" ) {
67
98
this . headers = {
68
99
api_key : stack_arguments [ 0 ] ,
@@ -80,7 +111,6 @@ export default class Stack {
80
111
this . fetchOptions = stack_arguments [ 3 ]
81
112
}
82
113
}
83
-
84
114
if ( stack_arguments [ 4 ] && typeof stack_arguments [ 4 ] === 'object' ) {
85
115
this . fetchOptions = stack_arguments [ 3 ]
86
116
}
0 commit comments