|
@@ -1,5 +1,6 @@
|
1
|
1
|
package fr.sayasoft.fake.zinc;
|
2
|
2
|
|
|
3
|
+import org.springframework.http.HttpStatus;
|
3
|
4
|
import org.springframework.http.ResponseEntity;
|
4
|
5
|
import org.springframework.web.bind.annotation.PathVariable;
|
5
|
6
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -14,6 +15,36 @@ import java.util.concurrent.atomic.AtomicLong;
|
14
|
15
|
public class FakeZincController {
|
15
|
16
|
|
16
|
17
|
private static final String template = "Hello, %s!";
|
|
18
|
+ public static final String GET_ORDER_RESPONSE = "{\n" +
|
|
19
|
+ " \"_type\" : \"order_response\",\n" +
|
|
20
|
+ " \"price_components\" : {\n" +
|
|
21
|
+ " \"shipping\" : 0,\n" +
|
|
22
|
+ " \"subtotal\" : 1999,\n" +
|
|
23
|
+ " \"tax\" : 0,\n" +
|
|
24
|
+ " \"total\" : 1999\n" +
|
|
25
|
+ " },\n" +
|
|
26
|
+ " \"merchant_order_ids\" : [\n" +
|
|
27
|
+ " {\n" +
|
|
28
|
+ " \"merchant_order_id\" : \"112-1234567-7272727\",\n" +
|
|
29
|
+ " \"merchant\" : \"amazon\",\n" +
|
|
30
|
+ " \"account\" : \"timbeaver@gmail.com\",\n" +
|
|
31
|
+ " \"placed_at\" : ISODate(\"2014-07-02T23:51:08.366Z\")\n" +
|
|
32
|
+ " }\n" +
|
|
33
|
+ " ],\n" +
|
|
34
|
+ " \"tracking\" : [\n" +
|
|
35
|
+ " {\n" +
|
|
36
|
+ " \"merchant_order_id\" : \"112-1234567-7272727\",\n" +
|
|
37
|
+ " \"carrier\" : \"Fedex\",\n" +
|
|
38
|
+ " \"tracking_number\" : \"9261290100129790891234\",\n" +
|
|
39
|
+ " \"obtained_at\" : ISODate(\"2014-07-03T23:22:48.165Z\")\n" +
|
|
40
|
+ " }\n" +
|
|
41
|
+ " ]\n" +
|
|
42
|
+ "}";
|
|
43
|
+
|
|
44
|
+ public static final String POST_ORDER_RESPONSE = "{\n" +
|
|
45
|
+ " \"request_id\": \"3f1c939065cf58e7b9f0aea70640dffc\"\n" +
|
|
46
|
+ "}";
|
|
47
|
+
|
17
|
48
|
private final AtomicLong counter = new AtomicLong();
|
18
|
49
|
|
19
|
50
|
@RequestMapping("/greeting")
|
|
@@ -22,13 +53,21 @@ public class FakeZincController {
|
22
|
53
|
String.format(template, name));
|
23
|
54
|
}
|
24
|
55
|
|
25
|
|
- @RequestMapping(value = "/order/{request_id}", method = RequestMethod.GET,)
|
|
56
|
+ @RequestMapping(
|
|
57
|
+ value = "/order/{request_id}",
|
|
58
|
+ method = RequestMethod.GET,
|
|
59
|
+ produces = "application/json; charset=UTF-8"
|
|
60
|
+ )
|
26
|
61
|
public String getOrder(@PathVariable(value = "request_id") String requestId) {
|
27
|
|
- return null;
|
|
62
|
+ return GET_ORDER_RESPONSE;
|
28
|
63
|
}
|
29
|
64
|
|
30
|
|
- @RequestMapping(value = "/order", method = RequestMethod.POST)
|
|
65
|
+ @RequestMapping(
|
|
66
|
+ value = "/order",
|
|
67
|
+ method = RequestMethod.POST,
|
|
68
|
+ produces = "application/json; charset=UTF-8"
|
|
69
|
+ )
|
31
|
70
|
public ResponseEntity<?> postOrder(@RequestBody Object requestBody) {
|
32
|
|
- return null;
|
|
71
|
+ return new ResponseEntity<>(POST_ORDER_RESPONSE, HttpStatus.CREATED);
|
33
|
72
|
}
|
34
|
73
|
}
|