Skip to content

Commit

Permalink
feat: after order
Browse files Browse the repository at this point in the history
  • Loading branch information
kaioken committed Dec 23, 2024
1 parent 64248fd commit 612a64b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
50 changes: 50 additions & 0 deletions app/Console/Commands/KanvasVersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@

namespace App\Console\Commands;

use Baka\Traits\KanvasJobsTrait;
use Illuminate\Console\Command;
use Kanvas\Apps\Models\Apps;
use Kanvas\Connectors\Credit700\DataTransferObject\CreditApplicant;
use Kanvas\Connectors\Credit700\Services\CreditScoreService;
use Kanvas\Connectors\Credit700\Support\Setup;
use Kanvas\Enums\AppEnums;
use Kanvas\Guild\Leads\Models\Lead;
use Kanvas\Social\Channels\Models\Channel;
use Kanvas\Souk\Orders\Models\Order;
use Kanvas\SystemModules\Models\SystemModules;

class KanvasVersionCommand extends Command
{
use KanvasJobsTrait;

/**
* The name and signature of the console command.
*
Expand All @@ -34,6 +45,45 @@ public function handle()
$this->info('Kanvas Niche is running version : ' . AppEnums::VERSION->getValue());
$this->newLine();

$app = Apps::getById(78);
$this->overwriteAppService($app);

$order = Order::getById(768);
echo $order->get('message_id');

die();

$leadChannel = Channel::fromApp($app)
->where('entity_id', 24076)
->whereIn('entity_namespace', [Lead::class, SystemModules::getLegacyNamespace(Lead::class)])
->firstOrFail();

print_r($leadChannel);
die();

$setup700Credit = new Setup($app);
$setup700Credit->run();

$lead = Lead::getById(24076);
$people = $lead->people;
$address = $people->address()->first();

$creditApplication = new CreditApplicant(
'Mcintyre S Benjamin', //$people->name,
'718 Jefferson ', //$address->address,
'Fort Wayne', //$address->city,
'AL', //$address->state,
'35080', //$address->zip,
'666271746', //fake()->ssn
);

$creditScoreAction = new CreditScoreService($app);
$creditScore = $creditScoreAction->getCreditScore($creditApplication, $lead->user);

print_r($creditScore);
$lead->addFileFromUrl($creditScore['iframe_url_signed'], 'credit_score_report.pdf');
die();

return;
}
}
12 changes: 12 additions & 0 deletions app/GraphQL/Souk/Mutations/Orders/AppleInAppPurchaseMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Kanvas\Exceptions\ModelNotFoundException;
use Kanvas\Regions\Models\Regions;
use Kanvas\Souk\Orders\Models\Order;
use Kanvas\Workflow\Enums\WorkflowEnum;

class AppleInAppPurchaseMutation
{
Expand Down Expand Up @@ -48,6 +49,17 @@ public function create(mixed $root, array $request): Order
$order->saveCustomFields();
}

/**
* @todo move this to the create order DTO
*/
$order->fireWorkflow(
WorkflowEnum::AFTER_CREATE_ORDER->value,
true,
[
'app' => $app,
]
);

return $order;
}
}
1 change: 1 addition & 0 deletions src/Domains/Workflow/Enums/WorkflowEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum WorkflowEnum: string
case SEARCH = 'search';
case AFTER_PRODUCT_IMPORT = 'after-product-import';
case SYNC_SHOPIFY = 'sync-shopify';
case AFTER_CREATE_ORDER = 'after-create-order';

/**
* Get the enum case by its value.
Expand Down

0 comments on commit 612a64b

Please sign in to comment.