File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,12 @@ export class Authorizations extends BaseResource {
88 super ( token , basePath + "/authorizations" , config )
99 }
1010
11- public async get ( id : string ) : Promise < UnitResponse < Authorization > > {
12- return this . httpGet < UnitResponse < Authorization > > ( `/${ id } ` )
11+ public async get ( id : string , includeNonAuthorized = false ) : Promise < UnitResponse < Authorization > > {
12+ const parameters : any = {
13+ ...( includeNonAuthorized && { "filter[includeNonAuthorized]" : includeNonAuthorized } ) ,
14+ }
15+
16+ return this . httpGet < UnitResponse < Authorization > > ( `/${ id } ` , { params : parameters } )
1317 }
1418
1519 public async find ( params ?: AuthorizationQueryParams ) : Promise < UnitResponse < Authorization [ ] > & Meta > {
@@ -85,7 +89,7 @@ export interface AuthorizationQueryParams {
8589 /**
8690 * Optional. Filter authorizations by (Authorization Status)[https://docs.unit.co/cards-authorizations/#authorization-statuses].
8791 */
88- status : string [ ]
92+ status ? : string [ ]
8993
9094 /**
9195 * Optional. Leave empty or provide sort=createdAt for ascending order. Provide sort=-createdAt (leading minus sign) for descending order.
Original file line number Diff line number Diff line change 1+ import { Unit } from "../unit"
2+
3+ import dotenv from "dotenv"
4+ dotenv . config ( )
5+ const unit = new Unit ( process . env . UNIT_TOKEN || "test" , process . env . UNIT_API_URL || "test" )
6+ const authorizationIds : string [ ] = [ ]
7+
8+ describe ( "Authorization Find" , ( ) => {
9+ test ( "Get Authorization List" , async ( ) => {
10+ const res = await unit . authorizations . find ( { limit : 10 } )
11+ res . data . forEach ( element => { 0
12+ expect ( element . type === "authorization" ) . toBeTruthy ( )
13+ authorizationIds . push ( element . id )
14+ } )
15+ } )
16+ } )
17+
18+ describe ( "Get Authorization" , ( ) => {
19+ test ( "get authorization" , async ( ) => {
20+ authorizationIds . forEach ( async id => {
21+ const res = await unit . authorizations . get ( id )
22+ expect ( res . data . type === "authorization" ) . toBeTruthy ( )
23+ } )
24+ } )
25+ } )
You can’t perform that action at this time.
0 commit comments