Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Postback event example:
use Covery\Client\Envelopes\Builder;
use Covery\Client\Facade;

$event = Builder::postbackEvent($requestId, null, 'code', 'reason')->build(); //postbcak for event with id $requestId
$event = Builder::postbackEvent($requestId, null, 'code', 'reason')->build(); //postback for event with id $requestId
$postbackRequestId = Facade::sendPostback($event);
```

Expand All @@ -100,45 +100,45 @@ $event = Builder::cardIdEvent('curdNumber')->build();
$result = Facade::sendCardId($event);
```

Media Storage event example:
Document Storage event example:
```php
use Covery\Client\MediaStorage\Builder;
use Covery\Client\DocumentStorage\Builder;
use Covery\Client\Facade;

$event = Builder::mediaStorageEvent(\Covery\Client\ContentType::JPEG, \Covery\Client\ContentDescription::GENERAL_DOCUMENT, null, false)->build();
$result = Facade::sendMediaStorage($event);
$event = Builder::documentStorageEvent(\Covery\Client\ContentType::JPEG, \Covery\Client\ContentDescription::GENERAL_DOCUMENT, null, false)->build();
$result = Facade::sendDocumentStorage($event);
```

Attach media connection event example:
Attach document connection event example:
```php
use Covery\Client\MediaConnection\Builder;
use Covery\Client\DocumentConnection\Builder;
use Covery\Client\Facade;

$event = Builder::mediaConnectionEvent(1, [1])->build();
$result = Facade::attachMediaConnection($event);
$event = Builder::documentConnectionEvent(1, [1])->build();
$result = Facade::attachDocumentConnection($event);
```

Detach media connection event example:
Detach document connection event example:
```php
use Covery\Client\MediaConnection\Builder;
use Covery\Client\DocumentConnection\Builder;
use Covery\Client\Facade;

$event = Builder::mediaConnectionEvent(1, [1])->build();
$result = Facade::detachMediaConnection($event);
$event = Builder::documentConnectionEvent(1, [1])->build();
$result = Facade::detachDocumentConnection($event);
```

Media file upload example:
Document file upload example:
```php
use Covery\Client\Facade;

$stream = fopen('PATH_TO_FILE', 'r');
$mediaUrl = 'UPLOAD_URL'; //URL from Covery
$mediaFileUploader = \Covery\Client\MediaFileUploader\Builder::mediaFileUploaderEvent(
$mediaUrl,
$documentUrl = 'UPLOAD_URL'; //URL from Covery
$documentFileUploader = \Covery\Client\DocumentFileUploader\Builder::documentFileUploaderEvent(
$documentUrl,
$stream
)->build();

$result = \Covery\Client\Facade::uploadMediaFile($mediaFileUploader);
$result = \Covery\Client\Facade::uploadDocumentFile($documentFileUploader);
```

Account Configuration Status event example:
Expand Down Expand Up @@ -192,6 +192,7 @@ Methods `sendEvent` and `makeDecision` require envelope as argument. Envelope is
* `kyc_submit` - kyc submit event
* `order_item` - order item event
* `order_submit` - order submit event
* `document` - document event

Envelope specifications are bundled in `Covery\Client\EnvelopeInterface`.

Expand Down Expand Up @@ -229,6 +230,17 @@ You may provide the following as envelopes:

