Skip to content

Commit

Permalink
Merge pull request #1 from moqui/master
Browse files Browse the repository at this point in the history
Upstream 2022-01-14
  • Loading branch information
aabiabdallah authored Jan 14, 2022
2 parents 7194d84 + 1ec0028 commit 233a932
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion service/moqui/aws/SnsServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ along with this software (see the LICENSE.md file). If not, see
<parameter name="countryCode" default-value="1">
<description>For AWS SNS a country code is always required, defaults to 1 for North America</description></parameter>
<parameter name="areaCode"/>
<parameter name="contactNumber" required="true"/>
<parameter name="contactNumber" required="true">
<description>If there is a single string for phone number pass it here, may include a country code if begins with '+'</description></parameter>
<parameter name="message" required="true"/>
<parameter name="isPromotional" default="false" type="Boolean"/>
</in-parameters>
Expand All @@ -32,6 +33,9 @@ along with this software (see the LICENSE.md file). If not, see
<if condition="countryCode &amp;&amp; !countryCode.trim().startsWith('+')">
<set field="countryCode" from="'+' + countryCode.trim()"/>
</if>
<!-- don't prepend countryCode if areaCode starts with '+' or !areaCode and contactNumber starts with '+' -->
<if condition="(areaCode &amp;&amp; areaCode.startsWith('+')) || (!areaCode &amp;&amp; contactNumber.startsWith('+'))">
<set field="countryCode" from="null"/></if>
<set field="phoneNumber" from="(countryCode?:'') + (areaCode?.trim()?:'') + (contactNumber?.trim()?:'')"/>
<set field="hasPlus" from="phoneNumber.startsWith('+')"/>
<set field="phoneNumber" from="(hasPlus ? '+' : '') + phoneNumber.replaceAll('\\D', '')"/>
Expand Down
35 changes: 35 additions & 0 deletions service/org/moqui/SmsServices.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This software is in the public domain under CC0 1.0 Universal plus a
Grant of Patent License.
To the extent possible under law, the author(s) have dedicated all
copyright and related and neighboring rights to this software to the
public domain worldwide. This software is distributed without any
warranty.
You should have received a copy of the CC0 Public Domain Dedication
along with this software (see the LICENSE.md file). If not, see
<http://creativecommons.org/publicdomain/zero/1.0/>.
-->
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/service-definition-2.1.xsd">
<!-- this overrides the org.moqui.SmsServices.send#SmsMessage service to add an implementation -->
<service verb="send" noun="SmsMessage" authenticate="anonymous-view">
<in-parameters>
<parameter name="countryCode" default-value="1"/>
<parameter name="areaCode"/>
<parameter name="contactNumber" required="true">
<description>If there is a single string for phone number pass it here, may include a country code if begins with '+'</description></parameter>
<parameter name="message" required="true"/>
<parameter name="isPromotional" default="false" type="Boolean"/>
</in-parameters>
<out-parameters>
<parameter name="successful" type="Boolean"/>
<parameter name="messageId"/>
<parameter name="errorMessage"/>
</out-parameters>
<actions>
<service-call name="moqui.aws.SnsServices.publish#SmsMessage" in-map="context" out-map="context"/>
</actions>
</service>
</services>

0 comments on commit 233a932

Please sign in to comment.