Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Braybrooke committed Aug 7, 2020
0 parents commit a5dbca0
Show file tree
Hide file tree
Showing 41 changed files with 1,480 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
30 changes: 30 additions & 0 deletions README.md
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.
29 changes: 29 additions & 0 deletions composer.json
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"
}
}
}
}
7 changes: 7 additions & 0 deletions config/snscommunicationrecords.php
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 added database/.DS_Store
Binary file not shown.
Binary file added database/migrations/.DS_Store
Binary file not shown.
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');
}
}
13 changes: 13 additions & 0 deletions routes/api.php
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');
15 changes: 15 additions & 0 deletions routes/web.php
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 added src/.DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions src/Concerns/LogAsEmail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace PurpleMountain\SNSCommunicationRecords\Concerns;

interface LogAsEmail
{
//
}
8 changes: 8 additions & 0 deletions src/Concerns/LogAsMarketing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace PurpleMountain\SNSCommunicationRecords\Concerns;

interface LogAsMarketing
{
//
}
8 changes: 8 additions & 0 deletions src/Concerns/LogAsPhone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace PurpleMountain\SNSCommunicationRecords\Concerns;

interface LogAsPhone
{
//
}
8 changes: 8 additions & 0 deletions src/Concerns/LogAsSMS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace PurpleMountain\SNSCommunicationRecords\Concerns;

interface LogAsSMS
{
//
}
8 changes: 8 additions & 0 deletions src/Concerns/LogAsTransactional.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace PurpleMountain\SNSCommunicationRecords\Concerns;

interface LogAsTransactional
{
//
}
8 changes: 8 additions & 0 deletions src/Concerns/LogNotification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace PurpleMountain\SNSCommunicationRecords\Concerns;

interface LogNotification
{
//
}
44 changes: 44 additions & 0 deletions src/Events/SNSCommunicationBounced.php
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');
}
}
44 changes: 44 additions & 0 deletions src/Events/SNSCommunicationClicked.php
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');
}
}
44 changes: 44 additions & 0 deletions src/Events/SNSCommunicationComplaint.php
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');
}
}
44 changes: 44 additions & 0 deletions src/Events/SNSCommunicationDelivered.php
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');
}
}
Loading

0 comments on commit a5dbca0

Please sign in to comment.