fake-iamport-server
Version:
Fake iamport server for testing
148 lines (137 loc) • 3.78 kB
text/typescript
/**
* @packageDocumentation
* @module api.functional.receipts
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
//================================================================
import type { IConnection } from "@nestia/fetcher";
import { PlainFetcher } from "@nestia/fetcher/lib/PlainFetcher";
import type { IIamportReceipt } from "../../structures/IIamportReceipt";
import type { IIamportResponse } from "../../structures/IIamportResponse";
/**
* 현금 영수증 조회하기.
*
* @param imp_uid 귀속 결제의 {@link IIamportPayment.imp_uid }
* @returns 현금 영수증 정보
* @security bearer
* @author Samchon
*
* @controller FakeIamportReceiptsController.at
* @path GET /receipts/:imp_uid
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
export async function at(
connection: IConnection,
imp_uid: string,
): Promise<at.Output> {
return PlainFetcher.fetch(connection, {
...at.METADATA,
template: at.METADATA.path,
path: at.path(imp_uid),
});
}
export namespace at {
export type Output = IIamportResponse<IIamportReceipt>;
export const METADATA = {
method: "GET",
path: "/receipts/:imp_uid",
request: null,
response: {
type: "application/json",
encrypted: false,
},
status: 200,
} as const;
export const path = (imp_uid: string) =>
`/receipts/${encodeURIComponent(imp_uid?.toString() ?? "null")}`;
}
/**
* 현금 영수증 발행하기.
*
* @param imp_uid 귀속 결제의 {@link IIamportPayment.imp_uid }
* @param input 현금 영수증 입력 정보
* @returns 현금 영수증 정보
* @security bearer
* @author Samchon
*
* @controller FakeIamportReceiptsController.create
* @path POST /receipts/:imp_uid
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
export async function create(
connection: IConnection,
imp_uid: string,
input: IIamportReceipt.ICreate,
): Promise<create.Output> {
return PlainFetcher.fetch(
{
...connection,
headers: {
...connection.headers,
"Content-Type": "application/json",
},
},
{
...create.METADATA,
template: create.METADATA.path,
path: create.path(imp_uid),
},
input,
);
}
export namespace create {
export type Input = IIamportReceipt.ICreate;
export type Output = IIamportResponse<IIamportReceipt>;
export const METADATA = {
method: "POST",
path: "/receipts/:imp_uid",
request: {
type: "application/json",
encrypted: false,
},
response: {
type: "application/json",
encrypted: false,
},
status: 201,
} as const;
export const path = (imp_uid: string) =>
`/receipts/${encodeURIComponent(imp_uid?.toString() ?? "null")}`;
}
/**
* 현금 영수증 취소하기.
*
* @param imp_uid 귀속 결제의 {@link IIamportPayment.imp_uid }
* @returns 취소된 현금 영수증 정보
* @security bearer
* @author Samchon
*
* @controller FakeIamportReceiptsController.erase
* @path DELETE /receipts/:imp_uid
* @nestia Generated by Nestia - https://github.com/samchon/nestia
*/
export async function erase(
connection: IConnection,
imp_uid: string,
): Promise<erase.Output> {
return PlainFetcher.fetch(connection, {
...erase.METADATA,
template: erase.METADATA.path,
path: erase.path(imp_uid),
});
}
export namespace erase {
export type Output = IIamportResponse<IIamportReceipt>;
export const METADATA = {
method: "DELETE",
path: "/receipts/:imp_uid",
request: null,
response: {
type: "application/json",
encrypted: false,
},
status: 200,
} as const;
export const path = (imp_uid: string) =>
`/receipts/${encodeURIComponent(imp_uid?.toString() ?? "null")}`;
}