### Install Laravel Customer.io via Composer Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Install the package via Composer. ```bash composer require jeffersongoncalves/laravel-customer-io ``` -------------------------------- ### Campaign Operations with CustomerIo Facade Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Example usage of the CustomerIo facade for campaign operations: list, get, metrics, and trigger. ```php $campaigns = CustomerIo::campaigns()->list(); $campaign = CustomerIo::campaigns()->get(1); $metrics = CustomerIo::campaigns()->metrics(1); CustomerIo::campaigns()->trigger(1, [ 'emails' => ['jane@example.com'], 'data' => ['coupon' => 'SAVE10'], ]); ``` -------------------------------- ### Customer Operations with CustomerIo Facade Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Example usage of the CustomerIo facade to manage customer profiles: identify, get, delete, and track events. ```php use JeffersonGoncalves\CustomerIo\Facades\CustomerIo; // Create or update a customer profile (Track API) CustomerIo::customers()->identify('123', [ 'email' => 'jane@example.com', 'first_name' => 'Jane', 'plan' => 'premium', ]); // Fetch a customer's attributes (App API) $customer = CustomerIo::customers()->get('123'); // Delete a customer (Track API) CustomerIo::customers()->delete('123'); // Track a custom event (Track API) CustomerIo::customers()->trackEvent('123', 'purchase', ['amount' => 42]); ``` -------------------------------- ### GET /api/v1/campaigns Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Lists all campaigns using the App API. ```APIDOC ## [GET] /api/v1/campaigns ### Description Lists all campaigns using the App API. ### Method GET ### Endpoint /api/v1/campaigns ### Response #### Success Response (200) Returns a list of campaigns. #### Response Example [ { "id": 1, "name": "Welcome Campaign" } ] ``` -------------------------------- ### Handle CustomerIoException Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Example of error handling: catching CustomerIoException and logging the error message and body. ```php use JeffersonGoncalves\CustomerIo\Exceptions\CustomerIoException; try { CustomerIo::customers()->identify('123', ['email' => 'not-an-email']); } catch (CustomerIoException $e) { logger()->error($e->getMessage(), $e->errorBody()); } ``` -------------------------------- ### GET /api/v1/campaigns/{id} Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Fetches a specific campaign using the App API. ```APIDOC ## [GET] /api/v1/campaigns/{id} ### Description Fetches a specific campaign using the App API. ### Method GET ### Endpoint /api/v1/campaigns/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The campaign identifier. ### Response #### Success Response (200) Returns the campaign details. #### Response Example { "id": 1, "name": "Welcome Campaign" } ``` -------------------------------- ### GET /api/v1/customers/{id} Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Fetches a customer's attributes using the App API. ```APIDOC ## [GET] /api/v1/customers/{id} ### Description Fetches a customer's attributes using the App API. ### Method GET ### Endpoint /api/v1/customers/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The customer identifier. ### Response #### Success Response (200) Returns the customer's attributes. #### Response Example { "id": "123", "email": "jane@example.com", "first_name": "Jane", "plan": "premium" } ``` -------------------------------- ### Send Transactional Email with CustomerIo Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Example usage of the CustomerIo facade for transactional messaging: send an email. ```php CustomerIo::transactional()->sendEmail([ 'transactional_message_id' => '5', 'to' => 'jane@example.com', 'identifiers' => ['id' => '123'], 'message_data' => ['name' => 'Jane'], ]); ``` -------------------------------- ### GET /api/v1/campaigns/{id}/metrics Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Fetches metrics for a specific campaign using the App API. ```APIDOC ## [GET] /api/v1/campaigns/{id}/metrics ### Description Fetches metrics for a specific campaign using the App API. ### Method GET ### Endpoint /api/v1/campaigns/{id}/metrics ### Parameters #### Path Parameters - **id** (integer) - Required - The campaign identifier. ### Response #### Success Response (200) Returns campaign metrics. #### Response Example { "sent": 100, "delivered": 95, "opened": 50 } ``` -------------------------------- ### Publish Customer.io Config File Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Publish the package configuration file. ```bash php artisan vendor:publish --tag=customer-io-config ``` -------------------------------- ### Customer.io Configuration File Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Configuration file for the package, defining the site ID, API keys, and base URLs for the Track and App APIs. ```php // config/customer-io.php return [ 'site_id' => env('CUSTOMERIO_SITE_ID', ''), 'api_key' => env('CUSTOMERIO_API_KEY', ''), 'app_key' => env('CUSTOMERIO_APP_KEY', ''), 'track_url' => env('CUSTOMERIO_TRACK_URL', 'https://track.customer.io/api/v1'), 'app_url' => env('CUSTOMERIO_APP_URL', 'https://api.customer.io/v1'), ]; ``` -------------------------------- ### Configure Customer.io Environment Variables Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Set Customer.io credentials in the .env file. The site ID and Track API key are found under Settings > Account Settings > API Credentials. The App API key is created under Settings > API Credentials > App API Keys. ```env CUSTOMERIO_SITE_ID=your-site-id CUSTOMERIO_API_KEY=your-track-api-key CUSTOMERIO_APP_KEY=your-app-api-key ``` -------------------------------- ### Run Tests with Composer Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Run the package test suite. ```bash composer test ``` -------------------------------- ### POST /api/v1/customers/{id} Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Creates or updates a customer profile using the Track API. ```APIDOC ## [POST] /api/v1/customers/{id} ### Description Creates or updates a customer profile using the Track API. ### Method POST ### Endpoint /api/v1/customers/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The customer identifier. #### Request Body - **email** (string) - Optional - The customer's email address. - **first_name** (string) - Optional - The customer's first name. - **plan** (string) - Optional - The customer's plan. ### Request Example { "email": "jane@example.com", "first_name": "Jane", "plan": "premium" } ### Response #### Success Response (200) No response body is returned on success. #### Response Example {} ``` -------------------------------- ### POST /api/v1/customers/{id}/events Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Tracks a custom event for a customer using the Track API. ```APIDOC ## [POST] /api/v1/customers/{id}/events ### Description Tracks a custom event for a customer using the Track API. ### Method POST ### Endpoint /api/v1/customers/{id}/events ### Parameters #### Path Parameters - **id** (string) - Required - The customer identifier. #### Request Body - **name** (string) - Required - The event name. - **data** (object) - Optional - Additional event data. ### Request Example { "name": "purchase", "data": { "amount": 42 } } ### Response #### Success Response (200) No response body is returned on success. #### Response Example {} ``` -------------------------------- ### POST /api/v1/transactional Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Sends a transactional email using the App API. ```APIDOC ## [POST] /api/v1/transactional ### Description Sends a transactional email using the App API. ### Method POST ### Endpoint /api/v1/transactional ### Parameters #### Request Body - **transactional_message_id** (string) - Required - The transactional message identifier. - **to** (string) - Required - The recipient email address. - **identifiers** (object) - Optional - Customer identifiers. - **message_data** (object) - Optional - Data to populate the message template. ### Request Example { "transactional_message_id": "5", "to": "jane@example.com", "identifiers": { "id": "123" }, "message_data": { "name": "Jane" } } ### Response #### Success Response (200) No response body is returned on success. #### Response Example {} ``` -------------------------------- ### DELETE /api/v1/customers/{id} Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Deletes a customer using the Track API. ```APIDOC ## [DELETE] /api/v1/customers/{id} ### Description Deletes a customer using the Track API. ### Method DELETE ### Endpoint /api/v1/customers/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The customer identifier. ### Response #### Success Response (200) No response body is returned on success. #### Response Example {} ``` -------------------------------- ### POST /api/v1/campaigns/{id}/triggers Source: https://github.com/jeffersongoncalves/laravel-customer-io/blob/main/README.md Triggers a campaign for specific recipients using the App API. ```APIDOC ## [POST] /api/v1/campaigns/{id}/triggers ### Description Triggers a campaign for specific recipients using the App API. ### Method POST ### Endpoint /api/v1/campaigns/{id}/triggers ### Parameters #### Path Parameters - **id** (integer) - Required - The campaign identifier. #### Request Body - **emails** (array of strings) - Required - List of recipient email addresses. - **data** (object) - Optional - Additional data to pass to the campaign. ### Request Example { "emails": ["jane@example.com"], "data": { "coupon": "SAVE10" } } ### Response #### Success Response (200) No response body is returned on success. #### Response Example {} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.