Skip to content

Commit

Permalink
Merge branch 'feature/tier' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
SoleeChoi committed Jan 14, 2022
2 parents 14b78d6 + 4bdd91b commit c998a2e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/Interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export type Method = 'GET' | 'POST' | 'PUT' | 'DELETE'

export interface Headers {
Authorization: string,
'User-Agent': string,
Authorization?: string,
'User-Agent'?: string,
Tier?: string,
}

export interface Config {
Expand Down
11 changes: 9 additions & 2 deletions lib/request/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import _ from 'lodash';
import { List, Item, Collection } from '../response';

import { Iamport } from '../Iamport';
import { Method, Config, AxiosResponse } from '../Interfaces';
import { Method, Config, AxiosResponse, Headers } from '../Interfaces';

class RequestBase {
public url: string;
public method: Method = 'GET';
public headers: Headers = {};
public params: any;
public data: any;
public responseType: string = 'item';
Expand All @@ -22,8 +23,14 @@ class RequestBase {
params: this.params,
data: this.data,
};
if (Object.keys(this.headers).length > 0) {
config.headers = { ...this.headers };
}
if (this.isTokenNeeded) {
config.headers = await iamport.getHeaders();
config.headers = {
...config.headers,
...await iamport.getHeaders(),
};
}

return iamport.getApiInstance().request(config)
Expand Down
8 changes: 6 additions & 2 deletions lib/request/Payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import RequestBase from './Base';
import { PaymentResponse, PaymentAmountResponse } from '../response';
import { StatusEnum, SortingEnum } from '../enum';

import { ImpUidParams } from '../Interfaces';
import { ImpUidParams, Headers } from '../Interfaces';

interface ImpUidsParams {
imp_uid: string[],
Expand Down Expand Up @@ -80,9 +80,13 @@ class Payments extends RequestBase {
}

/* 결제정보 조회 > 아임포트 번호 */
public static getByImpUid({ imp_uid }: ImpUidParams): Payments {
public static getByImpUid({ imp_uid }: ImpUidParams, headers?: Headers): Payments {
const payments = new Payments();
payments.url = `/payments/${imp_uid}`;
if (headers && typeof headers === 'object' && !Array.isArray(headers) && Object.keys(headers).length !== 0) {
// 티어 결제 건 조회 용도
payments.headers = { ...headers };
}
return payments;
}

Expand Down

0 comments on commit c998a2e

Please sign in to comment.