<a name="changelog"></a>
## Changelog
* `1.4.0`
* **Removed transaction_id field from postback event**
* Renamed MediaStorage method to DocumentMethod
* Renamed MediaConnection method to DocumentConnection
* Renamed UploadMediaFile method to DocumentMediaFile.
* Renamed `media_id` field to `document_id`
* Added optional `merchant_advice_code` and `merchant_advice_text` fields for postback event
* Added optional `anonymous` field for kyc_submit, profile_update events
* Changed length field `plugins` to `8192`
* New `document` event introduced
* Old tests modified
* `1.3.14` Added MediaStorage method. Added MediaConnection method. Added UploadMediaFile method.
* Added optional `media_id` field for events: install, registration, confirmation, login, order-item, order-submit, transaction, refund, payout, transfer, profile-update, kyc-profile, kyc-submit.
* Added optional address_confirmed, second_address_confirmed fields for KYC profile and KYC submit events.
Expand Down
16 changes: 8 additions & 8 deletions src/AccountConfigurationStatusResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AccountConfigurationStatusResult
/**
* @var string|null
*/
private $mediaStorageWebhookUrl;
private $documentStorageWebhookUrl;
/**
* @var string|null
*/
Expand Down Expand Up @@ -80,7 +80,7 @@ class AccountConfigurationStatusResult
* @param $decisionCallbackUrl
* @param $manualDecisionCallbackUrl
* @param $ongoingMonitoringWebhookUrl
* @param $mediaStorageWebhookUrl
* @param $documentStorageWebhookUrl
* @param $fraudAlertCallbackUrl
* @param $cardIdGeneration
* @param $deviceFingerprintGeneration
Expand All @@ -97,7 +97,7 @@ public function __construct(
$decisionCallbackUrl,
$manualDecisionCallbackUrl,
$ongoingMonitoringWebhookUrl,
$mediaStorageWebhookUrl,
$documentStorageWebhookUrl,
$fraudAlertCallbackUrl,
$cardIdGeneration,
$deviceFingerprintGeneration,
Expand All @@ -123,8 +123,8 @@ public function __construct(
if (!empty($ongoingMonitoringWebhookUrl) && !is_string($ongoingMonitoringWebhookUrl)) {
throw new \InvalidArgumentException("Ongoing Monitoring Webhook Url must be string");
}
if (!empty($mediaStorageWebhookUrl) && !is_string($mediaStorageWebhookUrl)) {
throw new \InvalidArgumentException("Media Storage Webhook Url Url must be string");
if (!empty($documentStorageWebhookUrl) && !is_string($documentStorageWebhookUrl)) {
throw new \InvalidArgumentException("Document Storage Webhook Url Url must be string");
}
if (!empty($fraudAlertCallbackUrl) && !is_string($fraudAlertCallbackUrl)) {
throw new \InvalidArgumentException("Fraud Alert Callback Url must be string");
Expand Down Expand Up @@ -159,7 +159,7 @@ public function __construct(
$this->decisionCallbackUrl = $decisionCallbackUrl;
$this->manualDecisionCallbackUrl = $manualDecisionCallbackUrl;
$this->ongoingMonitoringWebhookUrl = $ongoingMonitoringWebhookUrl;
$this->mediaStorageWebhookUrl = $mediaStorageWebhookUrl;
$this->documentStorageWebhookUrl = $documentStorageWebhookUrl;
$this->fraudAlertCallbackUrl = $fraudAlertCallbackUrl;
$this->cardIdGeneration = $cardIdGeneration;
$this->deviceFingerprintGeneration = $deviceFingerprintGeneration;
Expand Down Expand Up @@ -214,9 +214,9 @@ public function getOngoingMonitoringWebhookUrl()
/**
* @return string
*/
public function getMediaStorageWebhookUrl()
public function getDocumentStorageWebhookUrl()
{
return $this->mediaStorageWebhookUrl;
return $this->documentStorageWebhookUrl;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/AccountConfigurationStatusResultBaseField.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AccountConfigurationStatusResultBaseField
const DECISION_CALLBACK_URL = 'decisionCallbackUrl';
const MANUAL_DECISION_CALLBACK_URL = 'manualDecisionCallbackUrl';
const ONGOING_MONITORING_WEBHOOK_URL = 'ongoingMonitoringWebhookUrl';
const MEDIA_STORAGE_WEBHOOK_URL = 'mediaStorageWebhookUrl';
const DOCUMENT_STORAGE_WEBHOOK_URL = 'documentStorageWebhookUrl';
const FRAUD_ALERT_CALLBACK_URL = 'fraudAlertCallbackUrl';
const CARD_ID_GENERATION = 'cardIdGeneration';
const DEVICE_FINGERPRINT_GENERATION = 'deviceFingerprintGeneration';
Expand Down
19 changes: 0 additions & 19 deletions src/ContentDescription.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Covery\Client\MediaConnection;
namespace Covery\Client\DocumentConnection;

class Builder
{
Expand All @@ -10,56 +10,56 @@ class Builder
private $data = [];

/**
* Returns builder for media request
* Returns builder for document request
*
* @param $requestId
* @param $mediaId
* @param $documentId
* @return Builder
*/
public static function mediaConnectionEvent($requestId, $mediaId)
public static function documentConnectionEvent($requestId, $documentId)
{
$builder = new self();

return $builder
->addConnectionData($requestId, $mediaId);
->addConnectionData($requestId, $documentId);
}

/**
* Provides MediaConnection value
* Provides DocumentConnection value
*
* @param $requestId
* @param $mediaId
* @param $documentId
* @return Builder
*/
public function addConnectionData($requestId, $mediaId)
public function addConnectionData($requestId, $documentId)
{
if (!is_int($requestId)) {
throw new \InvalidArgumentException('Request Id must be integer');
}
if ($requestId <= 0) {
throw new \InvalidArgumentException('Request Id must be positive integer');
}
if (!is_array($mediaId)) {
throw new \InvalidArgumentException('Media Id must be array');
if (!is_array($documentId)) {
throw new \InvalidArgumentException('Document Id must be array');
}
if (!$this->isListOfPositiveInt($mediaId)) {
throw new \InvalidArgumentException('Media Id must be list of positive int');
if (!$this->isListOfPositiveInt($documentId)) {
throw new \InvalidArgumentException('Document Id must be list of positive int');
}

$this->replace('request_id', $requestId);
$this->replace('media_id', $mediaId);
$this->replace('document_id', $documentId);

return $this;
}

/**
* Returns built MediaConnection
* Returns built DocumentConnection
*
* @return MediaConnection
* @return DocumentConnection
*/
public function build()
{
return new MediaConnection(
return new DocumentConnection(
array_filter($this->data, function ($data) {
return $data !== null;
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

namespace Covery\Client\MediaConnection;
namespace Covery\Client\DocumentConnection;

use Covery\Client\MediaConnectionInterface;
use Covery\Client\DocumentConnectionInterface;

class MediaConnection implements MediaConnectionInterface
class DocumentConnection implements DocumentConnectionInterface
{
/**
* @var array
*/
private $data;

/**
* MediaConnection constructor.
* DocumentConnection constructor.
*/
public function __construct($data = [])
{
Expand Down
18 changes: 18 additions & 0 deletions src/DocumentConnectionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Covery\Client;

/**
* Interface DocumentConnectionInterface
*
* DocumentConnectionInterface represents data packet, sent to Covery
*
* @package Covery\Client
*/
interface DocumentConnectionInterface extends \ArrayAccess, \Countable
{
/**
* @return array
*/
public function toArray();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Covery\Client\MediaFileUploader;
namespace Covery\Client\DocumentFileUploader;

use Psr\Http\Message\StreamInterface;

Expand All @@ -12,18 +12,18 @@ class Builder
private $data = [];

/**
* Returns builder for media request
* Returns builder for document request
*
* @param $url
* @param $file
* @return Builder
*/
public static function mediaFileUploaderEvent($url, $file)
public static function documentFileUploaderEvent($url, $file)
{
$builder = new self();

return $builder
->addMediaFileUploaderData($url, $file);
->addDocumentFileUploaderData($url, $file);
}

/**
Expand All @@ -33,7 +33,7 @@ public static function mediaFileUploaderEvent($url, $file)
* @param $file
* @return Builder
*/
public function addMediaFileUploaderData($url, $file)
public function addDocumentFileUploaderData($url, $file)
{
if (!is_string($url)) {
throw new \InvalidArgumentException('Url must be string');
Expand All @@ -53,13 +53,13 @@ public function addMediaFileUploaderData($url, $file)
}

/**
* Returns built MediaFileUploader
* Returns built DocumentFileUploader
*
* @return MediaFileUploader
* @return DocumentFileUploader
*/
public function build()
{
return new MediaFileUploader(
return new DocumentFileUploader(
array_filter($this->data, function ($data) {
return $data !== null;
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

namespace Covery\Client\MediaFileUploader;
namespace Covery\Client\DocumentFileUploader;

use Covery\Client\MediaFileUploaderInterface;
use Covery\Client\DocumentFileUploaderInterface;

class MediaFileUploader implements MediaFileUploaderInterface
class DocumentFileUploader implements DocumentFileUploaderInterface
{
/**
* @var array
*/
private $data;

/**
* MediaConnection constructor.
* DocumentConnection constructor.
*/
public function __construct($data = [])
{
Expand Down
Loading