Exemplo n.º 1
0
 /**
  * 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();
 }
Exemplo n.º 2
0
 /**
  * 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();
 }
Exemplo n.º 3
0
 /**
  * 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();
 }
Exemplo n.º 4
0
 /**
  * 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();
 }
Exemplo n.º 5
0
 /**
  * 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();
 }
Exemplo n.º 6
0
 /**
  * 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();
 }
Exemplo n.º 7
0
 /**
  * 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;
 }
Exemplo n.º 8
0
 /**
  * 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();
 }
Exemplo n.º 9
0
 public static function make(RuleRequest $request, $baseUrl = "")
 {
     return new Request($request->getMethod(), $baseUrl . $request->getRelativeUrl());
 }