From d8186836584f81ea6a0c6a3667c43abcc85eb778 Mon Sep 17 00:00:00 2001 From: chkltlabs Date: Thu, 21 Mar 2024 20:40:44 +0000 Subject: [PATCH 1/4] feature: Link Token Create uses added params, rewrites function to pass params directly --- .idea/.gitignore | 8 ++++ .idea/modules.xml | 8 ++++ .idea/php.xml | 20 ++++++++++ .idea/phpunit.xml | 10 +++++ .idea/plaid-sdk-php.iml | 11 ++++++ .idea/vcs.xml | 6 +++ src/Resources/Tokens.php | 82 +++++++++++++++++++--------------------- 7 files changed, 102 insertions(+), 43 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/phpunit.xml create mode 100644 .idea/plaid-sdk-php.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..73c1283 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..8977815 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml new file mode 100644 index 0000000..4f8104c --- /dev/null +++ b/.idea/phpunit.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/plaid-sdk-php.iml b/.idea/plaid-sdk-php.iml new file mode 100644 index 0000000..2735361 --- /dev/null +++ b/.idea/plaid-sdk-php.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Resources/Tokens.php b/src/Resources/Tokens.php index 2883dbb..892d779 100644 --- a/src/Resources/Tokens.php +++ b/src/Resources/Tokens.php @@ -16,17 +16,27 @@ class Tokens extends AbstractResource * @param array $country_codes Possible values are: CA, FR, IE, NL, ES, GB, US * @param User $user * @param array $products Possible values are: transactions, auth, identity, income, assets, investments, liabilities, payment_initiation + * @param array $required_if_supported_products Possible values are: transactions, auth, identity, income, assets, investments, liabilities, payment_initiation + * @param array $optional_products Possible values are: transactions, auth, identity, income, assets, investments, liabilities, payment_initiation * @param string|null $webhook * @param string|null $link_customization_name * @param AccountFilters|null $account_filters * @param string|null $access_token * @param string|null $redirect_uri * @param string|null $android_package_name + * @param array|null $institution_data * @param string|null $payment_id * @param string|null $institution_id * @param array|null $auth - * @throws PlaidRequestException + * @param array|null $transfer + * @param array|null $update + * @param array|null $identity_verification + * @param array|null $statements + * @param array|null $investments + * @param array|null $transactions + * @param array|null $identity * @return object + *@throws PlaidRequestException */ public function create( string $client_name, @@ -34,62 +44,48 @@ public function create( array $country_codes, User $user, array $products = [], + array $required_if_supported_products = [], + array $optional_products = [], ?string $webhook = null, ?string $link_customization_name = null, ?AccountFilters $account_filters = null, ?string $access_token = null, ?string $redirect_uri = null, ?string $android_package_name = null, + ?array $institution_data = null, ?string $payment_id = null, ?string $institution_id = null, - ?array $auth = null): object { - - $params = [ - "client_name" => $client_name, - "language" => $language, - "country_codes" => $country_codes, - "user" => $user->toArray(), - "products" => $products - ]; - - if( $webhook ){ - $params["webhook"] = $webhook; + ?array $auth = null, + ?array $transfer = null, + ?array $update = null, + ?array $identity_verification = null, + ?array $statements = null, + ?array $investments = null, + ?array $transactions = null, + ?array $identity = null + ): object { + + //all defined params show here, including ones left null + //so, filter out the nulls + $params = array_filter(get_defined_vars(), function ($var) { + return !is_null($var); + }); + + //perform any data transformation + $params["user"] = $params["user"]->toArray(); + + if( isset($params["account_filters"]) ){ + $params["account_filters"] = $params["account_filters"]->toArray(); } - if( $link_customization_name ){ - $params["link_customization_name"] = $link_customization_name; - } - - if( $account_filters ){ - $params["account_filters"] = $account_filters->toArray(); - } - - if( $access_token ){ - $params["access_token"] = $access_token; - } - - if( $redirect_uri ){ - $params["redirect_uri"] = $redirect_uri; - } - - if( $android_package_name ){ - $params["android_package_name"] = $android_package_name; - } - - if( $payment_id ){ + if( isset($params["payment_id"]) ){ $params["payment_initiation"] = [ - "payment_id" => $payment_id + "payment_id" => $params["payment_id"] ]; + unset($params["payment_id"]); } - if( $institution_id ){ - $params["institution_id"] = $institution_id; - } - - if ($auth) { - $params["auth"] = $auth; - } - + //pass to plaid return $this->sendRequest( "post", "link/token/create", From 431bba0cc963fcf32f896829b2b1631a5cf93791 Mon Sep 17 00:00:00 2001 From: chkltlabs Date: Thu, 21 Mar 2024 20:45:56 +0000 Subject: [PATCH 2/4] rmidea --- .idea/.gitignore | 8 -------- .idea/modules.xml | 8 -------- .idea/php.xml | 20 -------------------- .idea/phpunit.xml | 10 ---------- .idea/plaid-sdk-php.iml | 11 ----------- .idea/vcs.xml | 6 ------ 6 files changed, 63 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/modules.xml delete mode 100644 .idea/php.xml delete mode 100644 .idea/phpunit.xml delete mode 100644 .idea/plaid-sdk-php.iml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 73c1283..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml deleted file mode 100644 index 8977815..0000000 --- a/.idea/php.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml deleted file mode 100644 index 4f8104c..0000000 --- a/.idea/phpunit.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/plaid-sdk-php.iml b/.idea/plaid-sdk-php.iml deleted file mode 100644 index 2735361..0000000 --- a/.idea/plaid-sdk-php.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 8bcf742e12008eb17bad9f4edc3ce5e49f9b2469 Mon Sep 17 00:00:00 2001 From: chkltlabs Date: Thu, 21 Mar 2024 20:56:26 +0000 Subject: [PATCH 3/4] reorder params to pass build --- src/Resources/Tokens.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Resources/Tokens.php b/src/Resources/Tokens.php index 892d779..9de6093 100644 --- a/src/Resources/Tokens.php +++ b/src/Resources/Tokens.php @@ -44,18 +44,18 @@ public function create( array $country_codes, User $user, array $products = [], - array $required_if_supported_products = [], - array $optional_products = [], ?string $webhook = null, ?string $link_customization_name = null, ?AccountFilters $account_filters = null, ?string $access_token = null, ?string $redirect_uri = null, ?string $android_package_name = null, - ?array $institution_data = null, ?string $payment_id = null, ?string $institution_id = null, ?array $auth = null, + array $required_if_supported_products = [], + array $optional_products = [], + ?array $institution_data = null, ?array $transfer = null, ?array $update = null, ?array $identity_verification = null, From 2870c0ce1fc3346c4fedd6c91ecd6234021f2a0d Mon Sep 17 00:00:00 2001 From: chkltlabs Date: Thu, 21 Mar 2024 21:29:39 +0000 Subject: [PATCH 4/4] changed to empty() function to reject empty array params too --- src/Resources/Tokens.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/Tokens.php b/src/Resources/Tokens.php index 9de6093..8405ad1 100644 --- a/src/Resources/Tokens.php +++ b/src/Resources/Tokens.php @@ -43,7 +43,7 @@ public function create( string $language, array $country_codes, User $user, - array $products = [], + ?array $products = [], ?string $webhook = null, ?string $link_customization_name = null, ?AccountFilters $account_filters = null, @@ -68,7 +68,7 @@ public function create( //all defined params show here, including ones left null //so, filter out the nulls $params = array_filter(get_defined_vars(), function ($var) { - return !is_null($var); + return !empty($var); }); //perform any data transformation