Skip to content

Commit

Permalink
Add Experian credentials API
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirBerdnik committed Nov 4, 2020
1 parent 40e512f commit 30472ef
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -19,6 +19,7 @@ Security - in case of vulnerabilities.

- [x] Added **Blocklist API**
- [x] Added **Plaid Credentials API**
- [x] Added **Experian Credentials API**
- [x] Added **Payment Instruments API**
- [x] Added `PaymentToken`
- [x] Added `Client::paymentTokens()` factory
Expand Down
2 changes: 2 additions & 0 deletions src/Client.php
Expand Up @@ -82,6 +82,7 @@
* @method Services\WebhooksService webhooks()
* @method Services\WebhookCredentialsService webhookCredentials()
* @method Services\PlaidCredentialsService plaidCredentials()
* @method Services\ExperianCredentialsService experianCredentials()
* @method Services\ValuesListService lists()
* @method Services\ValuesListTrackingService listsTracking()
* @method Services\WebhookTrackingService webhooksTracking()
Expand Down Expand Up @@ -154,6 +155,7 @@ final class Client
'customerTimeline' => Services\CustomerTimelineService::class,
'aml' => Services\AmlService::class,
'plaidCredentials' => Services\PlaidCredentialsService::class,
'experianCredentials' => Services\ExperianCredentialsService::class,
'paymentInstruments' => Services\PaymentInstrumentService::class,
];

Expand Down
131 changes: 131 additions & 0 deletions src/Entities/ExperianCredential.php
@@ -0,0 +1,131 @@
<?php
/**
* This source file is proprietary and part of Rebilly.
*
* (c) Rebilly SRL
* Rebilly Ltd.
* Rebilly Inc.
*
* @see https://www.rebilly.com
*/

namespace Rebilly\Entities;

use Rebilly\Rest\Entity;

final class ExperianCredential extends Entity
{
/**
* @return string
*/
public function getId()
{
return $this->getHash();
}

/**
* @return string
*/
public function getHash()
{
return $this->getAttribute('hash');
}

/**
* @return string
*/
public function getStatus()
{
return $this->getAttribute('status');
}

/**
* @param string $value
*
* @return $this
*/
public function setStatus($value)
{
return $this->setAttribute('status', $value);
}

/**
* @return string
*/
public function getUsername()
{
return $this->getAttribute('username');
}

/**
* @param string $value
*
* @return $this
*/
public function setUsername($value)
{
return $this->setAttribute('username', $value);
}

/**
* @return string
*/
public function getPassword()
{
return $this->getAttribute('password');
}

/**
* @param string $value
*
* @return $this
*/
public function setPassword($value)
{
return $this->setAttribute('password', $value);
}

/**
* @return string
*/
public function getHmacKey()
{
return $this->getAttribute('hmacKey');
}

/**
* @param string $value
*
* @return $this
*/
public function setHmacKey($value)
{
return $this->setAttribute('hmacKey', $value);
}

/**
* @return string
*/
public function getPublicKey()
{
return $this->getAttribute('publicKey');
}

/**
* @param string $value
*
* @return $this
*/
public function setPublicKey($value)
{
return $this->setAttribute('publicKey', $value);
}

/**
* @return string
*/
public function getDeactivationTime()
{
return $this->getAttribute('deactivationTime');
}
}
6 changes: 6 additions & 0 deletions src/Entities/Schema.php
Expand Up @@ -345,6 +345,12 @@ public function __construct()
'payment-instruments/{paymentInstrumentId}' => function (array $content) {
return new CommonPaymentInstrument($content);
},
'credential-hashes/experian' => function (array $content) {
return new Collection(new ExperianCredential(), $content);
},
'credential-hashes/experian/{hash}' => function (array $content) {
return new ExperianCredential($content);
},
];
}

Expand Down
59 changes: 59 additions & 0 deletions src/Services/ExperianCredentialsService.php
@@ -0,0 +1,59 @@
<?php
/**
* This source file is proprietary and part of Rebilly.
*
* (c) Rebilly SRL
* Rebilly Ltd.
* Rebilly Inc.
*
* @see https://www.rebilly.com
*/

namespace Rebilly\Services;

use JsonSerializable;
use Rebilly\Entities\ExperianCredential;
use Rebilly\Rest\Collection;
use Rebilly\Rest\Service;

final class ExperianCredentialsService extends Service
{
/**
* @return ExperianCredential[]|Collection
*/
public function search()
{
return $this->client()->get('credential-hashes/experian');
}

/**
* @param array|JsonSerializable|ExperianCredential $data
*
* @return ExperianCredential
*/
public function create($data)
{
return $this->client()->post($data, 'credential-hashes/experian');
}

/**
* @param string $hash
*
* @return ExperianCredential
*/
public function load($hash)
{
return $this->client()->get('credential-hashes/experian/{hash}', ['hash' => $hash]);
}

/**
* @param string $hash
* @param array|JsonSerializable|ExperianCredential $data
*
* @return ExperianCredential
*/
public function patch($hash, $data)
{
return $this->client()->patch($data, 'credential-hashes/experian/{hash}', ['hash' => $hash]);
}
}
1 change: 1 addition & 0 deletions tests/Api/ApiTest.php
Expand Up @@ -212,6 +212,7 @@ public function provideEntityClasses(): iterable
[Entities\PaymentRetryAttempt::class],
[Entities\GatewayAccountDowntime::class],
[Entities\PlaidCredential::class, 'hash'],
[Entities\ExperianCredential::class, 'hash'],
[Entities\CommonPaymentInstrument::class],
];

Expand Down
5 changes: 5 additions & 0 deletions tests/Api/ServiceTest.php
Expand Up @@ -1351,6 +1351,11 @@ public function provideServiceClasses()
Services\PlaidCredentialsService::class,
Entities\PlaidCredential::class,
],
[
'experianCredentials',
Services\ExperianCredentialsService::class,
Entities\ExperianCredential::class,
],
[
'webhooksTracking',
Services\WebhookTrackingService::class,
Expand Down
3 changes: 3 additions & 0 deletions tests/TestCase.php
Expand Up @@ -150,6 +150,9 @@ protected function getFakeValue($attribute, $class)
case 'response':
case 'acquirerReferenceNumber':
case 'bic':
case 'hmacKey':
case 'publicKey':
case 'username':
return $faker->word;
case 'redirectUrl':
return $redirectUrl;
Expand Down

0 comments on commit 30472ef

Please sign in to comment.