-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add sms provider seven #120
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @matthiez, thanks for your PR!
It looks good to me, just a comment about boolean parameters.
const params = { | ||
flash: messageClass === 0, | ||
from, | ||
text, | ||
to, | ||
ttl, | ||
unicode: type === 'unicode' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems they use 0
or 1
in place of booleans in the documentation:
const params = { | |
flash: messageClass === 0, | |
from, | |
text, | |
to, | |
ttl, | |
unicode: type === 'unicode' | |
} | |
const params = { | |
flash: messageClass === 0 ? 1 : 0, | |
from, | |
text, | |
to, | |
ttl, | |
unicode: type === 'unicode' ? 1 : 0 | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both works :)
lib/providers/sms/index.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this file from the PR, it'll be generated during deployment.
headers: expect.objectContaining({ | ||
Accept: ['application/json'], | ||
'Content-Length': ['102'], | ||
'Content-Type': ['application/json'], | ||
SentWith: ['Notifme'], | ||
'User-Agent': ['notifme-sdk/v1 (+https://github.com/notifme/notifme-sdk)'], | ||
'X-Api-Key': ['apiKey'] | ||
}) | ||
})) | ||
expect(mockHttp.body).toEqual( | ||
'{"flash":false,"from":"Notifme","text":"Hello John! How are you?","to":"+15000000001","unicode":false}' | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headers: expect.objectContaining({ | |
Accept: ['application/json'], | |
'Content-Length': ['102'], | |
'Content-Type': ['application/json'], | |
SentWith: ['Notifme'], | |
'User-Agent': ['notifme-sdk/v1 (+https://github.com/notifme/notifme-sdk)'], | |
'X-Api-Key': ['apiKey'] | |
}) | |
})) | |
expect(mockHttp.body).toEqual( | |
'{"flash":false,"from":"Notifme","text":"Hello John! How are you?","to":"+15000000001","unicode":false}' | |
) | |
headers: expect.objectContaining({ | |
Accept: ['application/json'], | |
'Content-Length': ['94'], | |
'Content-Type': ['application/json'], | |
SentWith: ['Notifme'], | |
'User-Agent': ['notifme-sdk/v1 (+https://github.com/notifme/notifme-sdk)'], | |
'X-Api-Key': ['apiKey'] | |
}) | |
})) | |
expect(mockHttp.body).toEqual( | |
'{"flash":0,"from":"Notifme","text":"Hello John! How are you?","to":"+15000000001","unicode":0}' | |
) |
await sdk.send({ | ||
sms: { | ||
...request.sms, | ||
customize: async (provider, request) => ({ ...request, text: 'Hello John! How are you?' }) | ||
} | ||
}) | ||
expect(mockHttp).lastCalledWith(expect.objectContaining({ | ||
headers: expect.objectContaining({ 'Content-Length': ['103'] }) | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await sdk.send({ | |
sms: { | |
...request.sms, | |
customize: async (provider, request) => ({ ...request, text: 'Hello John! How are you?' }) | |
} | |
}) | |
expect(mockHttp).lastCalledWith(expect.objectContaining({ | |
headers: expect.objectContaining({ 'Content-Length': ['103'] }) | |
})) | |
await sdk.send({ | |
sms: { | |
...request.sms, | |
customize: async (provider, request) => ({ | |
...request, | |
text: 'a totally new message', | |
messageClass: 0, | |
type: 'unicode' | |
}) | |
} | |
}) | |
expect(mockHttp.body).toEqual( | |
'{"flash":1,"from":"Notifme","text":"a totally new message","to":"+15000000001","unicode":1}' | |
) |
Merged in #151 |
Hi,
I added a new a new SMS provider seven.
Hope this helps!