@@ 22-112 (lines=91) @@ | ||
19 | * |
|
20 | * @author VEBER Arnaud <https://github.com/VEBERArnaud> |
|
21 | */ |
|
22 | class Api extends AbstractApi |
|
23 | { |
|
24 | /** |
|
25 | * add api |
|
26 | * |
|
27 | * @param array $params |
|
28 | * |
|
29 | * @return \Psr\Http\Message\ResponseInterface |
|
30 | */ |
|
31 | public function addApi(array $params) |
|
32 | { |
|
33 | $headers = [ |
|
34 | 'Content-Type' => 'application/json', |
|
35 | ]; |
|
36 | ||
37 | $body = json_encode($params); |
|
38 | ||
39 | return $this->post('/apis/', $headers, $body); |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * retrieve api |
|
44 | * |
|
45 | * @param string $nameOrId |
|
46 | * |
|
47 | * @return \Psr\Http\Message\ResponseInterface |
|
48 | */ |
|
49 | public function retrieveApi($nameOrId) |
|
50 | { |
|
51 | return $this->get(sprintf('/apis/%1$s', $nameOrId)); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * list apis |
|
56 | * |
|
57 | * @return \Psr\Http\Message\ResponseInterface |
|
58 | */ |
|
59 | public function listApis() |
|
60 | { |
|
61 | return $this->get('/apis/'); |
|
62 | } |
|
63 | ||
64 | /** |
|
65 | * update api |
|
66 | * |
|
67 | * @param string $nameOrId |
|
68 | * @param array $params |
|
69 | * |
|
70 | * @return \Psr\Http\Message\ResponseInterface |
|
71 | */ |
|
72 | public function updateApi($nameOrId, array $params) |
|
73 | { |
|
74 | $headers = [ |
|
75 | 'Content-Type' => 'application/json', |
|
76 | ]; |
|
77 | ||
78 | $body = json_encode($params); |
|
79 | ||
80 | return $this->patch(sprintf('/apis/%1$s', $nameOrId), $headers, $body); |
|
81 | } |
|
82 | ||
83 | /** |
|
84 | * update or create api |
|
85 | * |
|
86 | * @param array $params |
|
87 | * |
|
88 | * @return \Psr\Http\Message\ResponseInterface |
|
89 | */ |
|
90 | public function updateOrCreateApi(array $params) |
|
91 | { |
|
92 | $headers = [ |
|
93 | 'Content-Type' => 'application/json', |
|
94 | ]; |
|
95 | ||
96 | $body = json_encode($params); |
|
97 | ||
98 | return $this->put('/apis/', $headers, $body); |
|
99 | } |
|
100 | ||
101 | /** |
|
102 | * delete api |
|
103 | * |
|
104 | * @param string $nameOrId |
|
105 | * |
|
106 | * @return \Psr\Http\Message\ResponseInterface |
|
107 | */ |
|
108 | public function deleteApi($nameOrId) |
|
109 | { |
|
110 | return $this->delete(sprintf('/apis/%1$s', $nameOrId)); |
|
111 | } |
|
112 | } |
|
113 |
@@ 21-111 (lines=91) @@ | ||
18 | * |
|
19 | * @author VEBER Arnaud <https://github.com/VEBERArnaud> |
|
20 | */ |
|
21 | class Consumer extends AbstractApi |
|
22 | { |
|
23 | /** |
|
24 | * create consumer |
|
25 | * |
|
26 | * @param array $params |
|
27 | * |
|
28 | * @return \Psr\Http\Message\ResponseInterface |
|
29 | */ |
|
30 | public function createConsumer(array $params) |
|
31 | { |
|
32 | $headers = [ |
|
33 | 'Content-Type' => 'application/json', |
|
34 | ]; |
|
35 | ||
36 | $body = json_encode($params); |
|
37 | ||
38 | $this->post('/consumers/', $headers, $body); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * retrieve consumer |
|
43 | * |
|
44 | * @param string $usernameOrId |
|
45 | * |
|
46 | * @return \Psr\Http\Message\ResponseInterface |
|
47 | */ |
|
48 | public function retrieveConsumer($usernameOrId) |
|
49 | { |
|
50 | return $this->get(sprintf('/consumers/%1$s', $usernameOrId)); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * list consumers |
|
55 | * |
|
56 | * @return \Psr\Http\Message\ResponseInterface |
|
57 | */ |
|
58 | public function listConsumers() |
|
59 | { |
|
60 | return $this->get('/consumers/'); |
|
61 | } |
|
62 | ||
63 | /** |
|
64 | * update consumer |
|
65 | * |
|
66 | * @param string $usernameOrId |
|
67 | * @param array $params |
|
68 | * |
|
69 | * @return \Psr\Http\Message\ResponseInterface |
|
70 | */ |
|
71 | public function updateConsumer($usernameOrId, array $params) |
|
72 | { |
|
73 | $headers = [ |
|
74 | 'Content-Type' => 'application/json', |
|
75 | ]; |
|
76 | ||
77 | $body = json_encode($params); |
|
78 | ||
79 | return $this->patch(sprintf('/consumers/%1$s', $usernameOrId), $headers, $body); |
|
80 | } |
|
81 | ||
82 | /** |
|
83 | * update or create consumer |
|
84 | * |
|
85 | * @param array $params |
|
86 | * |
|
87 | * @return \Psr\Http\Message\ResponseInterface |
|
88 | */ |
|
89 | public function updateOrCreateConsumer(array $params) |
|
90 | { |
|
91 | $headers = [ |
|
92 | 'Content-Type' => 'application/json', |
|
93 | ]; |
|
94 | ||
95 | $body = json_encode($params); |
|
96 | ||
97 | return $this->put('/consumers/', $headers, $body); |
|
98 | } |
|
99 | ||
100 | /** |
|
101 | * delete consumer |
|
102 | * |
|
103 | * @param string $usernameOrId |
|
104 | * |
|
105 | * @return \Psr\Http\Message\ResponseInterface |
|
106 | */ |
|
107 | public function deleteConsumer($usernameOrId) |
|
108 | { |
|
109 | return $this->delete(sprintf('/consumers/%1$s', $usernameOrId)); |
|
110 | } |
|
111 | } |
|
112 |