/** * Create fields. * * @param array $fields Array of fields {@link https://rule.se/apidoc/#subscriber-fields-create-groups-and-fields-post} * @return array Response result * @throws \Exception */ public function create(array $fields) { $this->assertValidFields($fields); $request = new Request('customizations'); $request->setParams(['fields' => $fields]); $response = $this->client->post($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(); }
/** * Adds tags to subscriber * * @link https://rule.se/apidoc/#subscribers-tags-post * * @param $id * @param array $tags * @param string $identifyBy * @return array * @throws \Exception */ public function addTags($id, array $tags, $identifyBy = 'email') { $request = new Request('subscribers'); $request->setQuery(['identified_by' => $identifyBy]); $request->setIdParam($id); $request->addSubresource(['name' => 'tags']); $request->setParams(['tags' => $tags]); $response = $this->client->post($request); $this->assertSuccessResponse($response); return $response->getData(); }