From 047789ae326568c06d85b594109829f585e26d65 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 14 Aug 2025 14:46:56 -0400 Subject: [PATCH] Allow implementors to set any request params they would like. --- src/Resources/Tokens.php | 80 +++++----------------------------------- 1 file changed, 10 insertions(+), 70 deletions(-) diff --git a/src/Resources/Tokens.php b/src/Resources/Tokens.php index 2883dbb..5f73da6 100644 --- a/src/Resources/Tokens.php +++ b/src/Resources/Tokens.php @@ -8,88 +8,28 @@ class Tokens extends AbstractResource { - /** + /** * Create a Link Token. * * @param string $client_name * @param string $language Possible values are: en, fr, es, nl * @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 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 string|null $payment_id - * @param string|null $institution_id - * @param array|null $auth + * @param array $params An array of additional parameters to pass to the Plaid API. * @throws PlaidRequestException * @return object + * @see https://plaid.com/docs/api/link/#linktokencreate */ public function create( string $client_name, - string $language, - array $country_codes, - User $user, - array $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, - ?string $payment_id = null, - ?string $institution_id = null, - ?array $auth = null): object { - - $params = [ + string $language = 'en', + array $country_codes = [], + array $params = [] + ): object { + $params = $params + [ "client_name" => $client_name, "language" => $language, "country_codes" => $country_codes, - "user" => $user->toArray(), - "products" => $products ]; - - if( $webhook ){ - $params["webhook"] = $webhook; - } - - 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 ){ - $params["payment_initiation"] = [ - "payment_id" => $payment_id - ]; - } - - if( $institution_id ){ - $params["institution_id"] = $institution_id; - } - - if ($auth) { - $params["auth"] = $auth; - } - return $this->sendRequest( "post", "link/token/create", @@ -107,7 +47,7 @@ public function create( public function get(string $link_token): object { $params = [ - "link_token" => $link_token + "link_token" => $link_token, ]; return $this->sendRequest( @@ -116,4 +56,4 @@ public function get(string $link_token): object $this->paramsWithClientCredentials($params) ); } -} \ No newline at end of file +}