Skip to content

Commit

Permalink
Merge pull request #269 from Nexmo/v2.5.1
Browse files Browse the repository at this point in the history
V2.5.1 - apps v2 & verify typings
  • Loading branch information
AlexLakatos authored Oct 4, 2019
2 parents 412f892 + 9e28325 commit 58b11eb
Show file tree
Hide file tree
Showing 25 changed files with 1,386 additions and 279 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ npm-debug.log
coverage
.nyc_output
.idea
coverage.lcov
.DS_Store
.env
.nexmo-app
coverage.lcov
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).

## 2.5.1
- ADDED: typings for Verify API
- ADDED: Applications API V2 support

## 2.4.2
- Added message signing for for sending SMS
- Added `Nexmo.generateSignature` to verify signed messages
Expand Down
66 changes: 57 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,42 +311,90 @@ For an overview of applications see https://developer.nexmo.com/concepts/guides/
### Create an App

```js
nexmo.applications.create(name, type, answerUrl, eventUrl, options, callback);
nexmo.applications.create(params, callback);
```

For more information see https://developer.nexmo.com/api/application#create-an-application
For more information see https://developer.nexmo.com/api/application.v2#createApplication

`params` can be

``` json
{
"name": "My Application",
"capabilities": {
"voice": {
"webhooks": {
"answer_url": {
"address": "https://example.com/webhooks/answer",
"http_method": "POST"
},
"event_url": {
"address": "https://example.com/webhooks/event",
"http_method": "POST"
}
}
},
"messages": {
"webhooks": {
"inbound_url": {
"address": "https://example.com/webhooks/inbound",
"http_method": "POST"
},
"status_url": {
"address": "https://example.com/webhooks/status",
"http_method": "POST"
}
}
},
"rtc": {
"webhooks": {
"event_url": {
"address": "https://example.com/webhooks/event",
"http_method": "POST"
}
}
},
"vbc": {}
}
}
```

### Get a single App

```js
nexmo.applications.get(appId, callback);
nexmo.applications.get(appId, callback, v2flag);
```

For more information see https://developer.nexmo.com/api/application#retrieve-an-application
For more information see https://developer.nexmo.com/api/application.v2#getApplication

- `v2flag` - if `true`, you'll receive the V2 API response, else you'll receive a V1 style response from the V2 API

### Get Apps by a filter

```js
nexmo.applications.get(options, callback);
nexmo.applications.get(options, callback, v2flag);
```

For more information see https://developer.nexmo.com/api/application#retrieve-your-applications
For more information see https://developer.nexmo.com/api/application.v2#listApplication
- `options` - filter options, use `{}` to get all your applications
- `v2flag` - if `true`, you'll receive the V2 API response, else you'll receive a V1 style response from the V2 API


### Update an App

```js
nexmo.applications.update(appId, name, type, answerUrl, eventUrl, options, callback);
nexmo.applications.update(appId, params, callback);
```

For more information see https://developer.nexmo.com/api/application#update-an-application
For more information see https://developer.nexmo.com/api/application.v2#updateApplication

### Delete an App

```js
nexmo.application.delete(appId, callback);
```

For more information see https://developer.nexmo.com/api/application#destroy-an-application
For more information see https://developer.nexmo.com/api/application.v2#deleteApplication

## Management

Expand Down
23 changes: 23 additions & 0 deletions examples/ex-create-v1-application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = function(callback, config) {

var Nexmo = require('../lib/Nexmo');

var nexmo = new Nexmo({
apiKey: config.API_KEY,
apiSecret: config.API_SECRET
}, {
debug: config.DEBUG
});

const name = 'My nexmo-node Messages App';
const type = 'messages';
const answerUrl = 'https://example.com'; // webhook that points to NCCO
const eventUrl = 'https://example.com';

let options = {
inbound_url: 'https://example.com',
status_url: 'https://example.com'
};

nexmo.applications.create(name, type, answerUrl, eventUrl, options, callback);
};
49 changes: 49 additions & 0 deletions examples/ex-create-v2-application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module.exports = function(callback, config) {

var Nexmo = require('../lib/Nexmo');

var nexmo = new Nexmo({
apiKey: config.API_KEY,
apiSecret: config.API_SECRET
}, {
debug: config.DEBUG
});

nexmo.applications.create({
name: 'My nexmo-node Example V2 App',
capabilities: {
voice: {
webhooks: {
answer_url: {
address: "https://example.com",
http_method: "GET"
},
event_url: {
address: "https://example.com",
http_method: "POST"
}
}
},
messages: {
webhooks: {
inbound_url: {
address: "https://example.com",
http_method: "POST"
},
status_url: {
address: "https://example.com",
http_method: "POST"
}
}
},
rtc: {
webhooks: {
event_url: {
address: "https://example.com",
http_method: "POST"
}
}
}
}
}, callback);
};
13 changes: 13 additions & 0 deletions examples/ex-delete-application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = function(callback, config) {

var Nexmo = require('../lib/Nexmo');

var nexmo = new Nexmo({
apiKey: config.API_KEY,
apiSecret: config.API_SECRET
},
{debug: config.DEBUG}
);

nexmo.applications.delete(config.APP_ID, callback);
};
13 changes: 0 additions & 13 deletions examples/ex-get-apps.js

