@@ 16-90 (lines=75) @@ | ||
13 | * Class CustomFieldsRequest |
|
14 | * @package Mailxpert\Request |
|
15 | */ |
|
16 | class CustomFieldsRequest |
|
17 | { |
|
18 | /** |
|
19 | * @param Mailxpert $mailxpert |
|
20 | * @param array $params |
|
21 | * |
|
22 | * @return \Mailxpert\MailxpertResponse |
|
23 | * @throws MailxpertSDKResponseException |
|
24 | */ |
|
25 | public static function get(Mailxpert $mailxpert, array $params = []) |
|
26 | { |
|
27 | $response = $mailxpert->sendRequest('GET', 'custom_fields', $params); |
|
28 | ||
29 | if (!$response->isHttpResponseCodeOK()) { |
|
30 | throw new MailxpertSDKResponseException($response, 'An error occured during the Custom field fetching.'); |
|
31 | } |
|
32 | ||
33 | return $response; |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * @param Mailxpert $mailxpert |
|
38 | * @param array $params |
|
39 | * |
|
40 | * @return \Mailxpert\MailxpertResponse |
|
41 | * @throws MailxpertSDKResponseException |
|
42 | */ |
|
43 | public static function post(Mailxpert $mailxpert, array $params) |
|
44 | { |
|
45 | $response = $mailxpert->sendRequest('POST', 'custom_fields', [], null, json_encode($params)); |
|
46 | ||
47 | if (!$response->getHeader('Location')) { |
|
48 | throw new MailxpertSDKResponseException($response, 'An error occured during the Custom field creation.'); |
|
49 | } |
|
50 | ||
51 | return $response; |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * @param Mailxpert $mailxpert |
|
56 | * @param string $id |
|
57 | * @param array $params |
|
58 | * |
|
59 | * @return \Mailxpert\MailxpertResponse |
|
60 | * @throws MailxpertSDKResponseException |
|
61 | */ |
|
62 | public static function patch(Mailxpert $mailxpert, $id, array $params) |
|
63 | { |
|
64 | $response = $mailxpert->sendRequest('PATCH', sprintf('custom_fields/%s', $id), [], null, json_encode($params)); |
|
65 | ||
66 | if (!$response->isHttpResponseCodeOK()) { |
|
67 | throw new MailxpertSDKResponseException($response, 'An error occured during updating the CustomField.'); |
|
68 | } |
|
69 | ||
70 | return $response; |
|
71 | } |
|
72 | ||
73 | /** |
|
74 | * @param Mailxpert $mailxpert |
|
75 | * @param string $id |
|
76 | * |
|
77 | * @return \Mailxpert\MailxpertResponse |
|
78 | * @throws MailxpertSDKResponseException |
|
79 | */ |
|
80 | public static function delete(Mailxpert $mailxpert, $id) |
|
81 | { |
|
82 | $response = $mailxpert->sendRequest('DELETE', sprintf('custom_fields/%s', $id)); |
|
83 | ||
84 | if (!$response->isHttpResponseCodeOK()) { |
|
85 | throw new MailxpertSDKResponseException($response, 'An error occured during the CustomField deletion.'); |
|
86 | } |
|
87 | ||
88 | return $response; |
|
89 | } |
|
90 | } |
|
91 |
@@ 12-86 (lines=75) @@ | ||
9 | * Class SegmentsRequest |
|
10 | * @package Mailxpert\Request |
|
11 | */ |
|
12 | class SegmentsRequest |
|
13 | { |
|
14 | /** |
|
15 | * @param Mailxpert $mailxpert |
|
16 | * @param array $params |
|
17 | * |
|
18 | * @return \Mailxpert\MailxpertResponse |
|
19 | * @throws MailxpertSDKResponseException |
|
20 | */ |
|
21 | public static function get(Mailxpert $mailxpert, array $params = []) |
|
22 | { |
|
23 | $response = $mailxpert->sendRequest('GET', 'segments', $params); |
|
24 | ||
25 | if (!$response->isHttpResponseCodeOK()) { |
|
26 | throw new MailxpertSDKResponseException($response, 'An error occured during receiving Segments.'); |
|
27 | } |
|
28 | ||
29 | return $response; |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * @param Mailxpert $mailxpert |
|
34 | * @param array $params |
|
35 | * |
|
36 | * @return \Mailxpert\MailxpertResponse |
|
37 | * @throws MailxpertSDKResponseException |
|
38 | */ |
|
39 | public static function post(Mailxpert $mailxpert, array $params) |
|
40 | { |
|
41 | $response = $mailxpert->sendRequest('POST', 'segments', [], null, json_encode($params)); |
|
42 | ||
43 | if (!$response->isHttpResponseCodeOK()) { |
|
44 | throw new MailxpertSDKResponseException($response, 'An error occured during the Segments creation.'); |
|
45 | } |
|
46 | ||
47 | return $response; |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * @param Mailxpert $mailxpert |
|
52 | * @param string $id |
|
53 | * @param array $params |
|
54 | * |
|
55 | * @return \Mailxpert\MailxpertResponse |
|
56 | * @throws MailxpertSDKResponseException |
|
57 | */ |
|
58 | public static function patch(Mailxpert $mailxpert, $id, array $params) |
|
59 | { |
|
60 | $response = $mailxpert->sendRequest('PATCH', sprintf('segments/%s', $id), [], null, json_encode($params)); |
|
61 | ||
62 | if (!$response->isHttpResponseCodeOK()) { |
|
63 | throw new MailxpertSDKResponseException($response, 'An error occured during updating the Segments.'); |
|
64 | } |
|
65 | ||
66 | return $response; |
|
67 | } |
|
68 | ||
69 | /** |
|
70 | * @param Mailxpert $mailxpert |
|
71 | * @param string $id |
|
72 | * |
|
73 | * @return \Mailxpert\MailxpertResponse |
|
74 | * @throws MailxpertSDKResponseException |
|
75 | */ |
|
76 | public static function delete(Mailxpert $mailxpert, $id) |
|
77 | { |
|
78 | $response = $mailxpert->sendRequest('DELETE', sprintf('segments/%s', $id)); |
|
79 | ||
80 | if (!$response->isHttpResponseCodeOK()) { |
|
81 | throw new MailxpertSDKResponseException($response, 'An error occured during the Segments deletion.'); |
|
82 | } |
|
83 | ||
84 | return $response; |
|
85 | } |
|
86 | } |
|
87 |