Skip to content

Commit

Permalink
Angaza shs plugin (#19)
Browse files Browse the repository at this point in the history
* angaza plugin created.

* fix tailtag bug

* (CodeQuality) linting

---------

Co-authored-by: Kemal <[email protected]>
  • Loading branch information
InensusDev and alchalade authored Jan 18, 2024
1 parent 5af56ba commit 8368c9c
Show file tree
Hide file tree
Showing 42 changed files with 971 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Website/htdocs/mpmanager/app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Inensus\SunKingSHS\Console\Commands\InstallPackage as InstallSunKingSHSPackage;
use Inensus\GomeLongMeter\Console\Commands\InstallPackage as InstallGomeLongMeterPackage;
use Inensus\WavecomPaymentProvider\Console\Commands\InstallPackage as InstallWaveComPackage;
use Inensus\AngazaSHS\Console\Commands\InstallPackage as InstallAngazaSHSPackage;
use Inensus\DalyBms\Console\Commands\InstallPackage as InstallDalyBmsPackage;

class Kernel extends ConsoleKernel
Expand Down Expand Up @@ -46,6 +47,7 @@ class Kernel extends ConsoleKernel
InstallSunKingSHSPackage::class,
InstallGomeLongMeterPackage::class,
InstallWaveComPackage::class,
InstallAngazaSHSPackage::class,
InstallDalyBmsPackage::class,
];

Expand Down
1 change: 1 addition & 0 deletions Website/htdocs/mpmanager/app/Models/MpmPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MpmPlugin extends MasterModel
public const GOME_LONG_METERS = 14;
public const WAVECOM_PAYMENT_PROVIDER = 15;
public const DALY_BMS = 16;
public const AGAZA_SHS = 17;

protected $table = 'mpm_plugins';

Expand Down
3 changes: 2 additions & 1 deletion Website/htdocs/mpmanager/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
"Inensus\\SunKingSHS\\": "packages/inensus/sun-king-shs/src",
"Inensus\\GomeLongMeter\\": "packages/inensus/gome-long-meter/src",
"Inensus\\WavecomPaymentProvider\\": "packages/inensus/wavecom-payment-provider/src",
"Inensus\\DalyBms\\": "packages/inensus/daly-bms/src"
"Inensus\\DalyBms\\": "packages/inensus/daly-bms/src",
"Inensus\\AngazaSHS\\": "packages/inensus/angaza-shs/src"
}
},
"minimum-stability": "dev",
Expand Down
1 change: 1 addition & 0 deletions Website/htdocs/mpmanager/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
\Inensus\SunKingSHS\Providers\SunKingSHSServiceProvider::class,
\Inensus\GomeLongMeter\Providers\GomeLongMeterServiceProvider::class,
\Inensus\WavecomPaymentProvider\Providers\WavecomPaymentProviderServiceProvider::class,
\Inensus\AngazaSHS\Providers\AngazaSHSServiceProvider::class,
\Inensus\DalyBms\Providers\DalyBmsServiceProvider::class

],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ public function run()
'installation_command' => 'daly-bms:install',
'root_class' => 'DalyBms'
],
[
'name' => 'AngazaSHS',
'description' => 'This plugin integrates Angaza solar home systems to Micropowermanager. It uses client_id & client_secret for creating tokens for energy.',
'tail_tag' => 'Angaza SHS',
'installation_command' => 'angaza-shs:install',
'root_class' => 'AngazaSHS'
]
)
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
21 changes: 21 additions & 0 deletions Website/htdocs/mpmanager/packages/inensus/angaza-shs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Inensus

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions Website/htdocs/mpmanager/packages/inensus/angaza-shs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Package-Development-Starter-Pack

#### Starter pack for package development to MicroPowerManager.

- This repo has created by the MicroPowerManager development team for developers who will develop a new package for MicroPowerManager.
- The team suggests developers use this repo when they decide to develop new packages to MicroPowerManager.
- Developers should clone our `Core` project with this url `https://github.com/inensus/MPManager` first. After cloning and running the core project, They have to go into laravel container and navigate to mpmanager & run `php artisan micropowermanager:new-package {{package-name}}` command to clone `this repo` into packages folder in MicroPowerManager core project.
- After cloning Package-Development-Starter-Pack, developers can keep developing the package inside of core project.
- When the developing will have been finished they can upload their packages to `https://packagist.org/` for the other developers usage




