akua-sdk
Version:
TypeScript SDK for Akua Acquiring Processor
104 lines (103 loc) • 3.94 kB
TypeScript
import { HttpClient } from '../http/client';
import { ApiResponse } from '../types';
import { InstrumentDTO } from '../types/dtos';
import { CreateInstrumentRequest, UpdateInstrumentRequest } from '../types/instrument/';
/**
* Service responsible for managing payment instruments (payment methods) in the Akua API.
* @class InstrumentService
*/
export declare class InstrumentService {
private readonly httpClient;
/**
* Creates an instance of InstrumentService.
* @param {HttpClient} httpClient - The HTTP client instance used for making API requests.
*/
constructor(httpClient: HttpClient);
/**
* Retrieves all payment instruments associated with the merchant.
* @async
* @returns {Promise<ApiResponse<InstrumentDTO[]>>} A promise that resolves to an array of payment instruments.
* @example
* // Get all payment instruments
* await instrumentService.get();
*/
get(): Promise<ApiResponse<InstrumentDTO[]>>;
/**
* Retrieves a specific payment instrument by its ID.
* @async
* @param {string} instrumentId - The unique identifier of the payment instrument.
* @returns {Promise<ApiResponse<InstrumentDTO>>} A promise that resolves to the requested payment instrument.
* @example
* // Get a payment instrument by ID
* await instrumentService.getById('instr_123');
*/
getById(instrumentId: string): Promise<ApiResponse<InstrumentDTO>>;
/**
* Creates a new payment instrument.
* @async
* @param {CreateInstrumentRequest} createInstrumentRequest - The data required to create a new payment instrument.
* @returns {Promise<ApiResponse<InstrumentDTO>>} A promise that resolves to the newly created payment instrument.
* @example
* // Create a new credit card instrument
* await instrumentService.create({
* type: 'CARD',
* card: {
* number: '4242424242424242',
* expiration_month: '12',
* expiration_year: '2025',
* first_name: 'John',
* last_name: 'Doe',
* cvv: '123'
* },
* user_data: {
* billing_address: {
* street: '123 Main St',
* number: 'Apt 4B',
* city: 'New York',
* state: 'NY',
* zip_code: '10001',
* country: 'US'
* }
* }
* });
*/
create(createInstrumentRequest: CreateInstrumentRequest): Promise<ApiResponse<InstrumentDTO>>;
/**
* Updates an existing payment instrument.
* @async
* @param {string} instrumentId - The unique identifier of the payment instrument to update.
* @param {UpdateInstrumentRequest} data - The data to update the payment instrument with.
* @returns {Promise<ApiResponse<InstrumentDTO>>} A promise that resolves to the updated payment instrument.
* @example
* // Update a payment instrument
* await instrumentService.update('instr_123', {
* card: {
* expiration_month: '12',
* expiration_year: '2026',
* first_name: 'John',
* last_name: 'Smith'
* },
* user_data: {
* billing_address: {
* street: '123 Main St',
* number: 'Apt 4B',
* city: 'New York',
* state: 'NY',
* zip_code: '10001',
* country: 'US'
* }
* }
* });
*/
update(instrumentId: string, data: UpdateInstrumentRequest): Promise<ApiResponse<InstrumentDTO>>;
/**
* Deletes a payment instrument.
* @async
* @param {string} instrumentId - The unique identifier of the payment instrument to delete.
* @returns {Promise<ApiResponse<void>>} A promise that resolves when the deletion is successful.
* @example
* // Delete a payment instrument
* await instrumentService.delete('instr_123');
*/
delete(instrumentId: string): Promise<ApiResponse<void>>;
}