### get() usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Reviews.md Example call to get() with a review ID. ```php Trustpilot::reviews()->get('review-id'); ``` -------------------------------- ### Install via Composer Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Install the package using Composer. ```bash composer require jeffersongoncalves/laravel-trustpilot ``` -------------------------------- ### get() with try/catch for TrustpilotException Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Demonstrates wrapping a get() call in a try/catch block to handle TrustpilotException. The example fetches reviews for a business unit with perPage=20 and reports the exception message. ```php use JeffersonGoncalves\Trustpilot\Exceptions\TrustpilotException; try { $reviews = $client->get('/business-units/'.$unitId.'/reviews', ['perPage' => 20]); } catch (TrustpilotException $e) { report($e->getMessage()); } ``` -------------------------------- ### get() usage with app() and query parameters Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Shows how to instantiate TrustpilotClient via the Laravel container and call get() with a query array. The example fetches the latest reviews with a count of 10. ```php use JeffersonGoncalves\Trustpilot\TrustpilotClient; $client = app(TrustpilotClient::class); $latest = $client->get('/reviews/latest', ['count' => 10]); ``` -------------------------------- ### Using tags() accessor Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Example usage of the tags() accessor. Demonstrates the get method. ```php $tags = Trustpilot::tags()->get('rev-1'); ``` -------------------------------- ### Using invitations() accessor Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Example usage of the invitations() accessor. Demonstrates the create method. ```php $invite = Trustpilot::invitations()->create('ada@example.com', 'Ada Lovelace'); ``` -------------------------------- ### get usage examples Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/BusinessUnits.md Shows two calls: one using the configured default business unit ID and one with an explicit ID that overrides the default. ```php Trustpilot::businessUnits()->get(); // uses configured default Trustpilot::businessUnits()->get('other-unit'); // explicit id wins ``` -------------------------------- ### reviews() usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Calls Trustpilot::reviews()->list() with perPage, stars, and language parameters. ```php $reviews = Trustpilot::reviews()->list(perPage: 20, stars: 5, language: 'pt'); ``` -------------------------------- ### accessToken() usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Calls Trustpilot::accessToken() to get the OAuth token. ```php $token = Trustpilot::accessToken(); // normally never needed — private calls do this automatically ``` -------------------------------- ### accessToken() usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Shows retrieving the access token, which is minted once and then served from cache. ```php $token = $client->accessToken(); // e.g. minted once, then served from cache ``` -------------------------------- ### latest() usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Reviews.md Example call to latest() with a count of 5. ```php Trustpilot::reviews()->latest(5); ``` -------------------------------- ### Using reviews() accessor Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Example usage of the reviews() accessor. Demonstrates public (apikey) and private (bearer) methods. ```php $latest = Trustpilot::reviews()->latest(5); // public (apikey) $reply = Trustpilot::reviews()->reply('rev-1', 'Thanks'); // private (bearer) ``` -------------------------------- ### businessUnits() usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Calls Trustpilot::businessUnits()->search() with a domain and limit. ```php $units = Trustpilot::businessUnits()->search('example.com', limit: 20); ``` -------------------------------- ### Verify Trustpilot bindings from application code Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotServiceProvider.md Example showing how to verify the singleton, alias, and facade bindings from application code. All checks return true. ```php use JeffersonGoncalves\Trustpilot\TrustpilotClient; use JeffersonGoncalves\Trustpilot\Facades\Trustpilot; $isSingleton = app(TrustpilotClient::class) === app(TrustpilotClient::class); // true $viaAlias = app('trustpilot') instanceof TrustpilotClient; // true $viaFacade = Trustpilot::getFacadeRoot() instanceof TrustpilotClient; // true ``` -------------------------------- ### list() usage with filters Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Reviews.md Example call to list() with perPage, orderBy, stars, and language parameters. ```php Trustpilot::reviews()->list(perPage: 20, orderBy: 'createdat.desc', stars: 5, language: 'pt'); ``` -------------------------------- ### templates() usage Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Invitations.md Example call to retrieve invitation templates. ```php Trustpilot::invitations()->templates(); ``` -------------------------------- ### get() method signature with docblock Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Declares the get() method that sends an HTTP GET to {base_url}{$uri} with query parameters. Defaults to 'apikey' auth mode; pass 'bearer' for private endpoints. Returns decoded JSON body or [] if not a JSON array, throws TrustpilotException on non-2xx. ```php /** * @param array $query * @return array * * @throws TrustpilotException */ public function get(string $uri, array $query = [], string $auth = 'apikey'): array ``` -------------------------------- ### businessUnitId() usage examples Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Shows two ways to call businessUnitId(): from config and with an explicit unit. ```php $id = Trustpilot::businessUnitId(); // from config $id = Trustpilot::businessUnitId('other-unit'); // explicit ``` -------------------------------- ### get(string $uri, array $query = [], string $auth = 'apikey'): array Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Sends an HTTP GET request to the Trustpilot API. Appends query parameters and defaults to apikey authentication. ```APIDOC ## GET {base_url}{$uri} ### Description Sends an HTTP GET to `{base_url}{$uri}` with `$query` appended as query string parameters. Defaults to the `apikey` auth mode; pass `'bearer'` as `$auth` for private endpoints. ### Method GET ### Endpoint `{base_url}{$uri}` ### Parameters #### Path Parameters - **$uri** (string) - Required - Path relative to `trustpilot.base_url`, e.g. `/reviews/latest` #### Query Parameters - **$query** (array) - Optional - Query string parameters #### Authentication - **$auth** (string) - Optional - Auth mode: `'apikey'` or `'bearer'` (default: `'apikey'`) ### Request Example ```php use JeffersonGoncalves\Trustpilot\TrustpilotClient; $client = app(TrustpilotClient::class); $latest = $client->get('/reviews/latest', ['count' => 10]); ``` ### Response #### Success Response (200) - **array** - The decoded JSON response body; `[]` if the body is not a JSON array. #### Response Example ```php use JeffersonGoncalves\Trustpilot\Exceptions\TrustpilotException; try { $reviews = $client->get('/business-units/'.$unitId.'/reviews', ['perPage' => 20]); } catch (TrustpilotException $e) { report($e->getMessage()); } ``` ### Error Handling Throws `TrustpilotException` on any non-2xx response. ``` -------------------------------- ### Tags get usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Tags.md Calls the get method with a review ID to fetch its tags. ```php Trustpilot::tags()->get('review-id'); ``` -------------------------------- ### reviews()->get() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Retrieves a specific review by ID. Returns raw decoded JSON response as an array. ```APIDOC ## reviews()->get() ### Description Retrieves a specific review by ID. Returns raw decoded JSON response as an array. ### Method reviews()->get() ### Parameters - **reviewId** (string) - Required - The ID of the review. ### Response Returns raw decoded JSON response as an array. ``` -------------------------------- ### reply() usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Reviews.md Replies to a review with the given ID and message. Returns a decoded JSON array. ```php Trustpilot::reviews()->reply('review-id', 'Thanks for the feedback!'); ``` -------------------------------- ### businessUnitId() usage examples Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Shows resolving the business unit id from config or with an explicit argument that overrides it. ```php $id = $client->businessUnitId(); // config value $id = $client->businessUnitId('other-unit'); // explicit wins ``` -------------------------------- ### Using businessUnits() accessor Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Example usage of the businessUnits() accessor via the Trustpilot facade. Returns a BusinessUnits instance and demonstrates the search method. ```php use JeffersonGoncalves\Trustpilot\Facades\Trustpilot; $units = Trustpilot::businessUnits(); // BusinessUnits instance $found = Trustpilot::businessUnits()->search('example.com'); ``` -------------------------------- ### get method signature Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/BusinessUnits.md Declares the get method that reads a single business unit by ID. The ID defaults to the configured trustpilot.business_unit_id when null is passed. Throws TrustpilotException on non-2xx responses or when no ID is resolvable. ```php /** * @return array */ public function get(?string $businessUnitId = null): array ``` -------------------------------- ### GET /reviews/latest Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Retrieve the latest reviews, with an optional count parameter. ```APIDOC ## GET /reviews/latest ### Description Retrieve the latest reviews, with an optional count parameter. ### Method GET ### Endpoint /reviews/latest ### Parameters #### Query Parameters - **count** (int) - Optional - Number of latest reviews (default: 20) ### Request Example No request body required. ### Response #### Success Response (200) Returns a list of the latest reviews. #### Response Example (No response example provided in source.) ``` -------------------------------- ### search usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/BusinessUnits.md Calls the search method with a domain query and a limit of 20. Returns an array of business units matching the query. ```php Trustpilot::businessUnits()->search('example.com', limit: 20); ``` -------------------------------- ### profile usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/BusinessUnits.md Calls the profile method with an explicit business unit ID to retrieve its profile information. ```php Trustpilot::businessUnits()->profile('other-unit'); ``` -------------------------------- ### delete() usage examples Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Shows calling delete() with and without query parameters. When $query is non-empty, it is serialized onto the URI via http_build_query. ```php $client->delete('/private/reviews/rev-1/reply'); // no query $client->delete('/private/reviews/rev-1/tags', ['group' => 'topic', 'value' => 'shipping']); // → DELETE .../tags?group=topic&value=shipping ``` -------------------------------- ### create() usage with reference Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Invitations.md Example call to create an invitation with a reference number. The reference is passed as a named argument 'order-42'. ```php Trustpilot::invitations()->create('ada@example.com', 'Ada Lovelace', reference: 'order-42'); ``` -------------------------------- ### Review Tags Methods Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Methods for getting, adding, and removing tags on a review. ```php Trustpilot::tags()->get('review-id'); Trustpilot::tags()->add('review-id', 'topic', 'shipping'); Trustpilot::tags()->remove('review-id', 'topic', 'shipping'); ``` -------------------------------- ### private() usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Reviews.md Calls the private() method with perPage=20 and stars=1. Returns a decoded JSON array. ```php Trustpilot::reviews()->private(perPage: 20, stars: 1); ``` -------------------------------- ### tags()->get() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Retrieves review tags. Requires API secret. Returns raw decoded JSON response as an array. ```APIDOC ## tags()->get() ### Description Retrieves review tags. Requires API secret. Returns raw decoded JSON response as an array. ### Method tags()->get() ### Parameters - **businessUnitId** (string) - Required - The ID of the business unit. ### Response Returns raw decoded JSON response as an array. ``` -------------------------------- ### GET /business-units/{businessUnitId}/reviews Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md List reviews for a specific business unit with optional filters. ```APIDOC ## GET /business-units/{businessUnitId}/reviews ### Description List reviews for a specific business unit with optional filters. ### Method GET ### Endpoint /business-units/{businessUnitId}/reviews ### Parameters #### Path Parameters - **businessUnitId** (string) - Required - The ID of the business unit #### Query Parameters - **perPage** (int) - Optional - Page size (default: 20) - **orderBy** (string) - Optional - Sort order (default: 'createdat.desc') - **stars** (int) - Optional - Star filter (omitted when null) - **language** (string) - Optional - Language filter (omitted when null) ### Request Example No request body required. ### Response #### Success Response (200) Returns a list of reviews for the business unit. #### Response Example (No response example provided in source.) ``` -------------------------------- ### businessUnits()->get() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Retrieves a specific business unit by ID. Returns raw decoded JSON response as an array. ```APIDOC ## businessUnits()->get() ### Description Retrieves a specific business unit by ID. Returns raw decoded JSON response as an array. ### Method businessUnits()->get() ### Parameters - **businessUnitId** (string) - Required - The ID of the business unit. ### Response Returns raw decoded JSON response as an array. ``` -------------------------------- ### create() usage with attributes Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Invitations.md Example call to create an invitation with extra attributes such as senderEmail, replyTo, and templateId. These attributes are merged into the request body. ```php Trustpilot::invitations()->create('ada@example.com', 'Ada Lovelace', attributes: [ 'senderEmail' => 'noreply@example.com', 'replyTo' => 'support@example.com', 'templateId' => 'your-template-id', ]); ``` -------------------------------- ### GET /reviews/{reviewId} Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Retrieve a specific review by its ID. ```APIDOC ## GET /reviews/{reviewId} ### Description Retrieve a specific review by its ID. ### Method GET ### Endpoint /reviews/{reviewId} ### Parameters #### Path Parameters - **reviewId** (string) - Required - The ID of the review ### Request Example No request body required. ### Response #### Success Response (200) Returns the review details. #### Response Example (No response example provided in source.) ``` -------------------------------- ### webLinks usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/BusinessUnits.md Calls the webLinks method with a Portuguese-Brazilian locale to retrieve web links for the default business unit. ```php Trustpilot::businessUnits()->webLinks('pt-BR'); ``` -------------------------------- ### Get Reviews instance via facade Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Reviews.md Retrieve the Reviews resource instance from the Trustpilot facade. Typically used to access review endpoints. ```php use JeffersonGoncalves\Trustpilot\Facades\Trustpilot; $reviews = Trustpilot::reviews(); // Reviews ``` -------------------------------- ### get() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Reviews.md Retrieves a single review by its ID. Public endpoint using API key authentication. ```APIDOC ## [GET] /reviews/{reviewId} ### Description Retrieves a single review by its ID. Public endpoint using API key authentication. ### Method GET ### Endpoint /reviews/{reviewId} ### Parameters #### Path Parameters - **reviewId** (string) - Required - The Trustpilot review id ### Request Example ``` GET /reviews/{reviewId} ``` ### Response #### Success Response (200) - **body** (array) - Decoded JSON response #### Response Example ```json {} ``` ### Error Handling - **TrustpilotException** - Thrown on non-2xx response. ``` -------------------------------- ### link() usage with reference Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Invitations.md Example call to create an invitation link with a reference id. The reference is passed as a named argument 'order-42'. ```php Trustpilot::invitations()->link('ada@example.com', 'Ada Lovelace', reference: 'order-42'); ``` -------------------------------- ### GET /private/business-units/{businessUnitId}/templates Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Retrieves email templates for a business unit. No query parameters are required. ```APIDOC ## GET /private/business-units/{businessUnitId}/templates ### Description Retrieves email templates for a business unit. No query parameters are required. ### Method GET ### Endpoint /private/business-units/{businessUnitId}/templates ### Parameters #### Path Parameters - **businessUnitId** (string) - Required - The ID of the business unit. ### Response #### Success Response (200) - **templates** (array) - List of templates. #### Response Example { "templates": [] } ``` -------------------------------- ### GET /business-units/{businessUnitId}/profileinfo Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Retrieve profile information for a specific business unit. ```APIDOC ## GET /business-units/{businessUnitId}/profileinfo ### Description Retrieve profile information for a specific business unit. ### Method GET ### Endpoint /business-units/{businessUnitId}/profileinfo ### Parameters #### Path Parameters - **businessUnitId** (string) - Required - The ID of the business unit ### Request Example No request body required. ### Response #### Success Response (200) Returns profile information for the business unit. #### Response Example (No response example provided in source.) ``` -------------------------------- ### GET /business-units/{businessUnitId}/web-links Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Retrieve web links for a specific business unit, optionally localized. ```APIDOC ## GET /business-units/{businessUnitId}/web-links ### Description Retrieve web links for a specific business unit, optionally localized. ### Method GET ### Endpoint /business-units/{businessUnitId}/web-links ### Parameters #### Path Parameters - **businessUnitId** (string) - Required - The ID of the business unit #### Query Parameters - **locale** (string) - Optional - Locale for the web links (default: 'en-US') ### Request Example No request body required. ### Response #### Success Response (200) Returns web links for the business unit. #### Response Example (No response example provided in source.) ``` -------------------------------- ### GET /business-units/search Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Search for business units by query term. Returns a list of matching business units. ```APIDOC ## GET /business-units/search ### Description Search for business units by query term. Returns a list of matching business units. ### Method GET ### Endpoint /business-units/search ### Parameters #### Query Parameters - **query** (string) - Required - Search term - **limit** (int) - Optional - Max results (default: 20) ### Request Example No request body required. ### Response #### Success Response (200) Returns a list of business units matching the search query. #### Response Example (No response example provided in source.) ``` -------------------------------- ### categories usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/BusinessUnits.md Calls the categories method without arguments, using the configured default business unit ID. ```php Trustpilot::businessUnits()->categories(); ``` -------------------------------- ### Config File Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Configuration options for the package. The base_url and cache_key have defaults if not set. ```php // config/trustpilot.php return [ 'api_key' => env('TRUSTPILOT_API_KEY'), 'api_secret' => env('TRUSTPILOT_API_SECRET'), 'business_unit_id' => env('TRUSTPILOT_BUSINESS_UNIT_ID'), 'base_url' => env('TRUSTPILOT_BASE_URL', 'https://api.trustpilot.com/v1'), 'cache_key' => env('TRUSTPILOT_CACHE_KEY', 'trustpilot.access_token'), ]; ``` -------------------------------- ### GET /private/business-units/{businessUnitId}/reviews Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Retrieves reviews for a specific business unit. Supports pagination and star filtering. ```APIDOC ## GET /private/business-units/{businessUnitId}/reviews ### Description Retrieves reviews for a specific business unit. Supports pagination and star filtering. ### Method GET ### Endpoint /private/business-units/{businessUnitId}/reviews ### Parameters #### Path Parameters - **businessUnitId** (string) - Required - The ID of the business unit. #### Query Parameters - **perPage** (int) - Optional - Page size. Default: 20. - **stars** (int) - Optional - Star filter. Omitted when null. ### Response #### Success Response (200) - **reviews** (array) - List of reviews. #### Response Example { "reviews": [] } ``` -------------------------------- ### Import Trustpilot Facade and Exception Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Required imports for using the Trustpilot facade and catching TrustpilotException. ```php use JeffersonGoncalves\Trustpilot\Facades\Trustpilot; use JeffersonGoncalves\Trustpilot\Exceptions\TrustpilotException; ``` -------------------------------- ### Catching TrustpilotException as RuntimeException Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotException.md Because TrustpilotException extends RuntimeException, it can be caught as RuntimeException or Exception. This example shows catching it as RuntimeException when calling Trustpilot::tags()->get(). ```php use RuntimeException; try { Trustpilot::tags()->get('rev-1'); } catch (RuntimeException $e) { // also catches TrustpilotException } ``` -------------------------------- ### Tags get method signature Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Tags.md Declares the get method that reads tags for a review via GET /private/reviews/{reviewId}/tags. Returns decoded JSON and throws TrustpilotException on non-2xx or credential failures. ```php /** * @return array */ public function get(string $reviewId): array ``` -------------------------------- ### Catching TrustpilotException with try-catch Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotException.md Example of catching TrustpilotException when calling the Trustpilot facade. Provides access to the API message via getMessage() and the HTTP status via statusCode, logging both along with the exception code. ```php use JeffersonGoncalves\Trustpilot\Facades\Trustpilot; use JeffersonGoncalves\Trustpilot\Exceptions\TrustpilotException; try { $reviews = Trustpilot::reviews()->list(); } catch (TrustpilotException $e) { // $e->getMessage() — the API's message / error_description / error, or the raw body // $e->statusCode — HTTP status returned by Trustpilot (0 for config errors) logger()->error('Trustpilot request failed', [ 'message' => $e->getMessage(), 'status' => $e->statusCode, 'code' => $e->getCode(), ]); } ``` -------------------------------- ### Facade root and non-facade access Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Shows three ways to resolve the singleton TrustpilotClient instance. ```php use JeffersonGoncalves\Trustpilot\Facades\Trustpilot; use JeffersonGoncalves\Trustpilot\TrustpilotClient; $client = Trustpilot::getFacadeRoot(); // the singleton TrustpilotClient $client = app(TrustpilotClient::class); // identical instance $client = app('trustpilot'); // via the container alias ``` -------------------------------- ### Run code formatting with composer format Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Formats the codebase according to the project's coding standards. ```bash composer format ``` -------------------------------- ### get(string $reviewId): array Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Tags.md Retrieves the tags associated with a specific review. This method sends a GET request to the private tags endpoint and returns the decoded JSON response. ```APIDOC ## GET /private/reviews/{reviewId}/tags ### Description Retrieves the tags for a given review. ### Method GET ### Endpoint /private/reviews/{reviewId}/tags ### Parameters #### Path Parameters - **reviewId** (string) - Required - The review whose tags are read ### Request Example No request body required. ### Response #### Success Response (200) - **tags** (array) - The list of tags associated with the review #### Response Example { "tags": [ { "group": "topic", "value": "shipping" } ] } ``` -------------------------------- ### reviews()->list() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Lists reviews for a business unit. Returns raw decoded JSON response as an array. ```APIDOC ## reviews()->list() ### Description Lists reviews for a business unit. Returns raw decoded JSON response as an array. ### Method reviews()->list() ### Parameters - **businessUnitId** (string) - Required - The ID of the business unit. ### Response Returns raw decoded JSON response as an array. ``` -------------------------------- ### Invitations Methods Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Methods for creating invitation links and retrieving templates. Extra payload keys for `create` are passed via the `attributes` array. ```php Trustpilot::invitations()->create('ada@example.com', 'Ada Lovelace', reference: 'order-42'); // extra payload keys go through `attributes` Trustpilot::invitations()->create('ada@example.com', 'Ada Lovelace', attributes: [ 'senderEmail' => 'noreply@example.com', 'replyTo' => 'support@example.com', 'templateId' => 'your-template-id', ]); Trustpilot::invitations()->link('ada@example.com', 'Ada Lovelace', reference: 'order-42'); Trustpilot::invitations()->templates(); ``` -------------------------------- ### reviews() annotation Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Static method annotation for reviews() returning Reviews. ```php @method static Reviews reviews() ``` -------------------------------- ### Publish Config File Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Optionally publish the config file using the artisan command. ```bash php artisan vendor:publish --tag="trustpilot-config" ``` -------------------------------- ### Run test suite with composer test Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Executes the package's test suite. Use this command to verify that all tests pass. ```bash composer test ``` -------------------------------- ### invitations()->create() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Creates an invitation. Requires API secret. Returns raw decoded JSON response as an array. ```APIDOC ## invitations()->create() ### Description Creates an invitation. Requires API secret. Returns raw decoded JSON response as an array. ### Method invitations()->create() ### Parameters - **data** (array) - Required - The invitation data. ### Response Returns raw decoded JSON response as an array. ``` -------------------------------- ### list() method implementation Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Reviews.md Fetches reviews for a business unit with optional filters. Public endpoint using API key auth. Null filters are omitted from the query string. ```php /** * @return array */ public function list( ?string $businessUnitId = null, int $perPage = 20, string $orderBy = 'createdat.desc', ?int $stars = null, ?string $language = null, ): array { return $this->client->get( '/business-units/'.$this->client->businessUnitId($businessUnitId).'/reviews', array_filter([ 'perPage' => $perPage, 'orderBy' => $orderBy, 'stars' => $stars, 'language' => $language, ], fn ($value) => $value !== null), ); } ``` -------------------------------- ### invitations() annotation Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Static method annotation for invitations() returning Invitations. ```php @method static Invitations invitations() ``` -------------------------------- ### GET /business-units/{businessUnitId}/categories Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Retrieve categories for a specific business unit. ```APIDOC ## GET /business-units/{businessUnitId}/categories ### Description Retrieve categories for a specific business unit. ### Method GET ### Endpoint /business-units/{businessUnitId}/categories ### Parameters #### Path Parameters - **businessUnitId** (string) - Required - The ID of the business unit ### Request Example No request body required. ### Response #### Success Response (200) Returns categories for the business unit. #### Response Example (No response example provided in source.) ``` -------------------------------- ### deleteReply() usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Reviews.md Deletes the reply for the given review ID. Returns a decoded JSON array. ```php Trustpilot::reviews()->deleteReply('review-id'); ``` -------------------------------- ### Class declaration for TrustpilotServiceProvider Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotServiceProvider.md The service provider extends Spatie's PackageServiceProvider, sets the package name to 'trustpilot', declares a config file, and registers TrustpilotClient as a singleton with the alias 'trustpilot'. ```php class TrustpilotServiceProvider extends PackageServiceProvider { public function configurePackage(Package $package): void { $package ->name('trustpilot') ->hasConfigFile(); } public function packageRegistered(): void { $this->app->singleton(TrustpilotClient::class); $this->app->alias(TrustpilotClient::class, 'trustpilot'); } } ``` -------------------------------- ### Run static analysis with composer analyse Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Runs static analysis on the codebase to detect potential issues without executing the code. ```bash composer analyse ``` -------------------------------- ### Instantiate Invitations via Trustpilot Facade Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Invitations.md Retrieve an Invitations resource instance from the Trustpilot facade. Requires TRUSTPILOT_API_SECRET for bearer auth. ```php use JeffersonGoncalves\Trustpilot\Facades\Trustpilot; $invitations = Trustpilot::invitations(); // Invitations ``` -------------------------------- ### Trustpilot::invitations() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Returns the Invitations resource instance for interacting with Trustpilot invitation endpoints. Use this to create review invitations. ```APIDOC ## Trustpilot::invitations() ### Description Returns the Invitations resource instance for interacting with Trustpilot invitation endpoints. Use this to create review invitations. ### Method Static method on the Trustpilot facade. ### Endpoint `Trustpilot::invitations()` ### Parameters None. ### Returns - **Invitations** - The Invitations resource instance. ### Example ```php Trustpilot::invitations()->create('ada@example.com', 'Ada Lovelace', reference: 'order-42'); ``` ``` -------------------------------- ### Reviews Methods Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Methods for listing, retrieving, and managing reviews. The `private` method requires the TRUSTPILOT_API_SECRET environment variable. ```php Trustpilot::reviews()->list(perPage: 20, orderBy: 'createdat.desc', stars: 5, language: 'pt'); Trustpilot::reviews()->get('review-id'); Trustpilot::reviews()->latest(20); // private — needs TRUSTPILOT_API_SECRET Trustpilot::reviews()->private(perPage: 20, stars: 1); Trustpilot::reviews()->reply('review-id', 'Thanks for the feedback!'); Trustpilot::reviews()->deleteReply('review-id'); ``` -------------------------------- ### Invitations::__construct Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Invitations.md Constructor for the Invitations resource. It accepts a TrustpilotClient instance that provides business unit ID resolution, HTTP verbs, and bearer authentication. ```APIDOC ## Invitations::__construct ### Description Constructor for the Invitations resource. It accepts a TrustpilotClient instance that provides business unit ID resolution, HTTP verbs, and bearer authentication. ### Method Constructor ### Parameters - `$client` (TrustpilotClient) - Required - The shared client; supplies `businessUnitId()` resolution, HTTP verbs, and bearer auth ### Source `src/Resources/Invitations.php:13` ``` -------------------------------- ### list() with exception handling Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Reviews.md Shows catching TrustpilotException when calling list(). Public call may fail with 'Invalid api key' and statusCode 401. ```php use JeffersonGoncalves\Trustpilot\Exceptions\TrustpilotException; try { $reviews = Trustpilot::reviews()->list(); } catch (TrustpilotException $e) { // public call: 'Invalid api key' with statusCode 401, e.g. } ``` -------------------------------- ### Trustpilot::reviews() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Returns the Reviews resource instance for interacting with Trustpilot review endpoints. Use this to list reviews with filtering options. ```APIDOC ## Trustpilot::reviews() ### Description Returns the Reviews resource instance for interacting with Trustpilot review endpoints. Use this to list reviews with filtering options. ### Method Static method on the Trustpilot facade. ### Endpoint `Trustpilot::reviews()` ### Parameters None. ### Returns - **Reviews** - The Reviews resource instance. ### Example ```php $reviews = Trustpilot::reviews()->list(perPage: 20, stars: 5, language: 'pt'); ``` ``` -------------------------------- ### templates Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Invitations.md Retrieves available invitation templates for a business unit. Sends a GET request to the private business units endpoint. ```APIDOC ## [GET] /private/business-units/{businessUnitId}/templates ### Description Retrieves available invitation templates for a business unit. Sends a GET request to the private business units endpoint. ### Method GET ### Endpoint /private/business-units/{businessUnitId}/templates ### Parameters #### Path Parameters - **businessUnitId** (string) - Optional - Business unit id; falls back to `trustpilot.business_unit_id` ### Response #### Success Response (200) - **response** (object) - Decoded JSON response (available invitation templates) #### Response Example { "templates": [] } ``` -------------------------------- ### Business Units Methods Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Methods for searching, retrieving, and managing business unit data. The `search` method accepts a domain and optional limit; `webLinks` accepts a locale. ```php Trustpilot::businessUnits()->search('example.com', limit: 20); Trustpilot::businessUnits()->get(); Trustpilot::businessUnits()->profile(); Trustpilot::businessUnits()->categories(); Trustpilot::businessUnits()->webLinks('pt-BR'); ``` -------------------------------- ### POST /private/business-units/{businessUnitId}/invitation-links Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Creates an invitation link for a consumer. Requires email and name. ```APIDOC ## POST /private/business-units/{businessUnitId}/invitation-links ### Description Creates an invitation link for a consumer. Requires email and name. ### Method POST ### Endpoint /private/business-units/{businessUnitId}/invitation-links ### Parameters #### Path Parameters - **businessUnitId** (string) - Required - The ID of the business unit. #### Request Body - **email** (string) - Required - Consumer email. - **name** (string) - Required - Consumer name. - **referenceId** (string) - Optional - Reference id. Default: ''. - **redirectUri** (string) - Optional - Post-review redirect. Default: 'https://trustpilot.com'. ### Request Example { "email": "consumer@example.com", "name": "John Doe", "referenceId": "12345", "redirectUri": "https://example.com/thank-you" } ### Response #### Success Response (200) - **link** (object) - The created invitation link. #### Response Example { "link": {} } ``` -------------------------------- ### reviews()->reply() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Adds a reply to a review. Requires API secret. Returns raw decoded JSON response as an array. ```APIDOC ## reviews()->reply() ### Description Adds a reply to a review. Requires API secret. Returns raw decoded JSON response as an array. ### Method reviews()->reply() ### Parameters - **reviewId** (string) - Required - The ID of the review. - **message** (string) - Required - The reply message. ### Response Returns raw decoded JSON response as an array. ``` -------------------------------- ### Tags remove usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Tags.md Calls the remove method with a review ID, group 'topic', and value 'shipping' to remove a tag. ```php Trustpilot::tags()->remove('review-id', 'topic', 'shipping'); ``` -------------------------------- ### reviews() method signature Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Returns a Reviews resource object sharing this client. Public read methods use the apikey auth mode; private(), reply() and deleteReply() use the bearer token. ```php public function reviews(): Reviews ``` -------------------------------- ### Tags add usage example Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Tags.md Calls the add method with a review ID, group 'topic', and value 'shipping' to add a tag. ```php Trustpilot::tags()->add('review-id', 'topic', 'shipping'); ``` -------------------------------- ### configurePackage method signature Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotServiceProvider.md Method signature for configurePackage(Package $package): void. It sets the package name and declares a config file, enabling publishing and merging of config/trustpilot.php. ```php public function configurePackage(Package $package): void ``` -------------------------------- ### Access BusinessUnits via Facade Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/BusinessUnits.md Use the Trustpilot facade to obtain a BusinessUnits instance. Requires TRUSTPILOT_API_KEY because all methods use the apikey auth mode. ```php use JeffersonGoncalves\Trustpilot\Facades\Trustpilot; $units = Trustpilot::businessUnits(); // BusinessUnits ``` -------------------------------- ### businessUnits() annotation Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Static method annotation for businessUnits() returning BusinessUnits. ```php @method static BusinessUnits businessUnits() ``` -------------------------------- ### tags() annotation Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Trustpilot.md Static method annotation for tags() returning Tags. ```php @method static Tags tags() ``` -------------------------------- ### GET /private/reviews/{reviewId}/tags Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Retrieves the tags associated with a specific review. This endpoint requires a bearer token for authentication. ```APIDOC ## GET /private/reviews/{reviewId}/tags ### Description Retrieves the tags associated with a specific review. ### Method GET ### Endpoint /private/reviews/{reviewId}/tags ### Parameters #### Path Parameters - **reviewId** (string) - Required - The ID of the review. ### Response #### Success Response (200) Returns the list of tags for the review. ``` -------------------------------- ### reviews()->latest() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Retrieves the latest reviews for a business unit. Returns raw decoded JSON response as an array. ```APIDOC ## reviews()->latest() ### Description Retrieves the latest reviews for a business unit. Returns raw decoded JSON response as an array. ### Method reviews()->latest() ### Parameters - **businessUnitId** (string) - Required - The ID of the business unit. ### Response Returns raw decoded JSON response as an array. ``` -------------------------------- ### GET /business-units/{businessUnitId} Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/endpoints.md Retrieve a specific business unit by its ID. The business unit ID can be provided as a path parameter or from the configured default. ```APIDOC ## GET /business-units/{businessUnitId} ### Description Retrieve a specific business unit by its ID. The business unit ID can be provided as a path parameter or from the configured default. ### Method GET ### Endpoint /business-units/{businessUnitId} ### Parameters #### Path Parameters - **businessUnitId** (string) - Required - The ID of the business unit (or use default from config) ### Request Example No request body required. ### Response #### Success Response (200) Returns the business unit details. #### Response Example (No response example provided in source.) ``` -------------------------------- ### get(?string $businessUnitId = null): array Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/BusinessUnits.md Reads a single business unit by its ID. If no ID is provided, it falls back to the configured default business unit ID. ```APIDOC ## [GET] /business-units/{businessUnitId} ### Description Reads a single business unit by its ID. If no ID is provided, it falls back to the configured default business unit ID. ### Method GET ### Endpoint /business-units/{businessUnitId} ### Parameters #### Path Parameters - **businessUnitId** (string) - Optional - Business unit ID; defaults to configured trustpilot.business_unit_id ### Request Example GET /business-units/12345 ### Response #### Success Response (200) - **array** - Decoded JSON response #### Response Example { "id": "12345" } ### Error Handling Throws TrustpilotException on non-2xx response or if no business unit ID is resolvable (statusCode = 0). ``` -------------------------------- ### reviews(): Reviews Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Returns a Reviews resource object sharing this client. Public read methods use the apikey auth mode; private(), reply() and deleteReply() use the bearer token. ```APIDOC ## reviews(): Reviews ### Description Returns a `Reviews` resource object sharing this client. Public read methods use the `apikey` auth mode; `private()`, `reply()` and `deleteReply()` use the bearer token. ### Method reviews ### Endpoint `Trustpilot::reviews()` ### Parameters #### Path Parameters - **— (none)** - Required - No parameters. ### Request Example ```php $latest = Trustpilot::reviews()->latest(5); // public (apikey) $reply = Trustpilot::reviews()->reply('rev-1', 'Thanks'); // private (bearer) ``` ### Response #### Success Response - **Reviews** - See [Reviews.md](Reviews.md). #### Response Example ```php $latest = Trustpilot::reviews()->latest(5); // public (apikey) ``` ``` -------------------------------- ### invitations(): Invitations Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotClient.md Returns an Invitations resource object sharing this client. All its methods are private and require trustpilot.api_secret. ```APIDOC ## invitations(): Invitations ### Description Returns an `Invitations` resource object sharing this client. All its methods are private and require `trustpilot.api_secret`. ### Method invitations ### Endpoint `Trustpilot::invitations()` ### Parameters #### Path Parameters - **— (none)** - Required - No parameters. ### Request Example ```php $invite = Trustpilot::invitations()->create('ada@example.com', 'Ada Lovelace'); ``` ### Response #### Success Response - **Invitations** - See [Invitations.md](Invitations.md). #### Response Example ```php $invite = Trustpilot::invitations()->create('ada@example.com', 'Ada Lovelace'); ``` ``` -------------------------------- ### create() method signature Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Invitations.md Defines the create method for sending email invitations. It accepts consumer email, name, reference, redirect URI, extra attributes, and an optional business unit ID. The attributes array can override or add payload keys like senderEmail, replyTo, or templateId. ```php /** * @param array $attributes extra payload keys such as senderEmail, replyTo or templateId * @return array */ public function create( string $email, string $name, string $reference = '', string $redirectUri = 'https://trustpilot.com', array $attributes = [], ?string $businessUnitId = null, ): array ``` -------------------------------- ### create Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/Invitations.md Creates a new email invitation for a consumer. Sends a POST request to the private business units endpoint with consumer details and optional attributes. ```APIDOC ## [POST] /private/business-units/{businessUnitId}/email-invitations ### Description Creates a new email invitation for a consumer. Sends a POST request to the private business units endpoint with consumer details and optional attributes. ### Method POST ### Endpoint /private/business-units/{businessUnitId}/email-invitations ### Parameters #### Path Parameters - **businessUnitId** (string) - Optional - Business unit id; falls back to `trustpilot.business_unit_id` #### Request Body - **consumerEmail** (string) - Required - Consumer email - **consumerName** (string) - Required - Consumer name - **referenceNumber** (string) - Optional - Order/reference number - **redirectUri** (string) - Optional - Where the consumer lands after the review - **senderEmail** (string) - Optional - Extra payload key (via $attributes) - **replyTo** (string) - Optional - Extra payload key (via $attributes) - **templateId** (string) - Optional - Extra payload key (via $attributes) ### Request Example { "consumerEmail": "ada@example.com", "consumerName": "Ada Lovelace", "referenceNumber": "order-42", "redirectUri": "https://trustpilot.com" } ### Response #### Success Response (200) - **response** (object) - Decoded JSON response (the created invitation) #### Response Example { "id": "invitation-id" } ``` -------------------------------- ### businessUnits()->webLinks() Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/README.md Retrieves web links for a business unit. Returns raw decoded JSON response as an array. ```APIDOC ## businessUnits()->webLinks() ### Description Retrieves web links for a business unit. Returns raw decoded JSON response as an array. ### Method businessUnits()->webLinks() ### Parameters - **businessUnitId** (string) - Required - The ID of the business unit. ### Response Returns raw decoded JSON response as an array. ``` -------------------------------- ### packageRegistered method signature Source: https://github.com/jeffersongoncalves/laravel-trustpilot/blob/main/_autodocs/api-reference/TrustpilotServiceProvider.md Method signature for packageRegistered(): void. Called after package registration to set up container bindings. ```php public function packageRegistered(): void ```