11import { Card , CardLimits , CreateDebitCardRequest , PinStatus , ReplaceCardRequest } from "../types/cards"
2- import { Include , UnitConfig , UnitResponse } from "../types/common"
2+ import { BaseListParams , Include , UnitConfig , UnitResponse } from "../types/common"
33import { Customer } from "../types/customer"
44import { Account } from "../types/account"
55import { BaseResource } from "./baseResource"
@@ -56,14 +56,19 @@ export class Cards extends BaseResource {
5656 }
5757
5858 public async list ( params ?: CardListParams ) : Promise < UnitResponse < Card [ ] > & Include < Account [ ] | Customer [ ] > > {
59- const parameters = {
60- "page[limit]" : ( params ?. limit ? params ? .limit : 100 ) ,
61- "page[offset]" : ( params ?. offset ? params ? .offset : 0 ) ,
62- ...( params ?. accountId && { "filter[accountId]" : params ? .accountId } ) ,
63- ...( params ?. customerId && { "filter[customerId]" : params ? .customerId } ) ,
64- ...( params ?. include && { "include" : params ? .include } )
59+ const parameters : any = {
60+ "page[limit]" : ( params ?. limit ? params . limit : 100 ) ,
61+ "page[offset]" : ( params ?. offset ? params . offset : 0 ) ,
62+ ...( params ?. accountId && { "filter[accountId]" : params . accountId } ) ,
63+ ...( params ?. customerId && { "filter[customerId]" : params . customerId } ) ,
64+ ...( params ?. include && { "include" : params . include } )
6565 }
6666
67+ if ( params ?. status )
68+ params . status . forEach ( ( s , idx ) => {
69+ parameters [ `filter[status][${ idx } ]` ] = s
70+ } )
71+
6772 return this . httpGet < UnitResponse < Card [ ] > & Include < Account [ ] | Customer [ ] > > ( "" , { params : parameters } )
6873 }
6974
@@ -78,19 +83,7 @@ export class Cards extends BaseResource {
7883 }
7984}
8085
81- export interface CardListParams {
82- /**
83- * Maximum number of resources that will be returned. Maximum is 1000 resources. See Pagination.
84- * default: 100
85- */
86- limit ?: number
87-
88- /**
89- * Number of resources to skip. See Pagination.
90- * default: 0
91- */
92- offset ?: number
93-
86+ export interface CardListParams extends BaseListParams {
9487 /**
9588 * Optional. Filters the results by the specified account id.
9689 * default: empty
@@ -108,4 +101,9 @@ export interface CardListParams {
108101 * default: empty
109102 */
110103 include ?: string
104+
105+ /**
106+ * Optional. Filter customers by status (Active, Archived). Usage example: *filter[status][0]=Active
107+ */
108+ status ?: string [ ]
111109}
0 commit comments