Skip to content

Commit

Permalink
Removed common service from order routing, all these services has bee…
Browse files Browse the repository at this point in the history
…n moved to maarg-util component
  • Loading branch information
dixitdeepak committed May 7, 2024
1 parent b1c6743 commit 1da337a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 77 deletions.
1 change: 1 addition & 0 deletions component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ under the License.
<component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/moqui-conf-3.xsd"
name="order-routing" version="1.0.0">
<!-- no dependencies -->
<depends-on name="maarg-util"/>
</component>
75 changes: 0 additions & 75 deletions service/co/hotwax/common/CommonServices.xml
Original file line number Diff line number Diff line change
@@ -1,81 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://moqui.org/xsd/service-definition-3.xsd">


<service verb="login" noun="User">
<in-parameters>
<parameter name="username" required="true"/>
<parameter name="password" required="true"/>
</in-parameters>
<out-parameters>
<parameter name="token"/>
</out-parameters>
<actions>
<set field="code" value="200" type="Integer"/>
<script>
try {
loggedIn = ec.user.loginUser(username, password)
//TODO: Avoid using api_key pattern , please refer following thread
//https://groups.google.com/forum/?utm_medium=email&amp;utm_source=footer#!msg/moqui/gQzEtMweM2E/ObEGLik_AAAJ
if (loggedIn) {
token = ec.user.getLoginKey()
return;
} else if (ec.message.hasError()) {
ec.logger.error("User login error : " + ec.message.getErrorsString())
ec.message.clearErrors()
}
} catch (Exception e) {
ec.logger.error("Error while generating token ", e)
}
</script>
<return error="true" message="Sorry, your username and/or password are incorrect - please try again." />
</actions>
</service>
<service verb="get" noun="UserProfile">
<out-parameters>
<parameter name="userId"/>
<parameter name="username"/>
<parameter name="userFullName"/>
<parameter name="timeZone"/>
<parameter name="locale"/>
<parameter name="emailAddress"/>
<parameter name="preferences" type="Map">
<auto-parameters entity-name="moqui.security.UserPreference"/>
</parameter>
</out-parameters>
<actions>
<set field="userId" from="ec.user.UserAccount.userId"/>
<set field="username" from="ec.user.UserAccount.username"/>
<set field="userFullName" from="ec.user.UserAccount.userFullName"/>
<set field="timeZone" from="ec.user.getTimeZone()"/>
<set field="locale" from="ec.user.getLocale()"/>
<set field="emailAddress" from="ec.user.UserAccount.emailAddress"/>
<set field="preferences" from="ec.user.UserAccount.preferences"/>
</actions>
</service>
<service verb="get" noun="AvailableTimeZones">
<out-parameters>
<parameter name="timeZones" type="List">
<parameter name="timeZone" type="Map">
<parameter name="id"/>
<parameter name="label"/>
<parameter name="offset"/>
</parameter>
</parameter>
</out-parameters>
<actions>
<script>
timeZones = TimeZone.getAvailableIDs().collect { id ->
TimeZone tz = TimeZone.getTimeZone(id)
[
id: tz.ID,
label: tz.getDisplayName(tz.useDaylightTime(), TimeZone.LONG, ec.user.getLocale()),
offset: tz.rawOffset
]
}.toSorted { a, b -> a.id &lt;=&gt; b.id }
</script>
</actions>
</service>
<service verb="check" noun="OmsConnection">
<actions>
<entity-find-one entity-name="moqui.service.message.SystemMessageRemote" value-field="omsSystemMessageRemote">
Expand Down
4 changes: 2 additions & 2 deletions service/orderrouting.rest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
It involves determining the most efficient and cost-effective way to fulfill customer orders based on various factors such as inventory levels, location of the products, shipping costs, and delivery times.">

<resource name="login" require-authentication="anonymous-all">
<method type="post"><service name="co.hotwax.common.CommonServices.login#User"/></method>
<method type="post"><service name="co.hotwax.common.UserServices.login#User"/></method>
</resource>
<resource name="user">
<resource name="profile">
<method type="get"><service name="co.hotwax.common.CommonServices.getUserProfile"/></method>
<method type="get"><service name="co.hotwax.common.UserServices.getUserProfile"/></method>
</resource>
<resource name="getAvailableTimeZones">
<method type="get"><service name="co.hotwax.common.CommonServices.getAvailableTimeZones"/></method>
Expand Down

0 comments on commit 1da337a

Please sign in to comment.