27 changes: 27 additions & 0 deletions Website/htdocs/mpmanager/packages/inensus/angaza-shs/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "inensus/angaza-shs",
"description": "Angaza SHS integration for Micropowermanager",
"type": "package",
"require": {},
"license": "MIT",
"authors": [
{
"name": "kamuran engin",
"email": "[email protected]",
"role": "Developer"
}
],
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"Inensus\\AngazaSHS\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"AngazaSHSServiceProvider"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [

];
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

class CreateAngazaTables extends Migration
{
public function up()
{
if (!Schema:: hasTable('angaza_api_credentials')) {
Schema::create('angaza_api_credentials', static function (Blueprint $table) {
$table->increments('id');
$table->string('api_url')->default('https://payg.angazadesign.com/nexus/v1');
$table->string('client_id')->nullable();
$table->string('client_secret')->nullable();
$table->timestamps();
});
}
if (!Schema:: hasTable('angaza_transactions')) {
Schema::create('angaza_transactions', static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
});
}
}

public function down()
{
Schema::dropIfExists('angaza_api_credentials');
Schema::dropIfExists('angaza_transactions');

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
namespace Inensus\AngazaSHS\Console\Commands;

use Illuminate\Console\Command;
use Inensus\AngazaSHS\Services\AngazaCredentialService;
use Inensus\AngazaSHS\Services\ManufacturerService;
use Inensus\AngazaSHS\Services\MenuItemService;

class InstallPackage extends Command
{
protected $signature = 'angaza-shs:install';
protected $description = 'Install AngazaSHS Package';

public function __construct(
private MenuItemService $menuItemService,
private ManufacturerService $manufacturerService,
private AngazaCredentialService $credentialService
) {
parent::__construct();
}
public function handle(): void
{
$this->info('Installing AngazaSHS Integration Package\n');
$this->manufacturerService->register();
$this->credentialService->createCredentials();
$this->info('Package installed successfully..');
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Inensus\AngazaSHS\Exceptions;

class AngazaApiResponseException extends \Exception
{
public function __construct($message)
{
parent::__construct($message);
}
}

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Inensus\AngazaSHS\Http\Controllers;

use Illuminate\Routing\Controller;
use Inensus\AngazaSHS\Http\Requests\AngazaCredentialRequest;
use Inensus\AngazaSHS\Http\Resources\AngazaResource;
use Inensus\AngazaSHS\Services\AngazaCredentialService;


class AngazaCredentialController extends Controller
{

public function __construct(private AngazaCredentialService $credentialService)
{
}

public function show(): AngazaResource
{
return AngazaResource::make($this->credentialService->getCredentials());
}

public function update(AngazaCredentialRequest $request): AngazaResource
{
$credentials = $this->credentialService->getCredentials();
$updateData = $request->only([
'client_id',
'client_secret'
]);
$credentials = $this->credentialService->updateCredentials($credentials, $updateData);

return AngazaResource::make($credentials);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php


namespace Inensus\AngazaSHS\Http\Requests;


use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class AngazaCredentialRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
*
* @return array
*/
public function rules()
{
return [
'client_id' => ['required'],
'client_secret' => ['required'],
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php


namespace Inensus\AngazaSHS\Http\Resources;


use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class AngazaResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Inensus\AngazaSHS\Models;

use App\Models\BaseModel;

class AngazaCredential extends BaseModel
{

protected $table = 'angaza_api_credentials';

public function getClientSecret()
{
return $this->client_secret;
}
public function getClientId()
{
return $this->client_id;
}

public function getApiUrl()
{
return $this->api_url;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Inensus\AngazaSHS\Models;

use App\Models\BaseModel;

class AngazaTransaction extends BaseModel
{
protected $table = 'angaza_transactions';
}
Loading

0 comments on commit 8368c9c

Please sign in to comment.