Skip to content

Commit

Permalink
feat(vouchers): allow queries in meta
Browse files Browse the repository at this point in the history
  • Loading branch information
eljefedelrodeodeljefe committed Jul 14, 2019
1 parent c813360 commit 4ff50ce
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/v0/vouchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export interface VouchersQueryOptions {
}
}

export interface VouchersMetaQuery {
deleted?: boolean
active?: boolean
}

export interface VouchersResponse {
data: object[]
metadata: object
Expand Down Expand Up @@ -128,11 +133,17 @@ export class Vouchers {
})
}

meta(): Promise<VouchersResponse> {
meta(q?: VouchersMetaQuery | undefined): Promise<VouchersResponse> {
return new Promise(async (resolve, reject) => {
let uri = `${this.options.base}${this.endpoint}/${this.options.user}/meta`

try {
const queryString = qs.stringify(q)

if (queryString) {
uri = `${uri}?${queryString}`
}

const response = await this.http.getClient().get(uri)
if (response.status !== 200) {
return reject(new errors.VouchersMetaFailed(undefined, { status: response.status }))
Expand Down

0 comments on commit 4ff50ce

Please sign in to comment.