Socket
Socket
Sign inDemoInstall

notifications-node-client

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notifications-node-client - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

CONTRIBUTING.md

10

.github/PULL_REQUEST_TEMPLATE.md

@@ -11,3 +11,9 @@ <!--Thanks for contributing to GOV.UK Notify. Using this template to write your pull request message will help get it merged as soon as possible. -->

- [ ] I’ve written unit tests for these changes
- [ ] I’ve update the documentation (in `README.md`)
- [ ] I’ve bumped the version number (in `package.json`)
- [ ] I’ve updated the documentation in
- `README.md`
- `CHANGELOG.md`
- [ ] I’ve bumped the version number in
- `package.json`
- [ ] I've added new environment variables in
- `CONTRIBUTING.md`
- `notifications-node-client/scripts/generate_docker_env.sh`

@@ -0,1 +1,8 @@

## [4.1.0] - 2017-11-23
### Changed
* Added new method:
* `getReceivedTexts` - get one page of text messages (250) per call
## [4.0.0] - 2017-11-07

@@ -2,0 +9,0 @@

@@ -247,2 +247,18 @@ var ApiClient = require('./api_client'),

/**
*
* @param {String} olderThan
*
* @returns {Promise}
*/
getReceivedTexts: function(olderThan){
if (olderThan) {
queryString = '?older_than=' + olderThan;
} else {
queryString = '';
}
return this.apiClient.get('/v2/received-text-messages' + queryString);
},
/**
*

@@ -249,0 +265,0 @@ * @param {String} url

2

package.json
{
"name": "notifications-node-client",
"version": "4.0.0",
"version": "4.1.0",
"description": "GOV.UK Notify Node.js client ",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -883,3 +883,70 @@ # GOV.UK Notify Node.js client

## Get received text messages with pagination
This will return one page of text messages (250) per call.
#### Method
<details>
<summary>
Click here to expand for more information.
</summary>
```javascript
notifyClient
.getReceivedTexts(olderThan)
.then((response) => { })
.catch((err) => {})
;
```
</details>
#### Response
<details>
<summary>
Click here to expand for more information.
</summary>
If the request is successful, `response` will be a `json object`:
```javascript
{
"received_text_messages":
[
{
"id": "notify_id", // required
"user_number": "user number", // required user number
"notify_number": "notify number", // receiving number
"created_at": "created at", // required
"service_id": "service id", // required service id
"content": "text content" // required text content
},
],
"links": {
"current": "/received-test-messages",
"next": "/received-text-messages?older_than=last_id_in_list"
}
}
```
</details>
#### Arguments
<details>
<summary>
Click here to expand for more information.
</summary>
##### `olderThan`
If omitted, returns 250 of the latest received text messages. Otherwise the next 250 received text messages older than the given id are returned.
</details>
## Tests

@@ -886,0 +953,0 @@

@@ -49,3 +49,3 @@ {

"required": ["body", "subject"]
}
}
}

@@ -27,2 +27,3 @@ const NotifyClient = require('../../client/notification.js').NotifyClient;

let notifyClient;
let whitelistNotifyClient;
let emailNotificationId;

@@ -49,5 +50,8 @@ let smsNotificationId;

const urlBase = process.env.NOTIFY_API_URL;
const serviceId = process.env.SERVICE_ID;
const apiKeyId = process.env.API_KEY;
notifyClient = new NotifyClient(urlBase, serviceId, apiKeyId);
const apiKeyId = process.env.API_KEY
const inboundSmsKeyId = process.env.INBOUND_SMS_QUERY_KEY;
const whitelistApiKeyId = process.env.API_SENDING_KEY;
notifyClient = new NotifyClient(urlBase, apiKeyId);
whitelistNotifyClient = new NotifyClient(urlBase, whitelistApiKeyId);
receivedTextClient = new NotifyClient(urlBase, inboundSmsKeyId);
var definitions_json = require('./schemas/v2/definitions.json');

@@ -106,3 +110,3 @@ chai.tv4.addSchema('definitions.json', definitions_json);

should.exist(smsSenderId);
return notifyClient.sendSms(smsTemplateId, phoneNumber, options).then((response) => {
return whitelistNotifyClient.sendSms(smsTemplateId, phoneNumber, options).then((response) => {
response.statusCode.should.equal(201);

@@ -176,2 +180,4 @@ expect(response.body).to.be.jsonSchema(postSmsNotificationResponseJson);

var postTemplatePreviewJson = require('./schemas/v2/POST_template_preview.json');
var getReceivedTextJson = require('./schemas/v2/GET_received_text_response.json');
var getReceivedTextsJson = require('./schemas/v2/GET_received_texts_response.json');

@@ -288,4 +294,14 @@ it('get sms template by id', () => {

it('get all received texts', (done) => {
chai.tv4.addSchema('receivedText.json', getReceivedTextJson);
return receivedTextClient.getReceivedTexts().then((response) => {
response.statusCode.should.equal(200);
expect(response.body).to.be.jsonSchema(getReceivedTextsJson);
expect(response.body["received_text_messages"]).to.be.an('array').that.is.not.empty;
done();
});
});
});
});

@@ -378,4 +378,32 @@ var expect = require('chai').expect, NotifyClient = require('../client/notification.js').NotifyClient,

it('should get latest 250 received texts', function(done) {
notifyAuthNock
.get('/v2/received-text-messages')
.reply(200, {"foo":"bar"});
notifyClient.getReceivedTexts()
.then(function(response){
expect(response.statusCode).to.equal(200);
done();
});
});
it('should get up to next 250 received texts with a reference older than a given message id', function(done) {
var olderThanId = '35836a9e-5a97-4d99-8309-0c5a2c3dbc72';
notifyAuthNock
.get('/v2/received-text-messages?older_than=' + olderThanId)
.reply(200, {"foo":"bar"});
notifyClient.getReceivedTexts(olderThanId)
.then(function(response){
expect(response.statusCode).to.equal(200);
done();
});
});
});
MockDate.reset();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc