Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bindings for Terminal endpoints #498

Merged
merged 2 commits into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/resources/Terminal/ConnectionTokens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

var StripeResource = require('../../StripeResource');

module.exports = StripeResource.extend({
path: 'terminal/connection_tokens',
includeBasic: ['create'],
})
8 changes: 8 additions & 0 deletions lib/resources/Terminal/Locations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

var StripeResource = require('../../StripeResource');

module.exports = StripeResource.extend({
path: 'terminal/locations',
includeBasic: ['create', 'list', 'retrieve', 'update'],
})
8 changes: 8 additions & 0 deletions lib/resources/Terminal/Readers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

var StripeResource = require('../../StripeResource');

module.exports = StripeResource.extend({
path: 'terminal/readers',
includeBasic: ['create', 'list', 'retrieve', 'update'],
})
5 changes: 5 additions & 0 deletions lib/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ var resources = {
Sigma: resourceNamespace('sigma', {
ScheduledQueryRuns: require('./resources/Sigma/ScheduledQueryRuns'),
}),
Terminal: resourceNamespace('terminal', {
ConnectionTokens: require('./resources/Terminal/ConnectionTokens'),
Locations: require('./resources/Terminal/Locations'),
Readers: require('./resources/Terminal/Readers'),
}),
};

Stripe.StripeResource = require('./StripeResource');
Expand Down
21 changes: 21 additions & 0 deletions test/resources/Terminal/ConnectionTokens.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

var stripe = require('../../testUtils').getSpyableStripe();

var expect = require('chai').expect;

describe('Terminal', function() {
describe('ConnectionToken Resource', function () {
describe('create', function() {
it('Sends the correct request', function () {
stripe.terminal.connectionTokens.create({});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/terminal/connection_tokens',
headers: {},
data: {},
});
});
});
});
});
80 changes: 80 additions & 0 deletions test/resources/Terminal/Locations.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
'use strict';

var stripe = require('../../testUtils').getSpyableStripe();

var expect = require('chai').expect;

describe('Terminal', function () {
describe('Locations Resource', function () {
describe('retrieve', function () {
it('Sends the correct request', function () {
stripe.terminal.locations.retrieve('loc_123');

expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/terminal/locations/loc_123',
headers: {},
data: {},
});
});
});

describe('create', function () {
it('Sends the correct request', function () {
stripe.terminal.locations.create({
display_name: 'name',
address: {
line1: 'line1',
country: 'US',
postal_code: '12345',
state: 'CA',
city: 'San Francisco',
},
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/terminal/locations',
headers: {},
data: {
display_name: 'name',
address: {
line1: 'line1',
country: 'US',
postal_code: '12345',
state: 'CA',
city: 'San Francisco',
},
},
});
});
});

describe('update', function () {
it('Sends the correct request', function () {
stripe.terminal.locations.update('loc_123', {
display_name: 'name'
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/terminal/locations/loc_123',
headers: {},
data: {
display_name: 'name',
},
});
});
});

describe('list', function () {
it('Sends the correct request', function () {
stripe.terminal.locations.list();
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/terminal/locations',
headers: {},
data: {},
});
});
});
});
});
68 changes: 68 additions & 0 deletions test/resources/Terminal/Readers.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
'use strict';

var stripe = require('../../testUtils').getSpyableStripe();

var expect = require('chai').expect;

describe('Terminal', function () {
describe('Readers Resource', function () {
describe('retrieve', function () {
it('Sends the correct request', function () {
stripe.terminal.readers.retrieve('rdr_123');

expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/terminal/readers/rdr_123',
headers: {},
data: {},
});
});
});

describe('create', function () {
it('Sends the correct request', function () {
stripe.terminal.readers.create({
registration_code: 'a-b-c',
label: 'name',
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/terminal/readers',
headers: {},
data: {
registration_code: 'a-b-c',
label: 'name',
},
});
});
});

describe('update', function () {
it('Sends the correct request', function () {
stripe.terminal.readers.update('rdr_123', {
label: 'name'
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/terminal/readers/rdr_123',
headers: {},
data: {
label: 'name',
},
});
});
});

describe('list', function () {
it('Sends the correct request', function () {
stripe.terminal.readers.list();
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/terminal/readers',
headers: {},
data: {},
});
});
});
});
});