Skip to content

Commit ac21229

Browse files
authored
Authorizations fix (#184)
* Fixed authorization status filter * Fixed authorization status filter
1 parent cb0f0bc commit ac21229

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

resources/authorization.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Authorization } from "../types/authorization"
1+
import {Authorization, AuthorizationStatus} from "../types/authorization"
22
import { Meta, UnitConfig, UnitResponse } from "../types/common"
33
import { BaseResource } from "./baseResource"
44

@@ -28,7 +28,8 @@ export class Authorizations extends BaseResource {
2828
...(params?.includeNonAuthorized && { "filter[includeNonAuthorized]": params.includeNonAuthorized }),
2929
...(params?.sort && { "sort": params.sort }),
3030
...(params?.toAmount && { "filter[toAmount]": params.toAmount }),
31-
...(params?.fromAmount && { "filter[fromAmount]": params.fromAmount })
31+
...(params?.fromAmount && { "filter[fromAmount]": params.fromAmount }),
32+
...(params?.status && { "filter[status]": params.status })
3233
}
3334

3435
if (params?.merchantCategoryCode)
@@ -89,7 +90,7 @@ export interface AuthorizationQueryParams {
8990
/**
9091
* Optional. Filter authorizations by (Authorization Status)[https://docs.unit.co/cards-authorizations/#authorization-statuses].
9192
*/
92-
status?: string[]
93+
status?: AuthorizationStatus
9394

9495
/**
9596
* Optional. Leave empty or provide sort=createdAt for ascending order. Provide sort=-createdAt (leading minus sign) for descending order.

tests/authorizations.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const authorizationIds: string[] = []
77

88
describe("Authorization Find", () => {
99
test("Get Authorization List", async () => {
10-
const res = await unit.authorizations.find({limit: 10})
10+
const res = await unit.authorizations.find({limit: 10, status: "Authorized"})
1111
res.data.forEach(element => {0
1212
expect(element.type === "authorization").toBeTruthy()
1313
authorizationIds.push(element.id)

types/authorization.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Relationship } from "./common"
22

3+
export type AuthorizationStatus = "Authorized" | "Completed" | "Canceled" | "Declined"
4+
35
export interface Authorization {
46
/**
57
* Identifier of the authorization resource.

0 commit comments

Comments
 (0)