Skip to content

Commit

Permalink
Merge pull request #965 from OpenFn/eow-ghana-update
Browse files Browse the repository at this point in the history
Eow ghana update
  • Loading branch information
taylordowns2000 authored Jan 31, 2025
2 parents d37990b + 6dfaa9a commit 369fb2c
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 26 deletions.
6 changes: 6 additions & 0 deletions packages/ghana-bdr/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/language-ghana-bdr

## 0.1.3

### Patch Changes

- 7c677a5: Update mock and examples for bdr, add auth to test

## 0.1.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ghana-bdr/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"tags": [
{
"title": "example",
"description": "sendBirthNotification({\n child: {},\n mother: {},\n father: {},\n health_facility: {},\n birth_informant: {}\n})"
"description": "sendBirthNotification({\n registry_code: 'abc123',\n child: {},\n mother: {},\n father: {},\n})"
},
{
"title": "function",
Expand Down
2 changes: 1 addition & 1 deletion packages/ghana-bdr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-ghana-bdr",
"version": "0.1.2",
"version": "0.1.3",
"description": "OpenFn ghana-bdr adaptor",
"type": "module",
"exports": {
Expand Down
3 changes: 1 addition & 2 deletions packages/ghana-bdr/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ export function post(path, data) {
* Generate a birth certificate
* @example
* sendBirthNotification({
* registry_code: 'abc123',
* child: {},
* mother: {},
* father: {},
* health_facility: {},
* birth_informant: {}
* })
* @function
* @public
Expand Down
4 changes: 2 additions & 2 deletions packages/ghana-bdr/src/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export function createServer(url = 'http://tracker.chimgh.org') {
const mockPool = agent.get(url);

const sendBirthNotification = req => {
// if (validate(JSON.parse(req.body))) {
if (validateRequestBody(JSON.parse(req.body), sampleRequestBody)) {
const body = JSON.parse(req.body);
if (validateRequestBody(body, sampleRequestBody)) {
return {
statusCode: 200,
responseOptions: {
Expand Down
8 changes: 6 additions & 2 deletions packages/ghana-bdr/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const setMockClient = mockClient => {
client = mockClient;
};


// mock validator
export const validateRequestBody = (request, sample) => {
// Check top-level keys
Expand Down Expand Up @@ -77,6 +76,7 @@ export const prepareNextState = async (state, response) => {
export const request = (path, options) => {
return async state => {
const { baseUrl, username, password } = state.configuration;

getClient(baseUrl);
const basePath = baseUrl ? new URL(baseUrl).pathname : '/';

Expand Down Expand Up @@ -111,7 +111,8 @@ export const request = (path, options) => {

if (data.username || data.password) {
throwError(
"Please don't supply `username` and `password` in your request body."
"Please don't supply `username` and `password` in your request body. " +
'The adaptor will append it automatically.'
);
}

Expand All @@ -127,6 +128,9 @@ export const request = (path, options) => {
password,
})
);

// TODO: Why do we need to _ALSO_ append authentication to "data" for mock?
args.data = { ...data, username, password };
}

const response = await client.request(args);
Expand Down
5 changes: 4 additions & 1 deletion packages/ghana-bdr/test/Adaptor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { sendBirthNotification, execute } from '../src/Adaptor.js';
describe('sendBirthNotification', () => {
it('upload birth notification', async () => {
const state = {
configuration: {},
configuration: {
username: 'test',
password: 'fake',
},
data: {
registry_code: '',
child: {
Expand Down
6 changes: 6 additions & 0 deletions packages/ghana-nia/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/language-ghana-nia

## 0.1.3

### Patch Changes

- 7c677a5: Update mock and nia, add auth to test

## 0.1.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ghana-nia/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"tags": [
{
"title": "example",
"description": "registerChild({\n babyData: {\n dateOfBirth: \"string\",\n fatherName: \"string\",\n forenames: \"string\",\n gender: \"string\",\n lightwaveETrackerID: \"string\",\n motherName: \"string\",\n noSiblingsInDelivery: \"string\",\n placeOfBirth: \"string\",\n surname: \"string\",\n timeOfbirth: \"string\",\n weightAtBirth: \"string\",\n babyPicture: \"string\"\n },\n personVouching: {\n etrackerLightwaveID: \"string\",\n ghanaCardPIN: \"string\",\n relationToBaby: \"string\",\n relativePhone: \"string\",\n relativePicture: \"string\"\n },\n merchantKey: \"XXXXXXXXXXXXXXXXXXXXXX\"\n})"
"description": "registerChild({\n babyData: {\n dateOfBirth: \"string\",\n fatherName: \"string\",\n forenames: \"string\",\n gender: \"string\",\n lightwaveETrackerID: \"string\",\n motherName: \"string\",\n noSiblingsInDelivery: \"string\",\n placeOfBirth: \"string\",\n surname: \"string\",\n timeOfbirth: \"string\",\n weightAtBirth: \"string\",\n babyPicture: \"string\"\n },\n personVouching: {\n etrackerLightwaveID: \"string\",\n ghanaCardPIN: \"string\",\n relationToBaby: \"string\",\n relativePhone: \"string\",\n relativePicture: \"string\"\n }\n})"
},
{
"title": "function",
Expand Down
2 changes: 1 addition & 1 deletion packages/ghana-nia/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-ghana-nia",
"version": "0.1.2",
"version": "0.1.3",
"description": "OpenFn ghana-nia adaptor",
"type": "module",
"exports": {
Expand Down
3 changes: 1 addition & 2 deletions packages/ghana-nia/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export function post(path, data) {
* relationToBaby: "string",
* relativePhone: "string",
* relativePicture: "string"
* },
* merchantKey: "XXXXXXXXXXXXXXXXXXXXXX"
* }
* })
* @function
* @public
Expand Down
6 changes: 3 additions & 3 deletions packages/ghana-nia/src/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { validateRequestBody } from './util';
// const validate = new Ajv().compile(reqSchema);

const sampleRequestBody = {
merchantKey: '89487284-9083-4015-9128-91d8db7e023e',
babyData: {
dateOfBirth: '2024-03-05',
fatherName: 'Nyarkoa Osei-Akoto',
Expand Down Expand Up @@ -55,8 +54,9 @@ export function createServer(url = 'https://selfie.imsgh.org:2035') {
const mockPool = agent.get(url);

const sendNiaData = req => {
// if (validate(JSON.parse(req.body))) {
if (validateRequestBody(JSON.parse(req.body), sampleRequestBody)) {
const body = JSON.parse(req.body);

if (validateRequestBody(body, sampleRequestBody)) {
return {
statusCode: 200,
responseOptions: {
Expand Down
15 changes: 13 additions & 2 deletions packages/ghana-nia/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const validateRequestBody = (request, sample) => {
return true;
};


export const setMockClient = mockClient => {
client = mockClient;
};
Expand Down Expand Up @@ -108,8 +107,20 @@ export const request = (path, options) => {
...otherOptions,
};

if (data.merchantKey) {
throwError(
"Please don't supply `merchantKey` in your request body. " +
'The adaptor will append it automatically.'
);
}

if (data) {
args.body = JSON.stringify(data);
// Please note that the BDR systems requires that we add username &
// password attributes to the POST body.
args.body = JSON.stringify({ ...data, merchantKey });

// TODO: Why do we need to _ALSO_ append authentication to "data" for mock?
args.data = { ...data, merchantKey };
}

const response = await client.request(args);
Expand Down
5 changes: 3 additions & 2 deletions packages/ghana-nia/test/Adaptor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { registerChild, execute } from '../src/Adaptor.js';
describe('registerChild', () => {
it('upload to NIA for Ghana Card Number', async () => {
const state = {
configuration: {},
configuration: {
merchantKey: '123',
},
data: {
merchantKey: '7834rtyfh8h834hf7834hf',
babyData: {
dateOfBirth: '2024-11-12',
fatherName: 'kwamena Ahoi Jn',
Expand Down
8 changes: 7 additions & 1 deletion packages/wigal-sms/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/language-wigal-sms

## 0.1.3

### Patch Changes

- 7c677a5: Update example for wigal sms

## 0.1.2

### Patch Changes
Expand All @@ -10,7 +16,7 @@

### Patch Changes

- Make sendSMS public
- Make sendSms public

## 0.1.0

Expand Down
4 changes: 2 additions & 2 deletions packages/wigal-sms/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@
"tags": [
{
"title": "example",
"description": "sendSMS({\n senderid: \"Stevkky\",\n destinations: [{ destination: \"0552825710\" }],\n message: \"This is a sample message for SMS sending via Wigal FROG API.\",\n smstype: \"text\",\n});",
"description": "sendSms({\n senderid: \"Stevkky\",\n destinations: [{ destination: \"0552825710\" }],\n message: \"This is a sample message for SMS sending via Wigal FROG API.\",\n smstype: \"text\",\n});",
"caption": "Send General SMS message"
},
{
"title": "example",
"description": "sendSMS({\n senderid: \"Stevkky\",\n destinations: [\n {\n destination: \"0542709440\",\n message: \"Hello Joe your order is ready\",\n msgid: \"MGS1010101\",\n smstype: \"text\",\n },\n ],\n});",
"description": "sendSms({\n senderid: \"Stevkky\",\n destinations: [\n {\n destination: \"0542709440\",\n message: \"Hello Joe your order is ready\",\n msgid: \"MGS1010101\",\n smstype: \"text\",\n },\n ],\n});",
"caption": "Send Personalized SMS message"
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/wigal-sms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-wigal-sms",
"version": "0.1.2",
"version": "0.1.3",
"description": "OpenFn wigal-sms adaptor",
"type": "module",
"exports": {
Expand Down
4 changes: 2 additions & 2 deletions packages/wigal-sms/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ export function execute(...operations) {
* Send SMS using Wigal SMS Gateway API
*
* @example <caption>Send General SMS message</caption>
* sendSMS({
* sendSms({
* senderid: "Stevkky",
* destinations: [{ destination: "0552825710" }],
* message: "This is a sample message for SMS sending via Wigal FROG API.",
* smstype: "text",
* });
* @example <caption>Send Personalized SMS message</caption>
* sendSMS({
* sendSms({
* senderid: "Stevkky",
* destinations: [
* {
Expand Down

0 comments on commit 369fb2c

Please sign in to comment.