Skip to content

Commit

Permalink
CustomerGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
kg-bot committed Mar 22, 2019
1 parent c2968ad commit 09c7789
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/Builders/CustomerGroupBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Created by PhpStorm.
* User: nts
* Date: 19.4.18.
* Time: 01.32
*/

namespace KgBot\Magento\Builders;


use KgBot\Magento\Models\CustomerGroup;

class CustomerGroupBuilder extends Builder
{
protected $entity = 'customerGroups';
protected $model = CustomerGroup::class;

public function get( $filters = [] )
{
$urlFilters = $this->parseFilters( $filters );

return $this->request->handleWithExceptions( function () use ( $urlFilters ) {

$response = $this->request->client->get( "{$this->entity}/search{$urlFilters}" );
$responseData = json_decode( (string) $response->getBody() );
$items = $this->parseResponse( $responseData );

return $items;
} );
}
}
10 changes: 10 additions & 0 deletions src/Magento.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace KgBot\Magento;

use KgBot\Magento\Builders\CustomerBuilder;
use KgBot\Magento\Builders\CustomerGroupBuilder;
use KgBot\Magento\Builders\OrderBuilder;
use KgBot\Magento\Builders\ProductBuilder;
use KgBot\Magento\Utils\Request;
Expand Down Expand Up @@ -65,4 +66,13 @@ public function products()
{
return new ProductBuilder( $this->request );
}

/**
* @return \KgBot\Magento\Builders\CustomerGroupBuilder
*/
public function customer_groups()
{

return new CustomerGroupBuilder( $this->request );
}
}
18 changes: 18 additions & 0 deletions src/Models/CustomerGroup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Created by PhpStorm.
* User: nts
* Date: 19.4.18.
* Time: 01.30
*/

namespace KgBot\Magento\Models;


use KgBot\Magento\Utils\Model;

class CustomerGroup extends Model
{
protected $entity = 'customerGroups';
protected $primaryKey = 'id';
}

0 comments on commit 09c7789

Please sign in to comment.