Skip to content

Commit

Permalink
Merge pull request #225 from paypay/feature/refactor-sdk-v1
Browse files Browse the repository at this point in the history
Refactor hostname configuration and remove duplicates
  • Loading branch information
Shreyansh Pandey committed Apr 27, 2021
2 parents ca740bd + 31f5043 commit 4202963
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 294 deletions.
File renamed without changes.
141 changes: 0 additions & 141 deletions src/lib/conf.perf.json

This file was deleted.

141 changes: 0 additions & 141 deletions src/lib/conf.stage.json

This file was deleted.

19 changes: 8 additions & 11 deletions src/lib/conf.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as stagingConfig from "./conf.stage.json";
import * as prodConfig from "./conf.prod.json";
import * as perfConfig from "./conf.perf.json";
import * as pathConfig from "./conf.path.json";
import {HOST_PATH} from "./constants";

export interface Config {
HOST_NAME: string;
PORT_NUMBER?: number;
API_PAYMENT: {};
API_WALLET: {};
Expand All @@ -17,20 +15,19 @@ export interface Config {
export class Conf {
options: { [k: string]: any } = {};

private readonly stagingConfig: Config = stagingConfig;
private readonly prodConfig: Config = prodConfig;
private readonly perfConfig: Config = perfConfig;
private readonly pathConfig: Config = pathConfig;

private readonly configLookup: any;

constructor(productionMode: boolean = false, perfMode: boolean = false) {
constructor(productionMode: boolean = false, perfMode: boolean) {
this.configLookup = JSON.parse(JSON.stringify(this.pathConfig));
if (productionMode) {
this.configLookup = JSON.parse(JSON.stringify(this.prodConfig));
this.configLookup.HOST_NAME = HOST_PATH.PROD
} else {
this.configLookup = JSON.parse(JSON.stringify(this.stagingConfig));
this.configLookup.HOST_NAME = HOST_PATH.STAGING;
}
if (perfMode) {
this.configLookup = JSON.parse(JSON.stringify(this.perfConfig));
this.configLookup.HOST_NAME = HOST_PATH.PERF_MODE;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const HOST_PATH = {
PROD: 'api.paypay.ne.jp',
STAGING: 'stg-api.sandbox.paypay.ne.jp',
PERF_MODE: 'perf-api.paypay.ne.jp',
};
2 changes: 1 addition & 1 deletion src/lib/paypay-rest-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PayPayRestSDK {
private options: any = "";
private productionMode: boolean = false;
private perfMode: boolean = false;
private auth: Auth;
private readonly auth: Auth;
private config: Conf;

constructor() {
Expand Down

0 comments on commit 4202963

Please sign in to comment.