Skip to content

Commit a30afa1

Browse files
committed
wier-up channel multi-method
1 parent 8560c1b commit a30afa1

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

clojure/wheel/src/wheel/marketplace/tata_cliq/core.clj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
(ns wheel.marketplace.tata-cliq.core
22
(:require [wheel.marketplace.tata-cliq.api :as tata-cliq]
3+
[wheel.marketplace.tata-cliq.order :as tata-cliq-order]
4+
[wheel.oms.client :as oms]
35
[wheel.marketplace.channel :as channel]
46
[wheel.middleware.ranging :as ranging]
57
[wheel.oms.message :as oms-message]
@@ -24,4 +26,9 @@
2426
(event/processing-failed ex id :ranging channel-id channel-name))))
2527

2628
(defmethod channel/allocate-order :tata-cliq [channel-id channel-config]
27-
(prn channel-id "~~>" channel-config))
29+
(try
30+
(->> (tata-cliq/new-orders channel-config channel-id)
31+
(map tata-cliq-order/to-oms-order)
32+
(run! oms/allocate-order))
33+
(catch Throwable e
34+
(prn e))))

clojure/wheel/src/wheel/marketplace/tata_cliq/order.clj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
(let [{:keys [address-info order-no order-lines payment-info]} tata-cliq-order
4242
{:keys [shipping billing]} address-info
4343
{:keys [payment-cost payment-id]} payment-info]
44-
{:billing (to-oms-address billing)
45-
:shipping (to-oms-address shipping)
46-
:order-no order-no
47-
:payments [{:amount payment-cost
48-
:reference-id payment-id}]
49-
:order-lines (map (fn [{:keys [article-number price]}]
50-
{:id article-number
51-
:sale-price price})
52-
order-lines)}))
44+
{:billing-address (to-oms-address billing)
45+
:shipping-address (to-oms-address shipping)
46+
:order-no order-no
47+
:payments [{:amount payment-cost
48+
:reference-id payment-id}]
49+
:order-lines (map (fn [{:keys [article-number price]}]
50+
{:id article-number
51+
:sale-price price})
52+
order-lines)}))
5353

5454
(comment
5555
(s/check-asserts true)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(ns wheel.oms.client
2+
(:require [wheel.oms.order :as oms-order]
3+
[clojure.spec.alpha :as s]))
4+
5+
(defn allocate-order [order]
6+
{:pre [(s/assert ::oms-order/order order)]}
7+
(prn (oms-order/to-xml order)))

0 commit comments

Comments
 (0)