Skip to content

Commit

Permalink
List and show store config
Browse files Browse the repository at this point in the history
  • Loading branch information
caothu159 committed Jul 26, 2024
1 parent d58e4c6 commit 4ed4111
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
38 changes: 38 additions & 0 deletions src/Builders/StoreConfigsBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

/*
* @copyright © 2019 Dxvn, Inc.
*
* @author Tran Ngoc Duc <ductn@diepxuan.com>
* @author Tran Ngoc Duc <caothu91@gmail.com>
*
* @lastupdate 2024-07-26 15:38:19
*/

namespace Diepxuan\Magento\Builders;

use Diepxuan\Magento\Models\StoreConfigs;
use Illuminate\Support\Collection;

class StoreConfigsBuilder extends Builder
{
protected $entity = StoreConfigs::ENTITY;
protected $model = StoreConfigs::class;

protected function parseResponse($response): Collection
{
$fetchedItems = collect($response);
$items = collect([]);

foreach ($fetchedItems as $index => $item) {
/** @var StoreConfigs $model */
$model = new $this->model($this->request, $item);

$items->push($model);
}

return $items;
}
}
10 changes: 8 additions & 2 deletions src/Magento.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
* @author Tran Ngoc Duc <ductn@diepxuan.com>
* @author Tran Ngoc Duc <caothu91@gmail.com>
*
* @lastupdate 2024-07-25 21:22:21
* @lastupdate 2024-07-26 15:45:22
*/

namespace Diepxuan\Magento;

use Diepxuan\Magento\Builders\CategoryBuilder;
use Diepxuan\Magento\Builders\ProductBuilder;
use Diepxuan\Magento\Builders\StoreConfigsBuilder;
use Diepxuan\Magento\Builders\StoreViewsBuilder;
use Diepxuan\Magento\Builders\StoreWebsitesBuilder;
use Diepxuan\Magento\Http\Request;
Expand Down Expand Up @@ -48,14 +49,19 @@ public static function store_views(): StoreViewsBuilder
return new StoreViewsBuilder(self::initOAuthRequest());
}

public static function store_configs(): StoreConfigsBuilder
{
return new StoreConfigsBuilder(self::initOAuthRequest());
}

/**
* Initial OAuth Request.
*
* @param mixed $token
* @param mixed $options
* @param mixed $headers
*/
private static function initOAuthRequest($token = [], $options = [], $headers = [])
private static function initOAuthRequest($token = [], $options = [], $headers = []): Request
{
$base_uri = implode('/', [
config('magento.base_url'),
Expand Down
22 changes: 22 additions & 0 deletions src/Models/StoreConfigs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

/*
* @copyright © 2019 Dxvn, Inc.
*
* @author Tran Ngoc Duc <ductn@diepxuan.com>
* @author Tran Ngoc Duc <caothu91@gmail.com>
*
* @lastupdate 2024-07-26 15:28:07
*/

namespace Diepxuan\Magento\Models;

#[\AllowDynamicProperties]
class StoreConfigs extends Model
{
public const ENTITY = 'store/storeConfigs';
protected $entity = 'store/storeConfigs';
protected $primaryKey = 'id';
}

0 comments on commit 4ed4111

Please sign in to comment.