capeandbay / birdeye
Client-side SDK Package for Laravel that integrates with the BirdEye REST API
Installs: 1 530
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- goldspecdigital/laravel-eloquent-uuid: ^6.0|^7.0|^8.0
- illuminate/support: ~6|~7|~8
- ixudra/curl: ^6.19
Requires (Dev)
- mockery/mockery: ^1.1
- orchestra/testbench: ~3|~4
- phpunit/phpunit: ^8.0
- sempro/phpunit-pretty-print: ^1.0
This package is auto-updated.
Last update: 2024-10-29 06:18:41 UTC
README
BirdEye Service SDK for Laravel
BirdEye helps your business be found and chosen by new customers, be connected with your existing customers, and deliver the best end-to-end customer experience.
This is an implementation of the BirdEye REST API designed to be used with Laravel PHP Framework v6, 7 and beyond.
Cape & Bay is not affiliated with BirdEye. We prefer to build custom packages for our needs, but it may also help you or be a good reference for your own implementation.
Getting Started
Quick Links
Installation
Via Composer
$ composer require capeandbay/birdeye
The package will automatically register itself. You can optionally publish the config file with:
php artisan vendor:publish --provider="CapeAndBay\BirdEye\CBBirdEyeServiceProvider" --tag="config"
The settings can be found in the generated config/birdeye.php
configuration file. .
You can publish the migration with:
php artisan vendor:publish --provider="CapeAndBay\BirdEye\CBBirdEyeServiceProvider" --tag="migrations"
If you need to, update the config, before running the migration.
After publishing the migration you can create the birdeye_businesses
table by running the migrations:
php artisan migrate
Configuration
By default, the package uses the following environment variables to auto-configure the plugin without modification:
BIRDEYE_API_KEY (default = '')
BIRDEYE_PARENT_BUSINESS_KEY (default = '')
BIRDEYE_API_URL (default = 'https://api.birdeye.com/resources') Can be set to their Mock & Debug URLs as per their API
DB_CONNECTION (default = mysql)
<?php return [ 'api_url' => env('BIRDEYE_API_URL','https://api.birdeye.com/resources'), 'deets' => [ 'api_key' => env('BIRDEYE_API_KEY', ''), 'parent_business_id' => env('BIRDEYE_PARENT_BUSINESS_KEY', '') // Leave blank if using multiple accounts ], 'accounts' => [], 'class_maps' => [], ];
Note that you can always swap out preloaded classes with a project's arbitrary own; the package will use that class in that context.
Using Multiple Accounts
To use multiple accounts, leave config('birdeye.deets.parent_business_id)
blank.
Instead, populate config('birdeye.accounts)
like the following example
<?php return [ // Other configs left out for brevity 'accounts' => [ 'client-a' => env('BIRD_EYE_CLIENT_A_KEY', 'something'), 'client-b' => 'some-token' ], ];
Finally, run the cron php artisan birdeye:init
to migrate the child businesses of each parent.
Migrate the Child Business Data
Run the built-in CLI Command to migrate the accounts' child business into the ecosystem
$ php artisan birdeye:init
You can run this command again to add new accounts' child businesses, by adding to the config and running again
Using the Trait
This package is bundle with a simple trait that when coupled with one of your project's
Eloquent models can link to any of the records in the birdeye_businesses
table by
use of an Eloquent relation.
Start by Adding the trait to one of your project's models by including the dependancy and
importing the trait HasBirdEyeBusiness
like so -
<?php namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use CapeAndBay\BirdEye\Traits\HasBirdEyeBusiness; class StoreLocation extends Model { use HasBirdEyeBusiness, SoftDeletes; public $birdeye_id_column = 'some_column'; /** Rest of the Logic assumed */ }
Be sure to include $birdeye_id_column
where 'some_column'
is the foreign key
to birdeye_businesses.internal_id
Note - that in order to complete the relationship you will need to manually
enter the relationship id or roll your own automated method.
This exposes an elequent relation birdeye_business()
that an be used in queries.
To use the trait, peep this example and adapt -
<?php use App\LocationModel; $location = LocationModel::find(1); $birdeye_biz = $location->birdeye_business()->first();
The contents of the BirdEye Business are available to be used with rest of the package Library to ping BirdEye to interface with them!
Usage
Check an EndUser Customer into a business
<?php use App\StoreLocation; //Uses HasBirdEyeBusiness trait attached use CapeAndBay\BirdEye\Facades\BirdEye; $location = StoreLocation::find(1); $business = $location->birdeye_business()->first(); $payload = [ 'name' => 'Some Name', 'emailId' => 'someName@test.com', 'phone' => '5555551212', 'smsEnabled' => '1', ]; $birdeye_customer = BirdEye::get('customer', $business->business_id); $checkin_response = $birdeye_customer->checkin($payload); return $checkin_response;
Change log
Please see the changelog for more information on what has changed recently.
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email angel@capeandbay.com instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.