/** * @param mixed $body * * @return Message */ public function send($body = null) { if (!is_null($body)) { $this->json($body); } $response = $this->client->send('POST', '/messages', ['tenant' => $this->tenant, 'type' => $this->type, 'payload' => $this->payloads]); return new Message($response['id'], $response['tenant'], $response['type'], $response['formats'], $response['recipients']); }
/** * Get the result of an API request to show a discussion. * * @param User $actor * @param array $params * @return object * @throws RouteNotFoundException */ protected function getDocument(User $actor, array $params) { $response = $this->api->send('Flarum\\Api\\Controller\\ShowDiscussionController', $actor, $params); $statusCode = $response->getStatusCode(); if ($statusCode === 404) { throw new RouteNotFoundException(); } return json_decode($response->getBody()); }
public function save() { $body = ['format' => $this->format, 'tenant' => $this->tenant, 'url' => $this->url, 'secret' => $this->secret, 'events' => $this->events]; if ($this->basicAuth) { $body['auth'] = $this->basicAuth; } if ($this->legacy) { $body['legacy'] = $this->legacy; } $response = $this->client->send('POST', '/subscribers/' . $this->subscriberId . '/subscriptions', $body); $subscription = new Subscription($response['id'], $response['subscriber_id'], $response['tenant'], $response['format'], $response['url']); $subscription->setUsesBasicAuth($response['uses_basic_auth']); if ($response['legacy']) { $subscription->setLegacyPayload($response['legacy']['payload']); } return $subscription; }
/** * {@inheritdoc} */ public function send($message, array $options) { $payload = new ChatPostMessagePayload(); $payload->setChannel($this->channel); $payload->setText($message); $payload->setUsername($this->user); try { $response = $this->client->send($payload); if ($response->isOk()) { return true; } else { $this->logger->error($response->getErrorExplanation()); return false; } } catch (\CL\Slack\Exception\SlackException $e) { $this->logger->error($e); return false; } }
public function save() { $body = ['tenant' => $this->tenant, 'events' => $this->events]; return $this->client->send('POST', '/subscribers/' . $this->subscriberId . '/subscriptions/unsubscribe', $body); }