This file was deleted.

13 changes: 13 additions & 0 deletions examples/ex-get-v1-application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = function(callback, config) {

var Nexmo = require('../lib/Nexmo');

var nexmo = new Nexmo({
apiKey: config.API_KEY,
apiSecret: config.API_SECRET
},
{debug: config.DEBUG}
);

nexmo.applications.get(config.APP_ID, callback);
};
13 changes: 13 additions & 0 deletions examples/ex-get-v1-applications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = function(callback, config) {

var Nexmo = require('../lib/Nexmo');

var nexmo = new Nexmo({
apiKey: config.API_KEY,
apiSecret: config.API_SECRET
},
{debug: config.DEBUG}
);

nexmo.applications.get({page_size: 5}, callback);
};
13 changes: 13 additions & 0 deletions examples/ex-get-v2-application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = function(callback, config) {

var Nexmo = require('../lib/Nexmo');

var nexmo = new Nexmo({
apiKey: config.API_KEY,
apiSecret: config.API_SECRET
},
{debug: config.DEBUG}
);

nexmo.applications.get(config.APP_ID, callback, true);
};
13 changes: 13 additions & 0 deletions examples/ex-get-v2-applications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = function(callback, config) {

var Nexmo = require('../lib/Nexmo');

var nexmo = new Nexmo({
apiKey: config.API_KEY,
apiSecret: config.API_SECRET
},
{debug: config.DEBUG}
);

nexmo.applications.get({page_size: 5}, callback, true);
};
23 changes: 23 additions & 0 deletions examples/ex-update-v1-application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = function(callback, config) {

var Nexmo = require('../lib/Nexmo');

var nexmo = new Nexmo({
apiKey: config.API_KEY,
apiSecret: config.API_SECRET
}, {
debug: config.DEBUG
});

const name = 'My updated nexmo-node Messages App';
const type = 'messages';
const answerUrl = 'https://example.com'; // webhook that points to NCCO
const eventUrl = 'https://example.com';

let options = {
inbound_url: 'https://example.com',
status_url: 'https://example.com'
};

nexmo.applications.update(config.APP_ID, name, type, answerUrl, eventUrl, options, callback);
};
49 changes: 49 additions & 0 deletions examples/ex-update-v2-application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module.exports = function(callback, config) {

var Nexmo = require('../lib/Nexmo');

var nexmo = new Nexmo({
apiKey: config.API_KEY,
apiSecret: config.API_SECRET
}, {
debug: config.DEBUG
});

nexmo.applications.update(config.APP_ID, {
name: 'My updated nexmo-node Example V2 App',
capabilities: {
voice: {
webhooks: {
answer_url: {
address: "https://example.com",
http_method: "GET"
},
event_url: {
address: "https://example.com",
http_method: "POST"
}
}
},
messages: {
webhooks: {
inbound_url: {
address: "https://example.com",
http_method: "POST"
},
status_url: {
address: "https://example.com",
http_method: "POST"
}
}
},
rtc: {
webhooks: {
event_url: {
address: "https://example.com",
http_method: "POST"
}
}
}
}
}, callback);
};
13 changes: 11 additions & 2 deletions examples/run-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,24 @@ exampleFiles = [
// 'ex-make-call.js',
// 'ex-number-insight-basic.js',
// 'ex-send-sms.js',
'ex-send-signed-sms.js',
// 'ex-send-signed-sms.js',
// 'ex-verify-signed-sms.js',
// 'ex-verify-signed-sms-without-instance.js',
// 'ex-stream-to-call.js',
// 'ex-talk-to-call.js',
// 'ex-create-secret.js',
// 'ex-get-secret.js',
// 'ex-list-secrets.js',
// 'ex-revoke-secret.js'
// 'ex-revoke-secret.js',
// 'ex-create-v1-application.js',
// 'ex-create-v2-application.js',
// 'ex-update-v1-application.js',
// 'ex-update-v2-application.js',
// 'ex-get-v1-application.js',
// 'ex-get-v1-applications.js',
// 'ex-get-v2-application.js',
// 'ex-get-v2-applications.js',
// 'ex-delete-application.js',
];

console.log('Found', exampleFiles.length, 'examples to run:\n', exampleFiles);
Expand Down
Loading

0 comments on commit 58b11eb

Please sign in to comment.