akua-sdk
Version:
TypeScript SDK for Akua Acquiring Processor
55 lines (54 loc) • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrganizationService = void 0;
const mapper_1 = require("../helpers/mapper");
/**
* Service responsible for managing organization-related operations in the Akua API.
* @class OrganizationService
*/
class OrganizationService {
httpClient;
/**
* Creates an instance of OrganizationService.
* @param {HttpClient} httpClient - The HTTP client instance used for making API requests.
*/
constructor(httpClient) {
this.httpClient = httpClient;
}
/**
* Creates a new organization in the Akua system.
* @async
* @param {CreateOrganizationRequest} createOrganizationRequest - The data required to create a new organization.
* @returns {Promise<ApiResponse<OrganizationDTO>>} A promise that resolves to the newly created organization information.
* @example
* // Create a new organization
* await organizationService.create({
* name: 'Acme Corp'
* });
*/
async create(createOrganizationRequest) {
const response = await this.httpClient.post('/v1/organizations', createOrganizationRequest);
const mappedData = mapper_1.Mapper.mapToOrganizationDTO(response.data);
return {
...response,
data: mappedData,
};
}
/**
* Retrieves all organizations from the Akua system.
* @async
* @returns {Promise<ApiResponse<OrganizationDTO[]>>} A promise that resolves to an array of organization DTOs.
* @example
* // Get all organizations
* await organizationService.get();
*/
async get() {
const response = await this.httpClient.get('/v1/organizations');
const mappedData = mapper_1.Mapper.mapToOrganizationDTO(response.data.data);
return {
...response,
data: mappedData,
};
}
}
exports.OrganizationService = OrganizationService;