/** * Get group fields * * @param integer $id Id of the group * @return array Request result * @throws \Exception */ public function get($id) { $request = new Request('customizations'); $request->setIdParam(urlencode($id)); $response = $this->client->get($request); $this->assertSuccessResponse($response); return $response->getData(); }
/** * Get template by id * * @link https://rule.se/apidoc/#templates-get-template-get * * @param $id * @return array * @throws \Exception */ public function get($id) { $this->assertValidTemplateId($id); $request = new Request('templates'); $request->setIdParam($id); $response = $this->client->get($request); $this->assertSuccessResponse($response); return $response->getData(); }
/** * Clear associations between subscriber and tag * * @link https://rule.se/apidoc/#tags-clear-tag-delete * * @param $id * @return array * @throws \Exception */ public function clear($id) { $request = new Request('tags'); $request->setIdParam(urlencode($id)); $request->addSubresource(['name' => 'clear']); $response = $this->client->delete($request); $this->assertSuccessResponse($response); return $response->getData(); }
/** * Creates new Suppression * * @link https://rule.se/apidoc/#suppressions-suppressions-post * * @param array $suppression * @return array * @throws \Exception */ public function create(array $suppressions) { foreach ($suppressions as $suppression) { $this->assertValidSuppression($suppression); } $request = new Request('suppressions'); $request->setParams(['subscribers' => $suppressions]); $response = $this->client->post($request); $this->assertSuccessResponse($response); return $response->getData(); }
/** * Send transaction * * @link https://rule.se/apidoc/#transactions-send-transaction-post * * @param array $transaction * @return array * @throws \Exception */ public function send(array $transaction) { $this->assertValidTransaction($transaction); if ($transaction['transaction_type'] == 'email') { $transaction['content']['plain'] = base64_encode($transaction['content']['plain']); $transaction['content']['html'] = base64_encode($transaction['content']['html']); } $request = new Request('transactionals'); $request->setParams($transaction); $response = $this->client->post($request); $this->assertSuccessResponse($response); return $response->getData(); }
/** * Schedule campaign. * * @link https://rule.se/apidoc/#campaigns-schedule-campaign-post * * @param array $campaign Campaign data formated according {@link https://rule.se/apidoc/#campaigns-send-campaign-post} * @return array * @throws \Exception, InvalidArgumentException */ public function schedule(array $campaign) { $this->assertValidCampaign($campaign); $this->assertScheduledCampaign($campaign); $request = new Request('campaigns'); $request->addSubresource(['name' => 'schedule']); $request->setParams($campaign); $response = $this->client->post($request); $this->assertSuccessResponse($response); return $response->getData(); }
/** * Returns request options * * @param Request $request * @return array */ private function getRequestOptions(Request $request) { $options = ['http_errors' => false, 'synchronous' => true]; if ($request->getQuery()) { $options['query'] = array_merge($this->guzzleClient->getConfig('query'), $request->getQuery()); } if ($request->getParams()) { $options['json'] = $request->getParams(); } return $options; }
/** * Removes subscriber tags * * @link https://rule.se/apidoc/#subscribers-delete-subscriber-tag-delete * * @param $id * @param $tag * @param string $identifyBy * @return array * @throws \Exception */ public function deleteTag($id, $tag, $identifyBy = "email") { $request = new Request('subscribers'); $request->setQuery(['identified_by' => $identifyBy]); $request->setIdParam($id); $request->addSubresource(['name' => 'tags', 'id' => urlencode($tag)]); $response = $this->client->delete($request); $this->assertSuccessResponse($response); return $response->getData(); }
public static function make(RuleRequest $request, $baseUrl = "") { return new Request($request->getMethod(), $baseUrl . $request->getRelativeUrl()); }