From 795e06052edfd895b98a9d43b715f58d922c1aaa Mon Sep 17 00:00:00 2001 From: Ed Cass <150065800+edDocMe360@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:09:24 -0800 Subject: [PATCH] #1539 - Client Postman Collection (#1607) Co-authored-by: edSynapse --- .talismanrc | 10 +- documents/postman/README.md | 59 ++ .../internal_api_developers}/README.md | 0 .../development.postman_environment.json | 11 + .../notification-api.postman_collection.json | 0 .../performance.postman_environment.json | 11 + .../staging.postman_environment.json | 11 + ...ion-api-simplified.postman_collection.json | 686 ++++++++++++++++++ ...taging-simplified.postman_environment.json | 66 ++ 9 files changed, 852 insertions(+), 2 deletions(-) create mode 100644 documents/postman/README.md rename {scripts/postman => documents/postman/internal_api_developers}/README.md (100%) rename {scripts/postman => documents/postman/internal_api_developers}/development.postman_environment.json (93%) rename {scripts/postman => documents/postman/internal_api_developers}/notification-api.postman_collection.json (100%) rename {scripts/postman => documents/postman/internal_api_developers}/performance.postman_environment.json (92%) rename {scripts/postman => documents/postman/internal_api_developers}/staging.postman_environment.json (93%) create mode 100644 documents/postman/notification-api-simplified.postman_collection.json create mode 100644 documents/postman/staging-simplified.postman_environment.json diff --git a/.talismanrc b/.talismanrc index ab154417b7..42819dd2c9 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,3 +1,9 @@ fileignoreconfig: -- filename: app/celery/letters_pdf_tasks.py - checksum: 3430294d1d4e37f8886c3103557355d4c89c13bf1186a97709b1cfb86b78b5a3 +- filename: documents/postman/internal_api_developers/development.postman_environment.json + checksum: ca23e82ce6045c668de609cd48ee5bff986250c06198a262aebbd80e25c1ce65 +- filename: documents/postman/internal_api_developers/performance.postman_environment.json + checksum: a39e7244c02137f4c76df6fec596dbafeb3ba05796faa410e67ca6afff1f4099 +- filename: documents/postman/internal_api_developers/staging.postman_environment.json + checksum: a6b9dbff04ca357fed37bb800544195355555c5b5bc5f14e30965121403e5907 +- filename: documents/postman/staging-simplified.postman_environment.json + checksum: d69f7b3dfd46f9d8fe17c1ec8429fa1a90cd8acea452e2de2f0936f1c0013474 \ No newline at end of file diff --git a/documents/postman/README.md b/documents/postman/README.md new file mode 100644 index 0000000000..fbc6676aba --- /dev/null +++ b/documents/postman/README.md @@ -0,0 +1,59 @@ +# Postman + +To download Postman, go [here](https://www.postman.com/downloads/). Postman allows you to send requests. + +## Postman collection + +The intention of this collection is to provide quick, easy functionality to send email, sms, and push notifications. This collection can be used by business line users integrating with VA Notify to get familiar with the API and send test notifications. + +The postman scripts use the environment variables and populate or update them as the scripts are executed. These files can be imported into Postman and allow you to +execute the basic endpoints once the environmental variables below are populated. + +Creation, viewing and editing of templates can be done in the Self Service Portal. +## basic environment variables + +These environment variables should be defined before you can execute any of the scripts +- notification-api-url: `{environment}-api.va.gov/vanotify` - Publically available outside the VPN. +- notification-api-url-private: `https://{environment}.api.notifications.va.gov - Privately available inside the VPN. +- service-api-key : The VA Notify team creates an api key and sends it via encrypted email. +- service-id : Retrieve this from the portal. +- template-id : Retrieve this from the portal. +## basic notification calls + +See Postman collection for details of call to send email, sms, or mobile push. Using the collection, you can take the following actions: + +- You can send an email with an email address or a recipient-identifier, so VA Notify can look up the email address. +- You can send a text with a phone number or a recipient-identifier, so VA Notify can look up the email address. +- You can send a push notification to a Mobile App user. +- You can get information regarding the status of a notification. + +### Example +````` + +curl -x POST https:://api-staging.va.gov/vanotify/v2/notifications/email \ + -h + -d '{ + "template_id": "{{email-template-id}}", + "email_address": "john.smith@fake-domain.com" +} +````` + +#### Response +````` +{ + "billing_code": null, + "content": { + "body": "Test", + "subject": "Test" + }, + "id": "", + "reference": null, + "scheduled_for": null, + "template": { + "id": "", + "uri": "https://dev-api.va.gov/services//templates/", + "version": 1 + }, + "uri": "https://dev-api.va.gov/v2/notifications/" +} +````` \ No newline at end of file diff --git a/scripts/postman/README.md b/documents/postman/internal_api_developers/README.md similarity index 100% rename from scripts/postman/README.md rename to documents/postman/internal_api_developers/README.md diff --git a/scripts/postman/development.postman_environment.json b/documents/postman/internal_api_developers/development.postman_environment.json similarity index 93% rename from scripts/postman/development.postman_environment.json rename to documents/postman/internal_api_developers/development.postman_environment.json index 92cea903eb..9a5427605d 100644 --- a/scripts/postman/development.postman_environment.json +++ b/documents/postman/internal_api_developers/development.postman_environment.json @@ -37,6 +37,12 @@ "value": "", "enabled": true }, + { + "key": "icn", + "value": "", + "type": "any", + "enabled": true + }, { "key": "jwt_signed", "value": "", @@ -121,6 +127,11 @@ "key": "user-id", "value": "", "enabled": true + }, + { + "key": "vetext-template-id", + "value": "", + "enabled": true } ], "_postman_variable_scope": "environment", diff --git a/scripts/postman/notification-api.postman_collection.json b/documents/postman/internal_api_developers/notification-api.postman_collection.json similarity index 100% rename from scripts/postman/notification-api.postman_collection.json rename to documents/postman/internal_api_developers/notification-api.postman_collection.json diff --git a/scripts/postman/performance.postman_environment.json b/documents/postman/internal_api_developers/performance.postman_environment.json similarity index 92% rename from scripts/postman/performance.postman_environment.json rename to documents/postman/internal_api_developers/performance.postman_environment.json index 55c851a727..532960d5f1 100644 --- a/scripts/postman/performance.postman_environment.json +++ b/documents/postman/internal_api_developers/performance.postman_environment.json @@ -37,6 +37,12 @@ "value": "", "enabled": true }, + { + "key": "icn", + "value": "", + "type": "any", + "enabled": true + }, { "key": "jwt_signed", "value": "", @@ -121,6 +127,11 @@ "key": "user-id", "value": "", "enabled": true + }, + { + "key": "vetext-template-id", + "value": "", + "enabled": true } ], "_postman_variable_scope": "environment", diff --git a/scripts/postman/staging.postman_environment.json b/documents/postman/internal_api_developers/staging.postman_environment.json similarity index 93% rename from scripts/postman/staging.postman_environment.json rename to documents/postman/internal_api_developers/staging.postman_environment.json index 820ecdb0fe..cd9455f992 100644 --- a/scripts/postman/staging.postman_environment.json +++ b/documents/postman/internal_api_developers/staging.postman_environment.json @@ -37,6 +37,12 @@ "value": "", "enabled": true }, + { + "key": "icn", + "value": "", + "type": "any", + "enabled": true + }, { "key": "jwt_signed", "value": "", @@ -121,6 +127,11 @@ "key": "user-id", "value": "", "enabled": true + }, + { + "key": "vetext-template-id", + "value": "", + "enabled": true } ], "_postman_variable_scope": "environment", diff --git a/documents/postman/notification-api-simplified.postman_collection.json b/documents/postman/notification-api-simplified.postman_collection.json new file mode 100644 index 0000000000..efa7532a8b --- /dev/null +++ b/documents/postman/notification-api-simplified.postman_collection.json @@ -0,0 +1,686 @@ +{ + "info": { + "_postman_id": "b86aae08-ab5e-4e02-9f98-b54712346590", + "name": "notification-api-simplified", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "30982915" + }, + "item": [ + { + "name": "/v2/notifications", + "item": [ + { + "name": "send SMS", + "item": [ + { + "name": "send sms with phone_number", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// JWT generation script adapted from", + "// https://gist.github.com/corbanb/", + "", + "var jwtSecret = pm.environment.get(\"service-api-key\");", + "", + "// Set headers for JWT", + "var header = {", + "\t'typ': 'JWT',", + "\t'alg': 'HS256'", + "};", + "", + "// Prepare timestamp in seconds", + "var currentTimestamp = Math.floor(Date.now() / 1000)", + "", + "var data = {", + "\t'iss': pm.environment.get(\"service-id\"),", + "\t'iat': currentTimestamp", + "}", + "", + "", + "function base64url(source) {", + " // Encode in classical base64", + " encodedSource = CryptoJS.enc.Base64.stringify(source)", + " ", + " // Remove padding equal characters", + " encodedSource = encodedSource.replace(/=+$/, '')", + " ", + " // Replace characters according to base64url specifications", + " encodedSource = encodedSource.replace(/\\+/g, '-')", + " encodedSource = encodedSource.replace(/\\//g, '_')", + " ", + " return encodedSource", + "}", + "", + "// encode header", + "var stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header))", + "var encodedHeader = base64url(stringifiedHeader)", + "", + "// encode data", + "var stringifiedData = CryptoJS.enc.Utf8.parse(JSON.stringify(data))", + "var encodedData = base64url(stringifiedData)", + "", + "// build token", + "var token = `${encodedHeader}.${encodedData}`", + "", + "// sign token", + "var signature = CryptoJS.HmacSHA256(token, jwtSecret)", + "signature = base64url(signature)", + "var signedToken = `${token}.${signature}`", + "", + "pm.environment.set('jwt_signed', signedToken)" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "exec": [ + "if (pm.response.code == 201) {", + " var jsonData = pm.response.json(); ", + " pm.environment.set(\"notification-id\", jsonData.id);", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{jwt_signed}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"template_id\": \"{{sms-template-id}}\",\n \"phone_number\": \"+16502532222\",\n \"sms_sender_id\": \"{{sms-sender-id}}\"\n}" + }, + "url": { + "raw": "{{notification-api-url}}/v2/notifications/sms", + "host": [ + "{{notification-api-url}}" + ], + "path": [ + "v2", + "notifications", + "sms" + ] + }, + "description": "api-key field combines key name, service id and secret:\n--\nwhere secret is the return value when calling create api key\nThis is important as the jwt token for sending message should use service-id and service-api-key to generate the JWT bearer token" + }, + "response": [] + }, + { + "name": "send sms with recipient_identifier", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// JWT generation script adapted from", + "// https://gist.github.com/corbanb/", + "", + "var jwtSecret = pm.environment.get(\"service-api-key\");", + "", + "// Set headers for JWT", + "var header = {", + "\t'typ': 'JWT',", + "\t'alg': 'HS256'", + "};", + "", + "// Prepare timestamp in seconds", + "var currentTimestamp = Math.floor(Date.now() / 1000)", + "", + "var data = {", + "\t'iss': pm.environment.get(\"service-id\"),", + "\t'iat': currentTimestamp", + "}", + "", + "", + "function base64url(source) {", + " // Encode in classical base64", + " encodedSource = CryptoJS.enc.Base64.stringify(source)", + " ", + " // Remove padding equal characters", + " encodedSource = encodedSource.replace(/=+$/, '')", + " ", + " // Replace characters according to base64url specifications", + " encodedSource = encodedSource.replace(/\\+/g, '-')", + " encodedSource = encodedSource.replace(/\\//g, '_')", + " ", + " return encodedSource", + "}", + "", + "// encode header", + "var stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header))", + "var encodedHeader = base64url(stringifiedHeader)", + "", + "// encode data", + "var stringifiedData = CryptoJS.enc.Utf8.parse(JSON.stringify(data))", + "var encodedData = base64url(stringifiedData)", + "", + "// build token", + "var token = `${encodedHeader}.${encodedData}`", + "", + "// sign token", + "var signature = CryptoJS.HmacSHA256(token, jwtSecret)", + "signature = base64url(signature)", + "var signedToken = `${token}.${signature}`", + "", + "pm.environment.set('jwt_signed', signedToken)" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "exec": [ + "if (pm.response.code == 201) {", + " var jsonData = pm.response.json(); ", + " pm.environment.set(\"notification-id\", jsonData.id);", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + }, + { + "key": "Authorization", + "type": "text", + "value": "Bearer {{jwt_signed}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"template_id\": \"{{sms-template-id}}\",\n \"recipient_identifier\": {\n \"id_type\": \"VAPROFILEID\",\n \"id_value\": \"example\"\n },\n \"sms_sender_id\": \"{{sms-sender-id}}\"\n}" + }, + "url": { + "raw": "{{notification-api-url}}/v2/notifications/sms", + "host": [ + "{{notification-api-url}}" + ], + "path": [ + "v2", + "notifications", + "sms" + ] + }, + "description": "api-key field combines key name, service id and secret:\n--\nwhere secret is the return value when calling create api key\nThis is important as the jwt token for sending message should use service-id and service-api-key to generate the JWT bearer token" + }, + "response": [] + } + ] + }, + { + "name": "send EMAIL", + "item": [ + { + "name": "send email with email_address", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// JWT generation script adapted from", + "// https://gist.github.com/corbanb/", + "", + "var jwtSecret = pm.environment.get(\"service-api-key\");", + "", + "// Set headers for JWT", + "var header = {", + "\t'typ': 'JWT',", + "\t'alg': 'HS256'", + "};", + "", + "// Prepare timestamp in seconds", + "var currentTimestamp = Math.floor(Date.now() / 1000)", + "", + "var data = {", + "\t'iss': pm.environment.get(\"service-id\"),", + "\t'iat': currentTimestamp", + "}", + "", + "", + "function base64url(source) {", + " // Encode in classical base64", + " encodedSource = CryptoJS.enc.Base64.stringify(source)", + " ", + " // Remove padding equal characters", + " encodedSource = encodedSource.replace(/=+$/, '')", + " ", + " // Replace characters according to base64url specifications", + " encodedSource = encodedSource.replace(/\\+/g, '-')", + " encodedSource = encodedSource.replace(/\\//g, '_')", + " ", + " return encodedSource", + "}", + "", + "// encode header", + "var stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header))", + "var encodedHeader = base64url(stringifiedHeader)", + "", + "// encode data", + "var stringifiedData = CryptoJS.enc.Utf8.parse(JSON.stringify(data))", + "var encodedData = base64url(stringifiedData)", + "", + "// build token", + "var token = `${encodedHeader}.${encodedData}`", + "", + "// sign token", + "var signature = CryptoJS.HmacSHA256(token, jwtSecret)", + "signature = base64url(signature)", + "var signedToken = `${token}.${signature}`", + "", + "pm.environment.set('jwt_signed', signedToken)" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "exec": [ + "if (pm.response.code == 201) {", + " var jsonData = pm.response.json(); ", + " pm.environment.set(\"notification-id\", jsonData.id);", + "}", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{jwt_signed}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"template_id\": \"{{email-template-id}}\",\n \"email_address\": \"test@email.com\"\n}" + }, + "url": { + "raw": "{{notification-api-url}}/v2/notifications/email", + "host": [ + "{{notification-api-url}}" + ], + "path": [ + "v2", + "notifications", + "email" + ] + }, + "description": "api-key field combines key name, service id and secret:\n--\nwhere secret is the return value when calling create api key\nThis is important as the jwt token for sending message should use service-id and service-api-key to generate the JWT bearer token" + }, + "response": [] + }, + { + "name": "send email with recipient_identifier", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// JWT generation script adapted from", + "// https://gist.github.com/corbanb/", + "", + "var jwtSecret = pm.environment.get(\"service-api-key\");", + "", + "// Set headers for JWT", + "var header = {", + "\t'typ': 'JWT',", + "\t'alg': 'HS256'", + "};", + "", + "// Prepare timestamp in seconds", + "var currentTimestamp = Math.floor(Date.now() / 1000)", + "", + "var data = {", + "\t'iss': pm.environment.get(\"service-id\"),", + "\t'iat': currentTimestamp", + "}", + "", + "", + "function base64url(source) {", + " // Encode in classical base64", + " encodedSource = CryptoJS.enc.Base64.stringify(source)", + " ", + " // Remove padding equal characters", + " encodedSource = encodedSource.replace(/=+$/, '')", + " ", + " // Replace characters according to base64url specifications", + " encodedSource = encodedSource.replace(/\\+/g, '-')", + " encodedSource = encodedSource.replace(/\\//g, '_')", + " ", + " return encodedSource", + "}", + "", + "// encode header", + "var stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header))", + "var encodedHeader = base64url(stringifiedHeader)", + "", + "// encode data", + "var stringifiedData = CryptoJS.enc.Utf8.parse(JSON.stringify(data))", + "var encodedData = base64url(stringifiedData)", + "", + "// build token", + "var token = `${encodedHeader}.${encodedData}`", + "", + "// sign token", + "var signature = CryptoJS.HmacSHA256(token, jwtSecret)", + "signature = base64url(signature)", + "var signedToken = `${token}.${signature}`", + "", + "pm.environment.set('jwt_signed', signedToken)" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "exec": [ + "if (pm.response.code == 201) {", + " var jsonData = pm.response.json(); ", + " pm.environment.set(\"notification-id\", jsonData.id);", + "}", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{jwt_signed}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"template_id\": \"{{email-template-id}}\",\n \"recipient_identifier\": {\n \"id_type\": \"VAPROFILEID\",\n \"id_value\": \"example\"\n }\n}" + }, + "url": { + "raw": "{{notification-api-url}}/v2/notifications/email", + "host": [ + "{{notification-api-url}}" + ], + "path": [ + "v2", + "notifications", + "email" + ] + }, + "description": "api-key field combines key name, service id and secret:\n--\nwhere secret is the return value when calling create api key\nThis is important as the jwt token for sending message should use service-id and service-api-key to generate the JWT bearer token" + }, + "response": [] + } + ] + }, + { + "name": "Send Push", + "item": [ + { + "name": "send push notification", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// JWT generation script adapted from", + "// https://gist.github.com/corbanb/", + "", + "var jwtSecret = pm.environment.get(\"service-api-key\");", + "", + "// Set headers for JWT", + "var header = {", + "\t'typ': 'JWT',", + "\t'alg': 'HS256'", + "};", + "", + "// Prepare timestamp in seconds", + "var currentTimestamp = Math.floor(Date.now() / 1000)", + "", + "var data = {", + "\t'iss': pm.environment.get(\"service-id\"),", + "\t'iat': currentTimestamp", + "}", + "", + "", + "function base64url(source) {", + " // Encode in classical base64", + " encodedSource = CryptoJS.enc.Base64.stringify(source)", + " ", + " // Remove padding equal characters", + " encodedSource = encodedSource.replace(/=+$/, '')", + " ", + " // Replace characters according to base64url specifications", + " encodedSource = encodedSource.replace(/\\+/g, '-')", + " encodedSource = encodedSource.replace(/\\//g, '_')", + " ", + " return encodedSource", + "}", + "", + "// encode header", + "var stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header))", + "var encodedHeader = base64url(stringifiedHeader)", + "", + "// encode data", + "var stringifiedData = CryptoJS.enc.Utf8.parse(JSON.stringify(data))", + "var encodedData = base64url(stringifiedData)", + "", + "// build token", + "var token = `${encodedHeader}.${encodedData}`", + "", + "// sign token", + "var signature = CryptoJS.HmacSHA256(token, jwtSecret)", + "signature = base64url(signature)", + "var signedToken = `${token}.${signature}`", + "", + "pm.environment.set('jwt_signed', signedToken)" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "exec": [ + "if (pm.response.code == 201) {", + " var jsonData = pm.response.json(); ", + " pm.environment.set(\"notification-id\", jsonData.id);", + "}", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{jwt_signed}}" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"mobile_app\": \"VETEXT\",\n \"template_id\": \"{{vetext-template-id}}\",\n \"recipient_identifier\": {\n \"id_type\": \"ICN\",\n \"id_value\": \"{{icn}}\"\n },\n \"personalisation\": {\n \"appointment_date\": \"bar\",\n \"appointment_time\": \"foo\"\n }\n}" + }, + "url": { + "raw": "{{notification-api-url}}/v2/notifications/push", + "host": [ + "{{notification-api-url}}" + ], + "path": [ + "v2", + "notifications", + "push" + ] + }, + "description": "api-key field combines key name, service id and secret:\n--\nwhere secret is the return value when calling create api key\nThis is important as the jwt token for sending message should use service-id and service-api-key to generate the JWT bearer token" + }, + "response": [] + } + ] + }, + { + "name": "get notification", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "// JWT generation script adapted from", + "// https://gist.github.com/corbanb/", + "", + "var jwtSecret = pm.environment.get(\"service-api-key\");", + "", + "// Set headers for JWT", + "var header = {", + "\t'typ': 'JWT',", + "\t'alg': 'HS256'", + "};", + "", + "// Prepare timestamp in seconds", + "var currentTimestamp = Math.floor(Date.now() / 1000)", + "", + "var data = {", + "\t'iss': pm.environment.get(\"service-id\"),", + "\t'iat': currentTimestamp", + "}", + "", + "", + "function base64url(source) {", + " // Encode in classical base64", + " encodedSource = CryptoJS.enc.Base64.stringify(source)", + " ", + " // Remove padding equal characters", + " encodedSource = encodedSource.replace(/=+$/, '')", + " ", + " // Replace characters according to base64url specifications", + " encodedSource = encodedSource.replace(/\\+/g, '-')", + " encodedSource = encodedSource.replace(/\\//g, '_')", + " ", + " return encodedSource", + "}", + "", + "// encode header", + "var stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header))", + "var encodedHeader = base64url(stringifiedHeader)", + "", + "// encode data", + "var stringifiedData = CryptoJS.enc.Utf8.parse(JSON.stringify(data))", + "var encodedData = base64url(stringifiedData)", + "", + "// build token", + "var token = `${encodedHeader}.${encodedData}`", + "", + "// sign token", + "var signature = CryptoJS.HmacSHA256(token, jwtSecret)", + "signature = base64url(signature)", + "var signedToken = `${token}.${signature}`", + "", + "pm.environment.set('jwt_signed', signedToken)" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [ + { + "key": "Content-Type", + "type": "text", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{jwt_signed}}", + "type": "text" + } + ], + "url": { + "raw": "{{notification-api-url}}/v2/notifications/{{notification-id}}", + "host": [ + "{{notification-api-url}}" + ], + "path": [ + "v2", + "notifications", + "{{notification-id}}" + ] + }, + "description": "api-key field combines key name, service id and secret:\n--\nwhere secret is the return value when calling create api key\nThis is important as the jwt token for sending message should use service-id and service-api-key to generate the JWT bearer token" + }, + "response": [] + } + ] + } + ] +} \ No newline at end of file diff --git a/documents/postman/staging-simplified.postman_environment.json b/documents/postman/staging-simplified.postman_environment.json new file mode 100644 index 0000000000..132ee94998 --- /dev/null +++ b/documents/postman/staging-simplified.postman_environment.json @@ -0,0 +1,66 @@ +{ + "id": "1acffa98-51c5-4ba7-87fc-9f3d460c38ba", + "name": "staging-vanotify", + "values": [ + { + "key": "email-template-id", + "value": "", + "enabled": true + }, + { + "key": "icn", + "value": "", + "type": "any", + "enabled": true + }, + { + "key": "notification-api-url", + "value": "https://staging-api.va.gov/vanotify", + "enabled": true + }, + { + "key": "notification-api-url-private", + "value": "https://staging.api.notifications.va.gov/vanotify", + "enabled": true + }, + { + "key": "notification-id", + "value": "", + "enabled": true + }, + { + "key": "service-api-key", + "value": "", + "enabled": true + }, + { + "key": "service-id", + "value": "", + "enabled": true + }, + { + "key": "sms-sender-id", + "value": "", + "enabled": true + }, + { + "key": "sms-template-id", + "value": "", + "enabled": true + }, + { + "key": "jwt_signed", + "value": "", + "type": "any", + "enabled": true + }, + { + "key": "vetext-template-id", + "value": "", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2024-01-17T13:48:16.820Z", + "_postman_exported_using": "Postman/10.21.11" +} \ No newline at end of file