@@ -2,17 +2,17 @@ import { Gateway } from "./Gateway";
22
33export interface ConfigurationParams {
44 /**
5- * The Trolley public key
5+ * The Trolley access key
66 */
77 key : string ;
88 /**
9- * The Trolley private key
9+ * The Trolley secret key
1010 */
1111 secret : string ;
1212 /**
13- * The environment that you're using, most likely one of "production" or "sandbox"
13+ * Optional. The base URL to use to connect to the API gateway. Useful while running from source.
1414 */
15- environment ?: "production" | "sandbox" | "integration" | "development" ;
15+ apiBase ?: string ;
1616}
1717
1818// tslint:disable:function-name
@@ -40,13 +40,8 @@ export class Configuration {
4040 */
4141 constructor ( config ?: ConfigurationParams ) {
4242 this . apiKey = ( config && config . key ) || Configuration . apiKeyDefault ;
43- this . apiSecret =
44- ( config && config . secret ) || Configuration . apiSecretDefault ;
45- if ( config && config . environment ) {
46- this . apiBase = Configuration . environmentToUrl ( config . environment ) ;
47- } else {
48- this . apiBase = Configuration . apiBaseDefault ;
49- }
43+ this . apiSecret = ( config && config . secret ) || Configuration . apiSecretDefault ;
44+ this . apiBase = ( config && config . apiBase ) || Configuration . apiBaseDefault ;
5045 }
5146
5247 /**
@@ -83,31 +78,4 @@ export class Configuration {
8378 static setApiBase ( baseUrl : string ) {
8479 Configuration . apiBaseDefault = baseUrl ;
8580 }
86-
87- /**
88- * Set the Trolley API environment that your using
89- * @param environment one of "production" or "sandbox"
90- */
91- static setEnvironment ( environment : "production" | "sandbox" | "integration" ) {
92- Configuration . apiBaseDefault = Configuration . environmentToUrl ( environment ) ;
93- }
94-
95- /**
96- * Private method that converts an environment to a specific URL
97- * @param environment "production" | "sandbox"
98- * @hidden
99- */
100- private static environmentToUrl ( environment : string ) {
101- switch ( environment ) {
102- case "integration" :
103- // tslint:disable-next-line:no-http-string
104- return "http://api.local.dev:3000" ;
105- case "sandbox" :
106- return "https://api.trolley.com" ;
107- case "production" :
108- return "https://api.trolley.com" ;
109- default :
110- return "https://api.trolley.com" ;
111- }
112- }
11381}
0 commit comments