· 7 years ago · Oct 03, 2018, 09:00 PM
1General flow of data:
2
3Architect
4-> input contract
5-> requestTemplate and urlTemplate
6-> (REQUEST / RESPONSE)
7-> translationMap (JsonPath expressions)
8-> successTemplate
9-> output contract
10-> flatten
11-> Architect
12
13example input contract (json schema):
14{
15 "$schema": "http://json-schema.org/draft-04/schema#",
16 "type": "object",
17 "properties": {
18 "AccountNumber": {
19 "description": "The account number (string)",
20 "type": "string"
21 },
22 "AllowACH": {
23 "description": "Whether ACH is allowed (bool)",
24 "type": "boolean",
25 "default": false
26 },
27 "Auth_HostOrUser": {
28 "description": "Auth host or user (string)",
29 "type": "string"
30 },
31 "Auth_SecretKey": {
32 "description": "Auth secret key (string)",
33 "type": "string"
34 },
35 "Balance": {
36 "description": "The account balance (number).",
37 "type": "number"
38 },
39 "BillingAddress": {
40 "description": "The billing address (string)",
41 "type": "string"
42 },
43 "BillingZipCode": {
44 "description": "The billing zip code (string)",
45 "type": "string"
46 },
47 "CallerPhoneNumber": {
48 "description": "The caller phone number (string)",
49 "type": "string"
50 },
51 "PastDue": {
52 "description": "Amount past due (number)",
53 "type": "number"
54 },
55 "Response_ErrorMessage": {
56 "description": "The response error message (string)",
57 "type": "string"
58 },
59 "Response_Log": {
60 "description": "The response log (string)",
61 "type": "string"
62 },
63 "Response_ReturnCode": {
64 "description": "The response return code (integer)",
65 "type": "integer"
66 },
67 "UniqueCallId": {
68 "description": "The unique call ID (string)",
69 "type": "string"
70 }
71 }
72}
73
74output contract (json schema):
75{
76 "$schema": "http://json-schema.org/draft-04/schema#",
77 "type": "object",
78 "properties": {
79 "AccountNumber": {
80 "description": "The account number (string)",
81 "type": "string"
82 },
83 "AllowACH": {
84 "description": "Whether ACH is allowed (bool)",
85 "type": "boolean"
86 },
87 "Balance": {
88 "description": "The account balance (number).",
89 "type": "number"
90 },
91 "BillingAddress": {
92 "description": "The billing address (string)",
93 "type": "string"
94 },
95 "BillingZipCode": {
96 "description": "The billing zip code (string)",
97 "type": "string"
98 },
99 "CallerPhoneNumber": {
100 "description": "The caller phone number (string)",
101 "type": "string"
102 },
103 "PastDue": {
104 "description": "Amount past due (number)",
105 "type": "number"
106 },
107 "Response_Log": {
108 "description": "The response log (string)",
109 "type": "string"
110 },
111 "UniqueCallId": {
112 "description": "The unique call ID (string)",
113 "type": "string"
114 }
115 }
116}
117
118request configuration
119{
120 "requestUrlTemplate": "https://serviceapi.webcompany.com/api/AccountInfo",
121 "requestType": "POST",
122 "headers": {},
123 "requestTemplate": "{\n \"AccountNumber\": \"${input.AccountNumber}\",\n \"Balance\": ${input.Balance},\n \"PastDue\": ${input.PastDue},\n \"AllowACH\": ${input.AllowACH},\n \"BillingAddress\": \"${input.BillingAddress}\",\n \"BillingZipCode\": \"${input.BillingZipCode}\",\n \"UniqueCallId\": \"${input.UniqueCallId}\",\n \"CallerPhoneNumber\": \"${input.CallerPhoneNumber}\",\n \n \"Auth\": {\n \"HostOrUser\": \"${input.Auth_HostOrUser}\",\n \"SecretKey\": \"${input.Auth_SecretKey}\"\n },\n \n \"Response\": {\n \"ReturnCode\": ${input.Response_ReturnCode},\n \"ErrorMessage\": \"${input.Response_ErrorMessage}\",\n \"Log\": \"${input.Response_Log}\"\n }\n}"
124}
125
126
127(requestTemplate un-escaped for clarity - note Auth info is formatted into a nested object for the request):
128{
129 "AccountNumber": "${input.AccountNumber}",
130 "Balance": ${input.Balance},
131 "PastDue": ${input.PastDue},
132 "AllowACH": ${input.AllowACH},
133 "BillingAddress": "${input.BillingAddress}",
134 "BillingZipCode": "${input.BillingZipCode}",
135 "UniqueCallId": "${input.UniqueCallId}",
136 "CallerPhoneNumber": "${input.CallerPhoneNumber}",
137
138 "Auth": {
139 "HostOrUser": "${input.Auth_HostOrUser}",
140 "SecretKey": "${input.Auth_SecretKey}"
141 },
142
143 "Response": {
144 "ReturnCode": ${input.Response_ReturnCode},
145 "ErrorMessage": "${input.Response_ErrorMessage}",
146 "Log": "${input.Response_Log}"
147 }
148}
149
150response configuration - Note the JsonPath expression $.Response.Log to pull a nested response field into a named expression
151{
152 "translationMap": {
153 "PastDue": "$.PastDue",
154 "BillingAddress": "$.BillingAddress",
155 "AllowACH": "$.AllowACH",
156 "BillingZipCode": "$.BillingZipCode",
157 "UniqueCallId": "$.UniqueCallId",
158 "CallerPhoneNumber": "$.CallerPhoneNumber",
159 "Balance": "$.Balance",
160 "Response_Log": "$.Response.Log",
161 "AccountNumber": "$.AccountNumber"
162 },
163 "successTemplate": "{\n \"AccountNumber\": ${AccountNumber},\n \"Balance\": ${Balance},\n \"PastDue\": ${PastDue},\n \"AllowACH\": ${AllowACH},\n \"BillingAddress\": ${BillingAddress},\n \"BillingZipCode\": ${BillingZipCode},\n \"UniqueCallId\": ${UniqueCallId},\n \"CallerPhoneNumber\": ${CallerPhoneNumber},\n \"Response_Log\": ${Response_Log}\n}"
164}
165
166
167(successTemplate un-escaped for clarity):
168{
169 "AccountNumber": ${AccountNumber},
170 "Balance": ${Balance},
171 "PastDue": ${PastDue},
172 "AllowACH": ${AllowACH},
173 "BillingAddress": ${BillingAddress},
174 "BillingZipCode": ${BillingZipCode},
175 "UniqueCallId": ${UniqueCallId},
176 "CallerPhoneNumber": ${CallerPhoneNumber},
177 "Response_Log": ${Response_Log}
178}