Skip to content

phpdevkits/ortto-sdk

Repository files navigation

Ortto SDK for Laravel

A modern, elegant Laravel SDK for the Ortto Customer Data Platform API. Built on top of Saloon, this package provides a fluent interface to interact with Ortto's REST API.

Features

  • Full Ortto API coverage (People, Activities, Campaigns, and more)
  • Built with Saloon for robust HTTP communication
  • Laravel integration via service provider
  • Type-safe requests and responses
  • Comprehensive test coverage
  • Modern PHP 8.4+ syntax

Requirements

  • PHP 8.4 or higher
  • Laravel 10.x or 11.x

Installation

Install the package via Composer:

composer require phpdevkits/ortto-sdk

Publish the configuration file:

php artisan vendor:publish --provider="PhpDevKits\Ortto\OrttoServiceProvider"

Add your Ortto API credentials to your .env file:

ORTTO_API_KEY=your-api-key-here
ORTTO_REGION=ap3  # Options: ap3 (default), au, eu

Configuration

The configuration file will be published to config/ortto.php:

return [
    'api_key' => env('ORTTO_API_KEY'),
    'region' => env('ORTTO_REGION', 'ap3'),
];

Service Endpoints

Ortto uses region-specific endpoints:

  • Default (AP3): https://api.ap3api.com/ - For most Ortto users
  • Australia: https://api.au1api.com/ - For AU region instances
  • Europe: https://api.eu1api.com/ - For EU region instances

Usage

People Management

use PhpDevKits\Ortto\Facades\Ortto;

// Create or update a person
Ortto::people()->merge([
    'email' => 'user@example.com',
    'first_name' => 'John',
    'last_name' => 'Doe',
]);

// Get a person by email
$person = Ortto::people()->get('user@example.com');

// Delete a person
Ortto::people()->delete('user@example.com');

Activities

// Track a custom activity
Ortto::activities()->create([
    'email' => 'user@example.com',
    'activity_name' => 'product_viewed',
    'attributes' => [
        'product_id' => '12345',
        'product_name' => 'Premium Widget',
    ],
]);

Campaigns

// Send a campaign email
Ortto::campaigns()->send([
    'campaign_id' => 'your-campaign-id',
    'recipients' => [
        ['email' => 'user@example.com'],
    ],
]);

Documentation

Browse the docs/ directory for detailed documentation:

API Reference

For detailed information about Ortto's API endpoints and parameters, refer to the Ortto API Documentation.

Development

Clone the repository and install dependencies:

git clone https://github.com/phpdevkits/ortto-sdk.git
cd ortto-sdk
composer install

Code Quality

Keep a modern codebase with Pint:

composer lint

Run refactors using Rector:

composer refactor

Run static analysis using PHPStan:

composer test:types

Run unit tests using PEST:

composer test:unit

Run the entire test suite:

composer test

Testing

The package includes comprehensive test coverage using PEST and Lawman for architecture testing:

composer test

Learn more about testing in our Testing Documentation.

Changelog

Please see CHANGELOG for recent changes.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email security@example.com instead of using the issue tracker.

Credits

This package is built with modern PHP tools and frameworks:

  • Laravel - The PHP framework for web artisans
  • Saloon - Build beautiful API integrations
  • Pest PHP - An elegant PHP testing framework
  • Lawman - Architecture testing for Saloon
  • PHPStan - PHP static analysis tool
  • Laravel Pint - PHP code style fixer
  • Rector - Instant upgrades and automated refactoring

Special thanks to:

License

The MIT License (MIT). Please see License File for more information.

About

PHP Ortto SDK

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages