diff --git a/src/Builders/StoreConfigsBuilder.php b/src/Builders/StoreConfigsBuilder.php new file mode 100644 index 0000000..45a7054 --- /dev/null +++ b/src/Builders/StoreConfigsBuilder.php @@ -0,0 +1,38 @@ + + * @author Tran Ngoc Duc + * + * @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; + } +} diff --git a/src/Magento.php b/src/Magento.php index cf101e5..72c9f52 100644 --- a/src/Magento.php +++ b/src/Magento.php @@ -8,13 +8,14 @@ * @author Tran Ngoc Duc * @author Tran Ngoc Duc * - * @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; @@ -48,6 +49,11 @@ 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. * @@ -55,7 +61,7 @@ public static function store_views(): StoreViewsBuilder * @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'), diff --git a/src/Models/StoreConfigs.php b/src/Models/StoreConfigs.php new file mode 100644 index 0000000..6b923b5 --- /dev/null +++ b/src/Models/StoreConfigs.php @@ -0,0 +1,22 @@ + + * @author Tran Ngoc Duc + * + * @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'; +}