Skip to content
Open
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"type": "library",
"require": {
"php": ">=7.3|>=8.0",
"php": ">=7.4|>=8.0",
"ext-json": "*",
"ext-curl": "*",
"nimbly/shuttle": "^0.4"
Expand Down
102 changes: 102 additions & 0 deletions src/Entities/ConsumerReportUserIdentity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php

namespace TomorrowIdeas\Plaid\Entities;

class ConsumerReportUserIdentity
{

/**
* The first name.
*
* @var string
*/
protected $first_name;

/**
* The last name.
*
* @var string
*/
protected $last_name;

/**
* Phone numbers, in E164 format.
*
* @var string[]
*/
protected $phone_numbers = [];

/**
* The emails.
*
* @var string[]
*/
protected $emails;

/**
* The ssn last 4.
*
* @var string|null
*/
protected $ssn_last_4;

/**
* The date of birth.
*
* @var string|null
*/
protected $date_of_birth;

/**
* The primary address of the user.
*
* @var IdentityAddress|null
*/
protected $primary_address;

/**
* Construct a Consumer Report User Identity.
*
* @param string $first_name
* @param string $last_name
* @param array $phone_numbers
* @param array $emails
* @param string|null $ssn_last_4
* @param string|null $date_of_birth
* @param IdentityAddress|null $primary_address
*/
public function __construct(
string $first_name,
string $last_name,
array $phone_numbers = [],
array $emails = [],
?string $ssn_last_4 = null,
?string $date_of_birth = null,
?IdentityAddress $primary_address = null) {
$this->first_name = $first_name;
$this->last_name = $last_name;
$this->phone_numbers = $phone_numbers;
$this->emails = $emails;
$this->ssn_last_4 = $ssn_last_4;
$this->date_of_birth = $date_of_birth;
$this->primary_address = $primary_address;
}

public function toArray(): array
{
return \array_filter(
[
"first_name" => $this->first_name,
"last_name" => $this->last_name,
"phone_numbers" => $this->phone_numbers ?: null,
"emails" => $this->emails ?: null,
"ssn_last_4" => $this->ssn_last_4 ?: null,
"date_of_birth" => $this->date_of_birth,
"primary_address" => $this->primary_address ? $this->primary_address->toArray() : null
],
function($value): bool {
return $value !== null;
}
);
}
}
100 changes: 100 additions & 0 deletions src/Entities/IdentityAddress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

namespace TomorrowIdeas\Plaid\Entities;

class IdentityAddress
{

/**
* Street address.
*
* @var string
*/
protected $street;

/**
* City
*
* @var string
*/
protected $city;

/**
* The region or state.
*
* @var string
*/
protected $region;

/**
* Postal code
*
* @var string
*/
protected $postal_code;

/**
* Country (2 character ISO)
*
* @var string
*/
protected $country;

/**
* Create an IdentityAddress object from an array.
*
* @param array $data
*
* @return \TomorrowIdeas\Plaid\Entities\IdentityAddress
*/
public static function createFromArray(array $data) : IdentityAddress {
return new static(
$data['street'],
$data['city'],
$data['region'],
$data['postal_code'],
$data['country']
);
}

/**
* Address constructor.
*
* The Address object is needed for certain requests to Plaid.
*
* @param string $street
* @param string $city
* @param string $region
* @param string $postal_code
* @param string $country
*/
public function __construct(
string $street,
string $city,
string $region,
string $postal_code,
string $country)
{
$this->street = $street;
$this->city = $city;
$this->region = $region;
$this->postal_code = $postal_code;
$this->country = $country;
}

/**
* Convert the object into a key=>value pair that can be used in HTTP requests.
*
* @return array
*/
public function toArray(): array
{
return [
"street" => $this->street,
"city" => $this->city,
"region" => $this->region,
"postal_code" => $this->postal_code,
"country" => $this->country
];
}
}
122 changes: 122 additions & 0 deletions src/Entities/Item.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

namespace TomorrowIdeas\Plaid\Entities;

/**
* Representation of an item.
*
* @see https://plaid.com/docs/api/items/#itemget
*/
class Item
{

/**
* The item id.
*
* @var string
*/
protected $item_id;

/**
* The institution id.
*
* @var string
*/
protected $institution_id;

/**
* The institution name.
*
* @var string
*/
protected $institution_name;

/**
* The webhook url.
*
* @var string
*/
protected $webhook;

/**
* The auth method.
*
* @var string
*/
protected $auth_method;

protected $error;

protected $available_products;

protected $billed_products;

protected $products;

protected $consented_products;

protected $consent_expiration_time;

protected $update_type;

protected $created_at;

protected $consented_use_cases;

protected $consented_data_scopes;

public static function fromArray(array $array) {
return new static(
$array['item_id'],
$array['institution_id'] ?? null,
$array['institution_name'] ?? null,
$array['webhook'] ?? null,
$array['auth_method'] ?? null,
$array['error'] ?? null,
$array['available_products'] ?? [],
$array['billed_products'] ?? [],
$array['products'] ?? [],
$array['consented_products'] ?? [],
$array['consent_expiration_time'] ?? null,
$array['update_type'] ?? null,
$array['created_at'] ?? null,
$array['consented_use_cases'] ?? [],
$array['consented_data_scopes'] ?? []
);
}

public function __construct(
string $item_id,
?string $institution_id = null,
?string $institution_name = null,
?string $webhook = null,
?string $auth_method = null,
?object $error = null, // @todo: Create an error entity?
array $available_products = [],
array $billed_products = [],
array $products = [],
array $consented_products = [],
?string $consent_expiration_time = null,
?string $update_type = null,
?string $created_at = null,
array $consented_use_cases = [],
array $consented_data_scopes = []
) {
$this->item_id = $item_id;
$this->institution_id = $institution_id;
$this->institution_name = $institution_name;
$this->webhook = $webhook;
$this->auth_method = $auth_method;
$this->error = $error;
$this->available_products = $available_products;
$this->billed_products = $billed_products;
$this->products = $products;
$this->consented_products = $consented_products;
$this->consent_expiration_time = $consent_expiration_time;
$this->update_type = $update_type;
$this->created_at = $created_at;
$this->consented_use_cases = $consented_use_cases;
$this->consented_data_scopes = $consented_data_scopes;
}

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

namespace TomorrowIdeas\Plaid\Entities;
namespace TomorrowIdeas\Plaid\Entities\TokenConfig;

class AccountFilters
{
Expand All @@ -11,6 +11,18 @@ class AccountFilters
*/
protected $filters = [];

/**
* Create account filters from and array.
*
* @param array $filters
*
* @return \TomorrowIdeas\Plaid\Entities\TokenConfig\AccountFilters
*/
public static function createFromArray(array $filters): self
{
return new self($filters);
}


/**
* AccountFilters constructor.
Expand Down
Loading