Skip to content

Commit

Permalink
Merge pull request #127 from voucherifyio/list-consents
Browse files Browse the repository at this point in the history
Allow to list consents
  • Loading branch information
frakti authored Sep 17, 2020
2 parents 88e261d + defcb65 commit 3d69223
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ API:
|
<a href="#customers-api">Customers</a>
|
<a href="#consents-api">Consents</a>
|
<a href="#orders-api">Orders</a>
|
<a href="#products-api">Products</a>
Expand Down Expand Up @@ -477,6 +479,20 @@ client.customers.updateConsents(customer, consents)

---

### Consents API
Methods are provided within `client.consents.*` namespace.

- [List Customers](#list-customers)

You can [update Customer's consents](#update-customers-consents) in Customer namespace.

#### [List Consents]
```javascript
client.consents.list()
```

---

### Orders API
Methods are provided within `client.orders.*` namespace.

Expand Down Expand Up @@ -1117,6 +1133,7 @@ Bug reports and pull requests are welcome through [GitHub Issues](https://github
[Delete Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-customer
[List Customers]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-customers
[Update Customer's Consents]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-customers-consents
[List Consents]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-consents

[Create Order]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-order
[Get Order]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-order
Expand Down
11 changes: 11 additions & 0 deletions src/Consents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'

module.exports = class Consents {
constructor (client) {
this.client = client
}

list (callback) {
return this.client.get('/consents', null, callback)
}
}
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Redemptions = require('./Redemptions')
const PromotionTiers = require('./PromotionTiers')
const Promotions = require('./Promotions')
const Customers = require('./Customers')
const Consents = require('./Consents')
const Orders = require('./Orders')
const Products = require('./Products')
const Rewards = require('./Rewards')
Expand All @@ -36,6 +37,7 @@ module.exports = function (options) {
const validations = new Validations(client, promotions)
const redemptions = new Redemptions(client, promotions)
const customers = new Customers(client)
const consents = new Consents(client)
const orders = new Orders(client)
const products = new Products(client)
const rewards = new Rewards(client)
Expand All @@ -51,6 +53,7 @@ module.exports = function (options) {
redemptions,
promotions,
customers,
consents,
orders,
products,
rewards,
Expand Down
43 changes: 43 additions & 0 deletions test/consents-api.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* eslint-env mocha */
/* eslint-disable no-unused-expressions */

const nock = require('nock')
const { expect } = require('chai')
const VoucherifyClient = require('./client-loader')
const fixtures = require('./fixtures')
const reqWithoutBody = fixtures.reqWithoutBody

nock.disableNetConnect()

describe('Consents API', function () {
var client = new VoucherifyClient({
applicationId: 'node-sdk-test-id',
clientSecretKey: 'node-sdk-test-secret'
})

describe('list', function () {
it('should list all consents', function (done) {
var server = nock('https://api.voucherify.io', reqWithoutBody)
.get('/v1/consents')
.reply(200, [])

client.consents.list()
.then(function () {
server.done()
done()
})
})

it('should list all consents (callback)', function (done) {
var server = nock('https://api.voucherify.io', reqWithoutBody)
.get('/v1/consents')
.reply(200, [])

client.consents.list(function (err) {
expect(err).to.be.null
server.done()
done()
})
})
})
})

0 comments on commit 3d69223

Please sign in to comment.