/**
  * @param string $eventName
  * @param string $callbackUrl
  * @param string $fallbackEmail
  * @return int
  */
 public function post($eventName, $callbackUrl, $fallbackEmail)
 {
     $data = new SubscriptionAddTransfer();
     $data->event_name = $eventName;
     $data->callback_url = $callbackUrl;
     $data->fallback_email = $fallbackEmail;
     $endpoint = new Post($this->getTransport());
     $endpoint->setTransfer($data);
     $resultRequest = $endpoint->performRequest();
     return Response::extractId($resultRequest, '/subscriptions/%d/');
 }
Example #2
0
 public function testInstance()
 {
     /** @var \Mockery\Mock|\Hitmeister\Component\Api\Transfers\SubscriptionAddTransfer $transfer */
     $transfer = \Mockery::mock('\\Hitmeister\\Component\\Api\\Transfers\\SubscriptionAddTransfer');
     $transfer->shouldReceive('toArray')->once()->andReturn(['callback_url' => 'http://localhost']);
     $post = new Post($this->transport);
     $post->setTransfer($transfer);
     $this->assertInstanceOf('\\Hitmeister\\Component\\Api\\Transfers\\SubscriptionAddTransfer', $post->getTransfer());
     $this->assertEquals([], $post->getParamWhiteList());
     $this->assertEquals('POST', $post->getMethod());
     $this->assertEquals('subscriptions/', $post->getURI());
     $body = $post->getBody();
     $this->assertArrayHasKey('callback_url', $body);
 }