Skip to content

Commit

Permalink
Consents types (#18)
Browse files Browse the repository at this point in the history
* Added Conents type

* Updated types/index.ts

* Updated Consents types
  • Loading branch information
pkgacek authored Jan 19, 2021
1 parent 022b037 commit 4d01aad
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/khaki-cobras-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@voucherify/sdk': patch
---

Updated Consents types
5 changes: 5 additions & 0 deletions .changeset/sharp-horses-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@voucherify/sdk': patch
---

Added Consents type
4 changes: 3 additions & 1 deletion packages/sdk/src/Consents.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as T from './types/Consents'

import type { RequestController } from './RequestController'

export class Consents {
Expand All @@ -7,6 +9,6 @@ export class Consents {
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-consents
*/
public list() {
return this.client.get('/consents')
return this.client.get<T.ConsentsListResponse>('/consents')
}
}
34 changes: 34 additions & 0 deletions packages/sdk/src/types/Consents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
interface ConstentGroup {
id: string
name: string
description: string
consents: string[]
created_at: string
updated_at?: string
object: 'consent_group'
}

interface Consent {
id: string
name: string
description: string
category: string
created_at: string
updated_at?: string
object: 'consent'
}

export interface ConsentsListResponse {
groups: {
object: 'list'
total: number
data_ref: 'data'
data: ConstentGroup[]
}
consents: {
object: 'list'
total: number
data_ref: 'data'
data: Consent[]
}
}
1 change: 1 addition & 0 deletions packages/sdk/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './Customers'
export * from './Balance'
export * from './Consents'
export * from './Events'

0 comments on commit 4d01aad

Please sign in to comment.