forked from Vugario/External-Services
-
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.
App installation process with external services creation
- Loading branch information
Menno
committed
May 27, 2015
1 parent
8fcbec8
commit c91e914
Showing
25 changed files
with
363 additions
and
16 deletions.
There are no files selected for viewing
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
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
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
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
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,71 @@ | ||
<?php namespace App\libraries; | ||
|
||
use Illuminate\Support\Facades\Auth; | ||
|
||
class Webshop extends \WebshopappApiClient | ||
{ | ||
protected static $instance; | ||
|
||
public function __construct() | ||
{ | ||
$config = config('services.seoshop'); | ||
|
||
return parent::__construct($config['env'], $config['key'], md5(Auth::user()->token . $config['secret']), Auth::user()->language); | ||
} | ||
|
||
public static function instance() | ||
{ | ||
if (self::$instance) | ||
{ | ||
return self::$instance; | ||
} | ||
|
||
return self::$instance = new self(); | ||
} | ||
|
||
/** | ||
* This method will fetch the current external services | ||
* If these do not exist yet it will create them | ||
*/ | ||
public function installExternalServices() | ||
{ | ||
$currentServices = Webshop::instance()->external_services->get(); | ||
|
||
$hasShipmentService = false; | ||
$hasPaymentService = false; | ||
|
||
foreach ($currentServices as $currentService) | ||
{ | ||
if ($currentService['type'] == 'shipment') | ||
{ | ||
$hasShipmentService = true; | ||
} | ||
|
||
if ($currentService['type'] == 'payment') | ||
{ | ||
$hasPaymentService = true; | ||
} | ||
} | ||
|
||
if ($hasShipmentService === false) | ||
{ | ||
Webshop::instance()->external_services->create([ | ||
'type' => 'shipment', | ||
'name' => 'SEOshop Shipments', | ||
'urlEndpoint' => url('/', [], true), | ||
'rateEstimate' => true, | ||
'isActive' => true | ||
]); | ||
} | ||
|
||
if ($hasPaymentService === false) | ||
{ | ||
Webshop::instance()->external_services->create([ | ||
'type' => 'payment', | ||
'name' => 'SEOshop Payments', | ||
'urlEndpoint' => url('/', [], true), | ||
'isActive' => true | ||
]); | ||
} | ||
} | ||
} |
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,14 @@ | ||
<?php namespace App; | ||
|
||
use Illuminate\Auth\Authenticatable; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; | ||
|
||
class Shop extends Model implements AuthenticatableContract { | ||
|
||
use Authenticatable; | ||
|
||
protected $table = 'shops'; | ||
|
||
protected $fillable = ['shop_id']; | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
35 changes: 35 additions & 0 deletions
35
database/migrations/2015_05_27_194139_create_shops_table.php
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,35 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateShopsTable extends Migration { | ||
|
||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('shops', function(Blueprint $table) | ||
{ | ||
$table->increments('id'); | ||
$table->integer('shop_id'); | ||
$table->string('token'); | ||
$table->string('language'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::drop('shops'); | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.