diff --git a/README.md b/README.md index 1350093..858eee2 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ const trolley = require('trolley'); const client = trolley.connect({ key: "YOUR-API-KEY", secret: "YOUR-API-SECRET", - environment: "production", }); // Async/Await version @@ -67,7 +66,6 @@ If you're working on the library itself, here's easy way to run the tests. $ cp .env.test .env // Set access key and secret in the env file -TROLLEY_ENVIRONMENT="production" TROLLEY_ACCESS_KEY="ACCESS_KEY" TROLLEY_SECRET_KEY="SECRET_KEY" diff --git a/docs/README.md b/docs/README.md index 2210186..f38b368 100644 --- a/docs/README.md +++ b/docs/README.md @@ -43,7 +43,7 @@ Create a client for the Trolley (Payment Rails) JavasScript API - const client = paymentrails.connect({ + const client = trolley.connect({ key: "MY_PUBLIC_KEY", secret: "MY_PRIVATE_KEY", }); diff --git a/lib/Configuration.ts b/lib/Configuration.ts index d560792..680c9a1 100644 --- a/lib/Configuration.ts +++ b/lib/Configuration.ts @@ -2,17 +2,17 @@ import { Gateway } from "./Gateway"; export interface ConfigurationParams { /** - * The Trolley public key + * The Trolley access key */ key: string; /** - * The Trolley private key + * The Trolley secret key */ secret: string; /** - * The environment that you're using, most likely one of "production" or "sandbox" + * Optional. The base URL to use to connect to the API gateway. Useful while running from source. */ - environment?: "production" | "sandbox" | "integration" | "development"; + apiBase?: string; } // tslint:disable:function-name @@ -40,13 +40,8 @@ export class Configuration { */ constructor(config?: ConfigurationParams) { this.apiKey = (config && config.key) || Configuration.apiKeyDefault; - this.apiSecret = - (config && config.secret) || Configuration.apiSecretDefault; - if (config && config.environment) { - this.apiBase = Configuration.environmentToUrl(config.environment); - } else { - this.apiBase = Configuration.apiBaseDefault; - } + this.apiSecret = (config && config.secret) || Configuration.apiSecretDefault; + this.apiBase = (config && config.apiBase) || Configuration.apiBaseDefault; } /** @@ -83,31 +78,4 @@ export class Configuration { static setApiBase(baseUrl: string) { Configuration.apiBaseDefault = baseUrl; } - - /** - * Set the Trolley API environment that your using - * @param environment one of "production" or "sandbox" - */ - static setEnvironment(environment: "production" | "sandbox" | "integration") { - Configuration.apiBaseDefault = Configuration.environmentToUrl(environment); - } - - /** - * Private method that converts an environment to a specific URL - * @param environment "production" | "sandbox" - * @hidden - */ - private static environmentToUrl(environment: string) { - switch (environment) { - case "integration": - // tslint:disable-next-line:no-http-string - return "http://api.local.dev:3000"; - case "sandbox": - return "https://api.trolley.com"; - case "production": - return "https://api.trolley.com"; - default: - return "https://api.trolley.com"; - } - } } diff --git a/test/integration/helpers/integrationTestsHelpers.ts b/test/integration/helpers/integrationTestsHelpers.ts index 48fb2d9..622323b 100755 --- a/test/integration/helpers/integrationTestsHelpers.ts +++ b/test/integration/helpers/integrationTestsHelpers.ts @@ -4,7 +4,6 @@ import * as nock from "nock"; export const testingApiClient = trolley.connect({ key: process.env.TROLLEY_ACCESS_KEY, secret: process.env.TROLLEY_SECRET_KEY, - environment: process.env.TROLLEY_ENVIRONMENT as any, } as any); export let nockBack = nock.back