Skip to content

Commit

Permalink
Delete interactions (#4)
Browse files Browse the repository at this point in the history
* Delete interactions

* Update client.php

* Update client.php
  • Loading branch information
joostbaptist authored and jarnovanleeuwen committed Jan 3, 2019
1 parent fbd619f commit 3ba6cb2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
29 changes: 29 additions & 0 deletions examples/DeleteInteraction/client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
namespace Examples\DeleteInteraction;

require_once "../../vendor/autoload.php";

use OneCommunity\Client;
use OneCommunity\Exceptions\RequestException;
use OneCommunity\Requests\DeleteInteractionRequest;

$apiKey = "DRSt3jWF4YqRZSi6Z8xzSAtBpVTauJ6b";
$userId = 1;
$projectName = "yourproject";

$client = new Client($apiKey, $userId, $projectName);
$client->loadPrivateKey("../private_rsa.pem");

$interactionId = 1;

try {
$request = new DeleteInteractionRequest($interactionId);

$response = $client->send($request);

dump($response->getData());
} catch (RequestException $exception) {
http_response_code(400);

dump($exception->getMessage());
}
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Client extends BaseClient
{
const API_URL = 'https://api.onecommunity.nl/v1/';
const VERSION = '0.5.0';
const VERSION = '0.5.1';

public function __construct(string $apiKey, int $userId, string $projectName)
{
Expand Down
25 changes: 25 additions & 0 deletions src/Requests/DeleteInteractionRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
namespace OneCommunity\Requests;

class DeleteInteractionRequest extends Request
{
/**
* @var int
*/
protected $interactionId;

public function __construct(int $interactionId)
{
$this->interactionId = $interactionId;
}

public function getMethod(): string
{
return 'POST';
}

public function getUri(): string
{
return "interactions/{$this->interactionId}/delete";
}
}

0 comments on commit 3ba6cb2

Please sign in to comment.