UNPKG

@bit-ui-libs/common

Version:
38 lines (29 loc) 1.68 kB
import { BaseService, BaseServiceOptions } from '../../api/services/base-service'; import { PaymentInfo } from '../interfaces'; import { AddPaymentDetailRequest, EditPaymentDetailRequest, ListPaymentDetailsRequest } from './payment-details.service.interfaces'; export type PaymentDetailsServiceOptions = BaseServiceOptions & { profileApiUrl: string }; export class PaymentDetailsService extends BaseService { private profileApiUrl: string; constructor(opts: PaymentDetailsServiceOptions) { super(opts); this.profileApiUrl = opts.profileApiUrl; } listPaymentDetails(profileId: string, req: ListPaymentDetailsRequest) { return this.get<PaymentInfo[]>(`${this.profileApiUrl}/${profileId}/payment-details`, req); } addPaymentDetails(profileId: string, req: AddPaymentDetailRequest) { return this.post<PaymentInfo, AddPaymentDetailRequest>(`${this.profileApiUrl}/${profileId}/payment-details`, req); } getDefaultPaymentDetails(profileId: string) { return this.get<PaymentInfo>(`${this.profileApiUrl}/${profileId}/payment-details/default`); } getPaymentDetailsById(profileId: string, paymentDetailId: string) { return this.get<PaymentInfo>(`${this.profileApiUrl}/${profileId}/payment-details/${paymentDetailId}`); } editPaymentDetails(profileId: string, paymentDetailId: string, req: EditPaymentDetailRequest) { return this.put<PaymentInfo, EditPaymentDetailRequest>(`${this.profileApiUrl}/${profileId}/payment-details/${paymentDetailId}`, req); } removePaymentDetails(profileId: string, paymentDetailId: string) { return this.delete<void>(`${this.profileApiUrl}/${profileId}/payment-details/${paymentDetailId}`); } }