@bluedot-innovation/models 7.5.4 → 7.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 7.5.5
2
+ - Remove url requirement from mobivity webhook body
3
+
1
4
  ## 7.5.4
2
5
  - Added webhook type "register" and structure "mobivity"
3
6
 
@@ -387,11 +387,11 @@ describe('Project', () => {
387
387
  it(`should throw an error if structure is mobivity and taregt_id is not a body field`, (done) => {
388
388
  project.webhooks[0].type = "register"
389
389
  project.webhooks[0].structure = "mobivity"
390
- project.webhooks[0].body = {"message_text": "test-value", "url": "test-value", "username": "test-value"}
390
+ project.webhooks[0].body = {"message_text": "test-value", "username": "test-value"}
391
391
  let Project = new ProjectModel(project)
392
392
  Project.validate((err, res) => {
393
393
  assert.exists(err)
394
- assert.match(err.message, /mobivity webhooks require "username", "target_id", "url" and "message_text" body fields to be present/)
394
+ assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
395
395
  done()
396
396
  })
397
397
  })
@@ -399,23 +399,11 @@ describe('Project', () => {
399
399
  it(`should throw an error if structure is mobivity and message_text is not a body field`, (done) => {
400
400
  project.webhooks[0].type = "register"
401
401
  project.webhooks[0].structure = "mobivity"
402
- project.webhooks[0].body = {"target_id": "test-value", "url": "test-value", "username": "test-value"}
402
+ project.webhooks[0].body = {"target_id": "test-value", "username": "test-value"}
403
403
  let Project = new ProjectModel(project)
404
404
  Project.validate((err, res) => {
405
405
  assert.exists(err)
406
- assert.match(err.message, /mobivity webhooks require "username", "target_id", "url" and "message_text" body fields to be present/)
407
- done()
408
- })
409
- })
410
-
411
- it(`should throw an error if structure is mobivity and url is not a body field`, (done) => {
412
- project.webhooks[0].type = "register"
413
- project.webhooks[0].structure = "mobivity"
414
- project.webhooks[0].body = {"target_id": "test-value", "message_text": "test-value", "username": "test-value"}
415
- let Project = new ProjectModel(project)
416
- Project.validate((err, res) => {
417
- assert.exists(err)
418
- assert.match(err.message, /mobivity webhooks require "username", "target_id", "url" and "message_text" body fields to be present/)
406
+ assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
419
407
  done()
420
408
  })
421
409
  })
@@ -423,11 +411,11 @@ describe('Project', () => {
423
411
  it(`should throw an error if structure is mobivity and username is not a body field`, (done) => {
424
412
  project.webhooks[0].type = "register"
425
413
  project.webhooks[0].structure = "mobivity"
426
- project.webhooks[0].body = {"target_id": "test-value", "message_text": "url", "url": "test-value"}
414
+ project.webhooks[0].body = {"target_id": "test-value", "message_text": "est-value"}
427
415
  let Project = new ProjectModel(project)
428
416
  Project.validate((err, res) => {
429
417
  assert.exists(err)
430
- assert.match(err.message, /mobivity webhooks require "username", "target_id", "url" and "message_text" body fields to be present/)
418
+ assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
431
419
  done()
432
420
  })
433
421
  })
@@ -439,7 +427,7 @@ describe('Project', () => {
439
427
  let Project = new ProjectModel(project)
440
428
  Project.validate((err, res) => {
441
429
  assert.exists(err)
442
- assert.match(err.message, /mobivity webhooks require "username", "target_id", "url" and "message_text" body fields to be present/)
430
+ assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
443
431
  done()
444
432
  })
445
433
  })
@@ -451,7 +439,7 @@ describe('Project', () => {
451
439
  let Project = new ProjectModel(project)
452
440
  Project.validate((err, res) => {
453
441
  assert.exists(err)
454
- assert.match(err.message, /mobivity webhooks require "username", "target_id", "url" and "message_text" body fields to be present/)
442
+ assert.match(err.message, /mobivity webhooks require "username", "target_id" and "message_text" body fields to be present/)
455
443
  done()
456
444
  })
457
445
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "7.5.4",
3
+ "version": "7.5.5",
4
4
  "main": "Models.js",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",
@@ -21,7 +21,7 @@ function validateMobivityRequiredFields(structure){
21
21
  return false;
22
22
  }
23
23
  const bodyKeys = Object.keys(webhookBodyFields)
24
- if(!bodyKeys.includes("username") || !bodyKeys.includes("target_id") || !bodyKeys.includes("message_text") || !bodyKeys.includes("url")){
24
+ if(!bodyKeys.includes("username") || !bodyKeys.includes("target_id") || !bodyKeys.includes("message_text")){
25
25
  return false;
26
26
  }
27
27
  }
@@ -45,7 +45,7 @@ let WebhookSchema = new mongoose.Schema({
45
45
  default: 'standard',
46
46
  validate: [
47
47
  {validator: validateTealiumRequiredFields, msg: 'tealium webhooks require "tealium_account" and "tealium_profile" body fields to be present'},
48
- {validator: validateMobivityRequiredFields, msg: 'mobivity webhooks require "username", "target_id", "url" and "message_text" body fields to be present'}
48
+ {validator: validateMobivityRequiredFields, msg: 'mobivity webhooks require "username", "target_id" and "message_text" body fields to be present'}
49
49
  ]
50
50
  }
51
51
  }, {