1 <?php
2 3 4 5 6 7
8
9 namespace frankmayer\ArangoDbPhpCore\Api\Rest;
10
11 use frankmayer\ArangoDbPhpCore\Api\RestApiInterface;
12 use frankmayer\ArangoDbPhpCore\Protocols\Http\AbstractHttpRequest;
13
14
15 16 17 18 19
20 class Async extends
21 Api implements
22 RestApiInterface
23 {
24 25 26
27 const API_PATH = '/_api/job';
28
29 30 31 32 33 34
35 public function fetchJobResult(
36 $handle,
37 $options = []
38 ) {
39
40 $request = $this->getRequest();
41 $request->options = $options;
42 $request->path = $this->client->fullDatabasePath . static::API_PATH . '/' . $handle;
43 $request->method = static::METHOD_PUT;
44
45 return $this->getReturnObject($request);
46 }
47
48
49 50 51 52 53 54 55
56 public function listJobResults(
57 $type,
58 $count = null,
59 $options = []
60 ) {
61 $urlQuery = null;
62
63
64 $request = $this->getRequest();
65 $request->options = $options;
66 $request->path = $this->client->fullDatabasePath . static::API_PATH . '/' . $type;
67
68 if ($count) {
69 $urlQuery = ['count' => $count];
70 $urlQuery = $request->buildUrlQuery($urlQuery);
71 }
72
73 $request->path .= $urlQuery;
74
75 $request->method = static::METHOD_GET;
76
77 return $this->getReturnObject($request);
78 }
79
80
81 82 83 84 85 86 87
88 public function deleteJobResult(
89 $type,
90 $stamp = null,
91 $options = []
92 ) {
93 $urlQuery = null;
94
95
96 $request = $this->getRequest();
97 $request->options = $options;
98 $request->path = $this->client->fullDatabasePath . static::API_PATH . '/' . $type;
99
100 if ($stamp) {
101 $urlQuery = ['stamp' => $stamp];
102 $urlQuery = $request->buildUrlQuery($urlQuery);
103 }
104 $request->path .= $urlQuery;
105
106 $request->method = static::METHOD_DELETE;
107
108 return $this->getReturnObject($request);
109 }
110 }
111