Last active
October 19, 2019 16:45
-
-
Save tamizhvendan/4544f0123bd30681be1c5198ed87522c to your computer and use it in GitHub Desktop.
Wheel - Gists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "mockoon_export", | |
"appVersion": "1.5.1", | |
"checksum": "240b68b32100126de3c02778b454a36c", | |
"subject": "environment", | |
"data": { | |
"uuid": "97fc5020-f100-11e9-a76d-9788f5e7b954", | |
"name": "Wheel Fake Marketplace", | |
"endpointPrefix": "", | |
"latency": 0, | |
"port": 3000, | |
"routes": [ | |
{ | |
"uuid": "97fc5021-f100-11e9-a76d-9788f5e7b954", | |
"documentation": "", | |
"method": "post", | |
"endpoint": "channels/:channelId/ranging", | |
"responses": [ | |
{ | |
"uuid": "97fc5022-f100-11e9-a76d-9788f5e7b954", | |
"body": "{}", | |
"latency": 0, | |
"statusCode": "200", | |
"headers": [ | |
{ | |
"key": "", | |
"value": "" | |
} | |
], | |
"filePath": "", | |
"sendFileAsBody": false, | |
"rules": [ | |
{ | |
"target": "params", | |
"modifier": "channelId", | |
"value": "UA", | |
"isRegex": false | |
} | |
] | |
}, | |
{ | |
"uuid": "97fc5023-f100-11e9-a76d-9788f5e7b954", | |
"body": "{}", | |
"latency": 0, | |
"statusCode": "500", | |
"headers": [ | |
{ | |
"key": "", | |
"value": "" | |
} | |
], | |
"filePath": "", | |
"sendFileAsBody": false, | |
"rules": [ | |
{ | |
"target": "params", | |
"modifier": "channelId", | |
"value": "UB", | |
"isRegex": false | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"uuid": "6bc3b170-f285-11e9-b60f-174e50ef3d64", | |
"documentation": "", | |
"method": "get", | |
"endpoint": "channels/:channelId/new-orders", | |
"responses": [ | |
{ | |
"uuid": "6bc3b171-f285-11e9-b60f-174e50ef3d64", | |
"body": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Orders>\n <Order>\n <OrderNo>181219-001-345786</OrderNo>\n <AddressInfo>\n <Shipping>\n <FirstName>Tamizhvendan</FirstName>\n <LastName>Sembiyan</LastName>\n <Address1>Plot No 222</Address1>\n <Address2>Ashok Nagar 42nd Street</Address2>\n <City>Chennai</City>\n <State>TamilNadu</State>\n <Pincode>600001</Pincode>\n </Shipping>\n <Billing>\n <FirstName>Tamizhvendan</FirstName>\n <LastName>Sembiyan</LastName>\n <Address1>Plot No 222</Address1>\n <Address2>Ashok Nagar 42nd Street</Address2>\n <City>Chennai</City>\n <State>TamilNadu</State>\n <Pincode>600001</Pincode>\n </Billing>\n </AddressInfo>\n <PaymentInfo>\n <PaymentCost>900.0</PaymentCost>\n <PaymentId>000000-1545216772601</PaymentId>\n </PaymentInfo>\n <OrderLines>\n <OrderLine>\n <TransactionId>200058001702351</TransactionId>\n <ArticleNumber>200374</ArticleNumber>\n <Price>900.0</Price>\n </OrderLine>\n </OrderLines>\n </Order>\n</Orders>", | |
"latency": 0, | |
"statusCode": "200", | |
"headers": [ | |
{ | |
"key": "Content-Type", | |
"value": "application/xml" | |
} | |
], | |
"filePath": "", | |
"sendFileAsBody": false, | |
"rules": [ | |
{ | |
"target": "params", | |
"modifier": "channelId", | |
"value": "UA", | |
"isRegex": false | |
} | |
] | |
} | |
] | |
} | |
], | |
"proxyMode": false, | |
"proxyHost": "", | |
"https": false, | |
"cors": true, | |
"headers": [ | |
{ | |
"key": "Content-Type", | |
"value": "application/json" | |
} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | |
<xs:element name="EXTNChannelList"> | |
<xs:complexType> | |
<xs:sequence> | |
<xs:element maxOccurs="unbounded" name="EXTNChannelItemList" minOccurs="1"> | |
<xs:complexType> | |
<xs:sequence> | |
<xs:element maxOccurs="unbounded" name="EXTNChannelItem" minOccurs="0"> | |
<xs:complexType> | |
<xs:attribute name="ChannelID" use="required"> | |
<xs:simpleType> | |
<xs:restriction base="xs:string"> | |
<xs:minLength value="1"/> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:attribute> | |
<xs:attribute name="EAN" use="required"> | |
<xs:simpleType> | |
<xs:restriction base="xs:string"> | |
<xs:minLength value="1"/> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:attribute> | |
<xs:attribute name="ItemID" use="required"> | |
<xs:simpleType> | |
<xs:restriction base="xs:string"> | |
<xs:minLength value="1"/> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:attribute> | |
<xs:attribute name="RangeFlag" use="required"> | |
<xs:simpleType> | |
<xs:restriction base="xs:string"> | |
<xs:enumeration value="Y"/> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:attribute> | |
</xs:complexType> | |
</xs:element> | |
</xs:sequence> | |
<xs:attribute name="IgnoreOrdering" use="optional" type="xs:string" /> | |
</xs:complexType> | |
</xs:element> | |
</xs:sequence> | |
</xs:complexType> | |
</xs:element> | |
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns wheel.xml | |
(:require [cuerdas.core :as str] | |
[clojure.xml :as xml]) | |
(:import [java.io StringBufferInputStream])) | |
(defn- xml-element-merger [x y] | |
(if (vector? x) | |
(conj x y) | |
(vector x y))) | |
(defn- merge-if [map source-map] | |
(if (empty? map) | |
source-map | |
(merge map source-map))) | |
(defn hyphenate-keys [m] | |
(reduce | |
(fn [state x] | |
(let [value (get m x)] | |
(assoc (dissoc state x) | |
(str/keyword x) | |
(cond | |
(map? value) (hyphenate-keys value) | |
(sequential? value) (map #(hyphenate-keys %) value) | |
:else value)))) | |
m (keys m))) | |
(defn xml-element->map [{:keys [tag attrs content]}] | |
(let [attrs (hyphenate-keys attrs)] | |
(if (= 1 (count content)) | |
(if (map? (first content)) | |
(hash-map (str/keyword tag) (->> (first content) | |
xml-element->map | |
(merge attrs))) | |
(if (empty? attrs) | |
(hash-map (str/keyword tag) (first content)) | |
(hash-map (str/keyword tag) attrs))) | |
(hash-map (str/keyword tag) (->> (map xml-element->map content) | |
(apply (partial merge-with xml-element-merger)) | |
(merge-if attrs)))))) | |
(defn xml-str->map [raw-xml-str] | |
(-> (StringBufferInputStream. raw-xml-str) | |
xml/parse | |
xml-element->map)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment