| @@ 196-214 (lines=19) @@ | ||
| 193 | * @return array |
|
| 194 | * @throws ApiException |
|
| 195 | */ |
|
| 196 | public function postDonation($accessToken, $name, $email, $amount, $currency, $message) |
|
| 197 | { |
|
| 198 | try { |
|
| 199 | $response = $this->httpClient->post(self::DONATION_ENDPOINT, [ |
|
| 200 | 'form_params' => [ |
|
| 201 | 'access_token' => $accessToken, |
|
| 202 | 'name' => $name, |
|
| 203 | 'identifier' => $email, |
|
| 204 | 'amount' => $amount, |
|
| 205 | 'currency' => $currency, |
|
| 206 | 'message' => $message |
|
| 207 | ] |
|
| 208 | ]); |
|
| 209 | ||
| 210 | return json_decode((string) $response->getBody(), true); |
|
| 211 | } catch (BadResponseException $e) { |
|
| 212 | throw ApiException::fromBadResponseException($e); |
|
| 213 | } |
|
| 214 | } |
|
| 215 | ||
| 216 | /** |
|
| 217 | * @param string $accessToken |
|
| @@ 228-247 (lines=20) @@ | ||
| 225 | * @return array |
|
| 226 | * @throws ApiException |
|
| 227 | */ |
|
| 228 | public function postAlert($accessToken, $type, $message, $imageUrl, $soundUrl, $textColor, $duration) |
|
| 229 | { |
|
| 230 | try { |
|
| 231 | $response = $this->httpClient->post(self::ALERT_ENDPOINT, [ |
|
| 232 | 'form_params' => [ |
|
| 233 | 'access_token' => $accessToken, |
|
| 234 | 'type' => $type, |
|
| 235 | 'message' => $message, |
|
| 236 | 'image_href' => $imageUrl, |
|
| 237 | 'sound_href' => $soundUrl, |
|
| 238 | 'special_text_color' => $textColor, |
|
| 239 | 'duration' => $duration |
|
| 240 | ] |
|
| 241 | ]); |
|
| 242 | ||
| 243 | return json_decode((string) $response->getBody(), true); |
|
| 244 | } catch (BadResponseException $e) { |
|
| 245 | throw ApiException::fromBadResponseException($e); |
|
| 246 | } |
|
| 247 | } |
|
| 248 | } |
|
| 249 | ||