-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christian Braybrooke
committed
Aug 7, 2020
0 parents
commit a5dbca0
Showing
41 changed files
with
1,480 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Laravel Zoho | ||
A lightweight (for now) wrapper around the Zoho PHP SDK | ||
|
||
## Installation | ||
|
||
``` | ||
composer require purplemountain/laravel-zoho | ||
``` | ||
|
||
## Setup | ||
1. If you haven't already, you need to create an Oauth2 client within Zoho. This can be done [here](https://api-console.zoho.com/). | ||
|
||
2. You want to choose a "Server-based Application" client within Zoho. | ||
|
||
3. For the "Authorized Redirect URIs" entry, you need to add `your-app-domain.tld/oauth/zoho`. Don't worry we handle this route for you within your app. | ||
|
||
## Env | ||
You will need to add the following details to your `.env` file and paste in the values from Zoho. | ||
|
||
``` | ||
ZOHO_CLIENT_ID= | ||
ZOHO_CLIENT_SECRET= | ||
ZOHO_USER_EMAIL= | ||
``` | ||
|
||
## Authorization | ||
You need to authorize your app to access Zoho. You can do this by simply running `php artisan zoho:url` which will generate the url to authorize the app. Follow the prompts and you'll be be all set. | ||
|
||
## Refreshing Tokens | ||
Zoho tokens last for aprox 1 hour. To refresh the token using the refresh token provided, you can run `php artisan zoho:refresh`. We reccomend setting this up to be run every 5 minutes in your `App\Console\Kernel.php` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "purplemountain/sns-communication-records", | ||
"description": "Store records of communications through AWS sns.", | ||
"authors": [ | ||
{ | ||
"name": "Christian Braybrooke", | ||
"email": "chris@purplemountmedia.com" | ||
} | ||
], | ||
"require": { | ||
"aws/aws-php-sns-message-validator": "^1.6", | ||
"aws/aws-sdk-php": "^3.147" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"PurpleMountain\\SNSCommunicationRecords\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"PurpleMountain\\SNSCommunicationRecords\\ServiceProvider" | ||
], | ||
"aliases": { | ||
"SNSCommunicationRecords": "PurpleMountain\\SNSCommunicationRecords\\Facade" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return [ | ||
'record_class' => PurpleMountain\SNSCommunicationRecords\Models\SNSCommunicationRecord::class, | ||
|
||
'to_class' => App\User::class | ||
]; |
Binary file not shown.
Binary file not shown.
54 changes: 54 additions & 0 deletions
54
database/migrations/2020_08_01_130327_create_sns_communication_records_table.php.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateSNSCommunicationRecordsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('sns_communication_records', function (Blueprint $table) { | ||
$table->uuid('id')->primary(); | ||
$table->string('channel_id')->nullable()->default(null); | ||
$table->string('internal_ref')->nullable()->default(null); | ||
$table->string('internal_id')->nullable()->default(null); | ||
$table->uuid('to_id')->nullable()->default(null); | ||
$table->string('to_type')->nullable()->default(null); | ||
$table->string('from')->nullable()->default(null); | ||
$table->string('bcc')->nullable()->default(null); | ||
$table->string('cc')->nullable()->default(null); | ||
$table->string('reply_to')->nullable()->default(null); | ||
$table->string('content_type')->nullable()->default(null); | ||
$table->string('type'); | ||
$table->integer('priority')->nullable()->default(null); | ||
$table->string('name')->nullable(); | ||
$table->string('subject')->nullable(); | ||
$table->longText('content')->nullable()->default(null); | ||
$table->dateTime('sent_at')->nullable()->default(null); | ||
$table->dateTime('delivered_at')->nullable()->default(null); | ||
$table->dateTime('read_at')->nullable()->default(null); | ||
$table->dateTime('clicked_at')->nullable()->default(null); | ||
$table->dateTime('bounced_at')->nullable()->default(null); | ||
$table->dateTime('complaint_at')->nullable()->default(null); | ||
$table->dateTime('rejected_at')->nullable()->default(null); | ||
$table->json('extra')->nullable()->default(null); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('sns_communication_records'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Package Api Routes | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here is where you can register api routes for your application. These | ||
| routes are loaded by the RouteServiceProvider within a group which | ||
| contains the "api" middleware group. | ||
| | ||
*/ | ||
Route::middleware('auth:api')->get('communication-records', 'SNSCommunicationRecordsController'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Package Web Routes | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here is where you can register web routes for your application. These | ||
| routes are loaded by the RouteServiceProvider within a group which | ||
| contains the "web" middleware group. | ||
| | ||
*/ | ||
Route::name('webhooks.')->prefix('webhooks')->group(function () { | ||
Route::post('sns', 'SNSCommunicationsWebhookController')->name('sns'); | ||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace PurpleMountain\SNSCommunicationRecords\Concerns; | ||
|
||
interface LogAsEmail | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace PurpleMountain\SNSCommunicationRecords\Concerns; | ||
|
||
interface LogAsMarketing | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace PurpleMountain\SNSCommunicationRecords\Concerns; | ||
|
||
interface LogAsPhone | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace PurpleMountain\SNSCommunicationRecords\Concerns; | ||
|
||
interface LogAsSMS | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace PurpleMountain\SNSCommunicationRecords\Concerns; | ||
|
||
interface LogAsTransactional | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace PurpleMountain\SNSCommunicationRecords\Concerns; | ||
|
||
interface LogNotification | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace PurpleMountain\SNSCommunicationRecords\Events; | ||
|
||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
use PurpleMountain\SNSCommunicationRecords\Models\SNSCommunicationRecord; | ||
|
||
class SNSCommunicationBounced implements ShouldBroadcast | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
/** | ||
* The SNS communication record model. | ||
* | ||
* @var \PurpleMountain\SNSCommunicationRecords\Models\SNSCommunicationRecord | ||
*/ | ||
protected $snsCommunicationRecord; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(SNSCommunicationRecord $snsCommunicationRecord) | ||
{ | ||
$this->snsCommunicationRecord = $snsCommunicationRecord; | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return \Illuminate\Broadcasting\Channel|array | ||
*/ | ||
public function broadcastOn() | ||
{ | ||
return new PrivateChannel('sns-communication-records'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace PurpleMountain\SNSCommunicationRecords\Events; | ||
|
||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
use PurpleMountain\SNSCommunicationRecords\Models\SNSCommunicationRecord; | ||
|
||
class SNSCommunicationClicked | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
/** | ||
* The SNS communication record model. | ||
* | ||
* @var \PurpleMountain\SNSCommunicationRecords\Models\SNSCommunicationRecord | ||
*/ | ||
protected $snsCommunicationRecord; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(SNSCommunicationRecord $snsCommunicationRecord) | ||
{ | ||
$this->snsCommunicationRecord = $snsCommunicationRecord; | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return \Illuminate\Broadcasting\Channel|array | ||
*/ | ||
public function broadcastOn() | ||
{ | ||
return new PrivateChannel('sns-communication-records'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace PurpleMountain\SNSCommunicationRecords\Events; | ||
|
||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
use PurpleMountain\SNSCommunicationRecords\Models\SNSCommunicationRecord; | ||
|
||
class SNSCommunicationComplaint | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
/** | ||
* The SNS communication record model. | ||
* | ||
* @var \PurpleMountain\SNSCommunicationRecords\Models\SNSCommunicationRecord | ||
*/ | ||
protected $snsCommunicationRecord; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(SNSCommunicationRecord $snsCommunicationRecord) | ||
{ | ||
$this->snsCommunicationRecord = $snsCommunicationRecord; | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return \Illuminate\Broadcasting\Channel|array | ||
*/ | ||
public function broadcastOn() | ||
{ | ||
return new PrivateChannel('sns-communication-records'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace PurpleMountain\SNSCommunicationRecords\Events; | ||
|
||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
use PurpleMountain\SNSCommunicationRecords\Models\SNSCommunicationRecord; | ||
|
||
class SNSCommunicationDelivered | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
/** | ||
* The SNS communication record model. | ||
* | ||
* @var \PurpleMountain\SNSCommunicationRecords\Models\SNSCommunicationRecord | ||
*/ | ||
protected $snsCommunicationRecord; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(SNSCommunicationRecord $snsCommunicationRecord) | ||
{ | ||
$this->snsCommunicationRecord = $snsCommunicationRecord; | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return \Illuminate\Broadcasting\Channel|array | ||
*/ | ||
public function broadcastOn() | ||
{ | ||
return new PrivateChannel('sns-communication-records'); | ||
} | ||
} |
Oops, something went wrong.