UNPKG

6.45 kBMarkdownView Raw
1# Cicero Server
2
3Exposes the Cicero Engine as a RESTful service.
4
5Templates are loaded from a the root CICERO_DIR.
6Clauses may be instantiated by passing the JSON or MD (i.e. TXT) via the payload Body as, either, `request`, `data`, `state`, `options` or `sample` objects.
7
8See below CURL examples for details.
9
10## Documentation
11
12http://docs.accordproject.org
13
14## Installation
15
16```
17npm install -g @accordproject/cicero-server --save
18```
19
20## Run
21
22Assuming you cloned the [Cicero template library](https://github.com/accordproject/cicero-template-library) in directory `<cicero-template-library-dir>`, you can start the server using:
23```
24export CICERO_DIR=<cicero-template-library-dir>/src
25cicero-server
26```
27
28The default port for the server is `6001`. You can set a different port as an environment variable `CICERO_PORT`.
29
30Once the server is started, you can sent requests as follows:
31
32### Parse request
33
34```
35curl --request POST \
36 --url http://localhost:6001/parse/latedeliveryandpenalty \
37 --header 'accept: application/json' \
38 --header 'content-type: application/json' \
39 --data '{
40 "sample": "## Late Delivery and Penalty.\n\n In case of delayed delivery except for Force Majeure cases,\n\"Dan\" (the Seller) shall pay to \"Steve\" (the Buyer) for every 2 days\nof delay penalty amounting to 10.5% of the total value of the Equipment\nwhose delivery has been delayed. Any fractional part of a days is to be\nconsidered a full days. The total amount of penalty shall not however,\nexceed 55% of the total value of the Equipment involved in late delivery.\nIf the delay is more than 15 days, the Buyer is entitled to terminate this Contract." }
41'
42```
43
44### Draft request
45
46```
47curl --request POST \
48 --url http://localhost:6001/draft/latedeliveryandpenalty \
49 --header 'accept: application/json' \
50 --header 'content-type: application/json' \
51 --data '{
52 "data": {
53 "$class": "org.accordproject.latedeliveryandpenalty.LateDeliveryAndPenaltyContract",
54 "contractId": "ecd6257e-2ffe-4ef1-8a5c-38ca9084a829",
55 "buyer": {
56 "$class": "org.accordproject.cicero.contract.AccordParty",
57 "partyId": "Dan"
58 },
59 "seller": {
60 "$class": "org.accordproject.cicero.contract.AccordParty",
61 "partyId": "Steve"
62 },
63 "forceMajeure": true,
64 "penaltyDuration": {
65 "$class": "org.accordproject.time.Duration",
66 "amount": 9,
67 "unit": "days"
68 },
69 "penaltyPercentage": 1000.5,
70 "capPercentage": 88,
71 "termination": {
72 "$class": "org.accordproject.time.Duration",
73 "amount": 5,
74 "unit": "weeks"
75 },
76 "fractionalPart": "days"
77 },
78 "options": {
79 "unquoteVariables": true
80 }
81}'
82```
83
84### Trigger request
85
86```
87curl --request POST \
88 --url http://localhost:6001/trigger/latedeliveryandpenalty \
89 --header 'accept: application/json' \
90 --header 'content-type: application/json' \
91 --data '{
92 "request": {
93 "$class": "org.accordproject.latedeliveryandpenalty.LateDeliveryAndPenaltyRequest",
94 "forceMajeure": false,
95 "agreedDelivery": "December 17, 2017 03:24:00",
96 "deliveredAt": null,
97 "goodsValue": 200.00
98 },
99 "state": {
100 "$class": "org.accordproject.cicero.contract.AccordContractState",
101 "stateId": "org.accordproject.cicero.contract.AccordContractState#1"
102 },
103 "data": {
104 "$class": "org.accordproject.latedeliveryandpenalty.LateDeliveryAndPenaltyContract",
105 "contractId": "ecd6257e-2ffe-4ef1-8a5c-38ca9084a829",
106 "buyer": {
107 "$class": "org.accordproject.cicero.contract.AccordParty",
108 "partyId": "Dan"
109 },
110 "seller": {
111 "$class": "org.accordproject.cicero.contract.AccordParty",
112 "partyId": "Steve"
113 },
114 "forceMajeure": true,
115 "penaltyDuration": {
116 "$class": "org.accordproject.time.Duration",
117 "amount": 9,
118 "unit": "days"
119 },
120 "penaltyPercentage": 1000.5,
121 "capPercentage": 99,
122 "termination": {
123 "$class": "org.accordproject.time.Duration",
124 "amount": 2,
125 "unit": "weeks"
126 },
127 "fractionalPart": "days"
128 }
129}'
130```
131
132### Trigger request - Stateless (legacy)
133
134Only supported for clauses or contracts without references to contract state
135
136If the body contains an object with the properties 'state', then this is used as the contract state. If no 'state' property exists then no contract state is used.
137
138Assuming you cloned the [Cicero template library](https://github.com/accordproject/cicero-template-library) in directory `<cicero-template-library-dir>`:
139
140```
141curl --request POST \
142 --url http://localhost:6001/trigger/latedeliveryandpenalty \
143 --header 'accept: application/json' \
144 --header 'content-type: application/json' \
145 --data '{
146 "request": {
147 "$class": "org.accordproject.latedeliveryandpenalty.LateDeliveryAndPenaltyRequest",
148 "forceMajeure": false,
149 "agreedDelivery": "December 17, 2017 03:24:00",
150 "deliveredAt": null,
151 "goodsValue": 200.00
152 },
153 "data": {
154 "$class": "org.accordproject.latedeliveryandpenalty.LateDeliveryAndPenaltyContract",
155 "contractId": "ecd6257e-2ffe-4ef1-8a5c-38ca9084a829",
156 "buyer": {
157 "$class": "org.accordproject.cicero.contract.AccordParty",
158 "partyId": "Dan"
159 },
160 "seller": {
161 "$class": "org.accordproject.cicero.contract.AccordParty",
162 "partyId": "Steve"
163 },
164 "forceMajeure": true,
165 "penaltyDuration": {
166 "$class": "org.accordproject.time.Duration",
167 "amount": 9,
168 "unit": "days"
169 },
170 "penaltyPercentage": 1000.5,
171 "capPercentage": 99,
172 "termination": {
173 "$class": "org.accordproject.time.Duration",
174 "amount": 2,
175 "unit": "weeks"
176 },
177 "fractionalPart": "days"
178 }
179}'
180```
181
182## License <a name="license"></a>
183Accord Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Accord Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/.
184
185© 2017-2019 Clause, Inc.