UNPKG

akua-sdk

Version:

TypeScript SDK for Akua Acquiring Processor

157 lines (156 loc) 5.85 kB
import { HttpClient } from '../http/client'; import { ApiResponse } from '../types'; import { MerchantDTO } from '../types/dtos'; import { CreateMerchantRequest, GetMerchantsRequest, UpdateMerchantRequest, UpdateMerchantRailsRequest } from '../types/merchant/'; /** * Service responsible for managing merchant-related operations in the Akua API. * @class MerchantService */ export declare class MerchantService { private readonly httpClient; /** * Creates an instance of MerchantService. * @param {HttpClient} httpClient - The HTTP client instance used for making API requests. */ constructor(httpClient: HttpClient); /** * Creates a new merchant in the Akua system. * @async * @param {CreateMerchantRequest} createMerchantRequest - The data required to create a new merchant * @returns {Promise<ApiResponse<MerchantDTO>>} A promise that resolves to the newly created merchant information * @example * // Create a new merchant * await merchantService.create({ * name: 'My Store', * organization_id: 'org_123', * country: 'US', * city: 'New York', * state: 'NY', * billing_address: { * street: '123 Main St', * city: 'New York', * state: 'NY', * country: 'US', * postal_code: '10001' * }, * location_address: { * street: '123 Main St', * city: 'New York', * state: 'NY', * country: 'US', * postal_code: '10001' * }, * classification_mode: 'retail', * default_currency: 'USD', * supported_currencies: ['USD', 'EUR'], * activity: 'retail', * alias: 'my-store-ny', * email: 'store@example.com', * external_id: 'ext_123', * phone: '+1234567890', * tax_id: '123456789', * rails: { * VISA: { * category_code: '5411', * payfac_id: 'payfac_123' * }, * MASTERCARD: { * category_code: '5411', * payfac_id: 'payfac_123' * } * } * }); */ create(createMerchantRequest: CreateMerchantRequest): Promise<ApiResponse<MerchantDTO>>; /** * Retrieves a merchant's information by its unique identifier. * @async * @param {string} merchantId - The unique identifier of the merchant to retrieve. * @returns {Promise<ApiResponse<MerchantDTO>>} A promise that resolves to the merchant's information. * @example * // Get merchant information by ID * await merchantService.getById('merch_123456789'); */ getById(merchantId: string): Promise<ApiResponse<MerchantDTO>>; /** * Deletes a merchant from the Akua system. * @async * @param {string} merchantId - The unique identifier of the merchant to delete. * @returns {Promise<ApiResponse<void>>} A promise that resolves when the merchant is successfully deleted. * @example * // Delete a merchant by ID * await merchantService.delete('merch_123456789'); */ delete(merchantId: string): Promise<ApiResponse<void>>; /** * Updates the rails configuration for a merchant. * @async * @param {string} merchantId - The unique identifier of the merchant to update. * @param {UpdateMerchantRailsRequest} updateRailsRequest - The new rails configuration for the merchant. * @returns {Promise<ApiResponse<MerchantDTO>>} A promise that resolves to the updated merchant information. * @example * // Update merchant rails configuration * await merchantService.updateRails('merch_123456789', { * VISA: { * category_code: '1234', * payfac_id: 'pfc-123', * external_id: 'mer-ext-123', * classification: 'micro-merchant', * annual_volume: [ * { * currency: 'COP', * value: 10000000 * } * ], * products: { * DEBIT: { * network_merchant_id: 'VISA-123', * enabled: true * }, * CREDIT: { * network_merchant_id: 'VISA-123', * enabled: true * } * } * } * }); */ updateRails(merchantId: string, updateRailsRequest: UpdateMerchantRailsRequest): Promise<ApiResponse<MerchantDTO>>; /** * Lists all merchants for an organization with pagination support. * @async * @param {ListMerchantsRequest} request - The request parameters for listing merchants. * @returns {Promise<ApiResponse<MerchantDTO[]>>} A promise that resolves to a paginated list of merchants. * @example * // List merchants for an organization * await merchantService.get({ * organization_id: 'org-d0j35vc4t5u70r4eso70', * page: 1, * page_size: 20, * sort: 'created_at:desc' * }); */ get(request: GetMerchantsRequest): Promise<ApiResponse<MerchantDTO[]>>; /** * Updates an existing merchant's information. * @async * @param {string} merchantId - The unique identifier of the merchant to update. * @param {UpdateMerchantRequest} updateRequest - The data to update the merchant with. * @returns {Promise<ApiResponse<MerchantDTO>>} A promise that resolves to the updated merchant information. * @example * // Update a merchant * await merchantService.update('merch_123456789', { * name: 'Updated Store Name', * email: 'updated@example.com', * phone: '+1987654321', * billing_address: { * street: '456 New St', * city: 'Los Angeles', * state: 'CA', * country: 'US', * postal_code: '90001' * } * }); */ update(merchantId: string, updateRequest: UpdateMerchantRequest): Promise<ApiResponse<MerchantDTO>>; }