Stripe Subscriptions module API explorer

/api/administrator/subscriptions/customers-count (GET)

Account information like email addresses is generated with faker-js it is not real user information.

await global.api.administrator.subscriptions.CustomersCount.get(req)

NodeJS source (view on github)

const subscriptions = require('../../../../../index.js')

module.exports = {
  get: async (req) => {
    return subscriptions.Storage.Customer.count({
      where: {
        appid: req.appid || global.appid
      }
    })
  }
}

Test source (view on github)

/* eslint-env mocha */
const assert = require('assert')
const TestHelper = require('../../../../../test-helper.js')

describe('/api/administrator/subscriptions/customers-count', function () {
  before(TestHelper.disableMetrics)
  after(TestHelper.enableMetrics)
  describe('returns', () => {
    it('integer', async () => {
      const administrator = await TestHelper.createOwner()
      const user1 = await TestHelper.createUser()
      await TestHelper.createCustomer(user1, {
        email: user1.profile.contactEmail
      })
      const user2 = await TestHelper.createUser()
      await TestHelper.createCustomer(user2, {
        email: user2.profile.contactEmail
      })
      const req = TestHelper.createRequest('/api/administrator/subscriptions/customers-count')
      req.account = administrator.account
      req.session = administrator.session
      req.filename = __filename
      req.saveResponse = true
      const result = await req.get()
      assert.strictEqual(result, global.pageSize)
    })
  })
})