Skip to content

Commit

Permalink
fix: Adds SearchResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
luis-herasme committed May 5, 2024
1 parent 895227d commit fb3582d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/azul-api/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { PostSchema, PostSchemaInput, SearchSchema, SearchSchemaInput } from './schemas';
import {
PostSchema,
PostSchemaInput,
SearchResponse,
SearchSchema,
SearchSchemaInput
} from './schemas';
import AzulRequester, { Config } from './request';
import DataVault from './data-vault/data-vault';
import ProcessPayment from './process-payment/process-payment ';
Expand Down Expand Up @@ -56,7 +62,7 @@ class AzulAPI {
* vía Webservices, anteriormente procesadas de un rango de fechas
* previamente seleccionado.
*/
async search(input: SearchSchemaInput): Promise<ProcessPaymentResponse> {
async search(input: SearchSchemaInput): Promise<SearchResponse> {
return await this.requester.safeRequest(SearchSchema.parse(input), Process.SearchPayments);
}
}
Expand Down
27 changes: 26 additions & 1 deletion src/azul-api/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export const PostSchema = z.object({
ITBIS
});

export type PostSchemaInput = z.infer<typeof PostSchema>;

export const SearchSchema = z.object({
// YYYY-MM-DD
dateFrom: z
Expand All @@ -68,4 +70,27 @@ export const SearchSchema = z.object({
});

export type SearchSchemaInput = z.infer<typeof SearchSchema>;
export type PostSchemaInput = z.infer<typeof PostSchema>;

export type SearchResponse = Partial<{
ErrorDescription: string;
ResponseCode: string;
Transactions: Partial<{
Amount: string;
AuthorizationCode: string;
AzulOrderId: string;
CardNumber: string;
CurrencyPosCode: string;
CustomOrderId: string;
DateTime: string;
ErrorDescription: string;
Found: boolean;
IsoCode: string;
Itbis: string;
LotNumber: string;
OrderNumber: string;
RRN: string;
ResponseCode: string;
Ticket: string;
TransactionType: string;
}>[];
}>;

0 comments on commit fb3582d

Please sign in to comment.