-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add customerproductvisibilities endpoint
- Loading branch information
Showing
10 changed files
with
641 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
examples/customerproductvisibilities/create_customerproductvisibility.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
try { | ||
require "../initialize.php"; | ||
|
||
$customerproductvisibility = $oro->customerproductvisibilities->create([ | ||
'data' => [ | ||
'type' => 'customerproductvisibilities', | ||
'attributes' => [ | ||
'visibility' => 'visible', | ||
], | ||
'relationships' => [ | ||
'product' => [ | ||
'data' => [ | ||
'type' => 'products', | ||
'id' => '1', | ||
], | ||
], | ||
'customer' => [ | ||
'data' => [ | ||
'type' => 'customers', | ||
'id' => '1', | ||
], | ||
], | ||
'website' => [ | ||
'data' => [ | ||
'type' => 'websites', | ||
'id' => '1', | ||
], | ||
], | ||
], | ||
], | ||
]); | ||
|
||
echo "<p>Customerproductvisibilty created: $customerproductvisibility->id</p>"; | ||
} catch (\Digitalprint\Oro\Api\Exceptions\ApiException $e) { | ||
echo "API call failed: " . $e->getMessage(); | ||
} |
10 changes: 10 additions & 0 deletions
10
examples/customerproductvisibilities/delete_customerproductvisibility.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
try { | ||
require "../initialize.php"; | ||
|
||
$customerproductvisibility = $oro->customerproductvisibilities->get('1-1-1')->delete(); | ||
echo "<p>Customerproductvisibility deleted</p>"; | ||
} catch (\Digitalprint\Oro\Api\Exceptions\ApiException $e) { | ||
echo "API call failed: " . $e->getMessage(); | ||
} |
15 changes: 15 additions & 0 deletions
15
examples/customerproductvisibilities/get_customerproductvisibility.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
try { | ||
require "../initialize.php"; | ||
|
||
$customerproductvisibility = $oro->customerproductvisibilities->get('1-1-1'); | ||
|
||
echo "<b>$customerproductvisibility->type $customerproductvisibility->id</b><br>"; | ||
foreach ($customerproductvisibility->attributes as $key => $val) { | ||
echo "$key: $val<br>"; | ||
} | ||
|
||
} catch (\Digitalprint\Oro\Api\Exceptions\ApiException $e) { | ||
echo "API call failed: {$e->getMessage()}"; | ||
} |
16 changes: 16 additions & 0 deletions
16
examples/customerproductvisibilities/page_customerproductvisibility.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
try { | ||
require "../initialize.php"; | ||
|
||
$customerproductvisibilities = $oro->customerproductvisibilities->page(1, 10); | ||
|
||
foreach ($customerproductvisibilities as $customerproductvisibility) { | ||
echo "<b>$customerproductvisibility->type $customerproductvisibility->id</b><br>"; | ||
foreach ($customerproductvisibility->attributes as $key => $val) { | ||
echo "$key: $val<br>"; | ||
} | ||
} | ||
} catch (\Digitalprint\Oro\Api\Exceptions\ApiException $e) { | ||
echo "API call failed: {$e->getMessage()}"; | ||
} |
24 changes: 24 additions & 0 deletions
24
examples/customerproductvisibilities/update_customerproductvisibility.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
try { | ||
require "../initialize.php"; | ||
|
||
$address = $oro->customerproductvisibilities->get('1-1-1'); | ||
|
||
$res = $address->update([ | ||
'data' => [ | ||
'meta' => [ | ||
'update' => true, | ||
], | ||
'type' => 'customerproductvisibilities', | ||
'id' => '1-1-1', | ||
'attributes' => [ | ||
'visibility' => 'visible', | ||
], | ||
], | ||
]); | ||
|
||
echo "<p>Customerproductvisibility updated: $res->id</p>"; | ||
} catch (\Digitalprint\Oro\Api\Exceptions\ApiException $e) { | ||
echo "API call failed: " . $e->getMessage(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace Digitalprint\Oro\Api\Endpoints; | ||
|
||
use Digitalprint\Oro\Api\Exceptions\ApiException; | ||
use Digitalprint\Oro\Api\Resources\Customerproductvisibility; | ||
use Digitalprint\Oro\Api\Resources\CustomerproductvisibilityCollection; | ||
use JsonException; | ||
use stdClass; | ||
|
||
class CustomerproductvisibilityEndpoint extends CollectionEndpointAbstract | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected string $resourcePath = "api/customerproductvisibilities"; | ||
|
||
/** | ||
* @param array $included | ||
* @return Customerproductvisibility | ||
*/ | ||
protected function getResourceObject(array $included = []): Customerproductvisibility | ||
{ | ||
return new Customerproductvisibility($this->client, $included); | ||
} | ||
|
||
/** | ||
* @param stdClass $links | ||
* @param array $included | ||
* @return CustomerproductvisibilityCollection | ||
*/ | ||
protected function getResourceCollectionObject(stdClass $links, array $included = []): CustomerproductvisibilityCollection | ||
{ | ||
return new CustomerproductvisibilityCollection($this->client, $links, $included); | ||
} | ||
|
||
/** | ||
* @param array|null $data | ||
* @return Customerproductvisibility | ||
* @throws ApiException | ||
* @throws JsonException | ||
*/ | ||
public function create(array $data = null): Customerproductvisibility | ||
{ | ||
return $this->rest_create($data); | ||
} | ||
|
||
/** | ||
* @param string $productpriceId | ||
* @param array $filter | ||
* @return Customerproductvisibility | ||
* @throws ApiException | ||
*/ | ||
public function get(string $customerproductvisibilityId, array $filter = []): Customerproductvisibility | ||
{ | ||
return $this->rest_read($customerproductvisibilityId, $filter); | ||
} | ||
|
||
/** | ||
* @param string|null $number | ||
* @param string|null $size | ||
* @param array $filter | ||
* | ||
* @return CustomerproductvisibilityCollection | ||
* @throws ApiException | ||
*/ | ||
public function page(string $number = null, string $size = null, array $filter = []): CustomerproductvisibilityCollection | ||
{ | ||
return $this->rest_list($number, $size, $filter); | ||
} | ||
|
||
/** | ||
* @param array $data | ||
* @return Customerproductvisibility | ||
* @throws ApiException | ||
* @throws JsonException | ||
*/ | ||
public function update(array $data = []): Customerproductvisibility | ||
{ | ||
return $this->rest_update($data); | ||
} | ||
|
||
/** | ||
* @param array $filter | ||
* @return Customerproductvisibility|null | ||
* @throws ApiException | ||
*/ | ||
public function delete(array $filter = []): ?Customerproductvisibility | ||
{ | ||
return $this->rest_delete($filter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Digitalprint\Oro\Api\Resources; | ||
|
||
use Digitalprint\Oro\Api\Exceptions\ApiException; | ||
use Digitalprint\Oro\Api\OroApiClient; | ||
use JsonException; | ||
|
||
class Customerproductvisibility extends BaseResource | ||
{ | ||
/** | ||
* @return BaseResource | ||
* @throws ApiException | ||
*/ | ||
public function get(): BaseResource | ||
{ | ||
$result = $this->client->performHttpCallToFullUrl( | ||
OroApiClient::HTTP_GET, | ||
$this->links->self | ||
); | ||
|
||
return ResourceFactory::createFromApiResult( | ||
$result->data, | ||
new Customerproductvisibility($this->client) | ||
); | ||
} | ||
|
||
/** | ||
* @param array $body | ||
* @return BaseResource|null | ||
* @throws ApiException | ||
* @throws JsonException | ||
*/ | ||
public function update(array $body = []): ?BaseResource | ||
{ | ||
$result = $this->client->performHttpCallToFullUrl( | ||
OroApiClient::HTTP_PATCH, | ||
$this->links->self, | ||
json_encode($body, JSON_THROW_ON_ERROR) | ||
); | ||
|
||
if ($result === null) { | ||
return null; | ||
} | ||
|
||
return ResourceFactory::createFromApiResult($result->data, new Customerproductvisibility($this->client)); | ||
} | ||
|
||
/** | ||
* @return null | ||
* @throws ApiException | ||
*/ | ||
public function delete() | ||
{ | ||
if (! isset($this->links->self)) { | ||
return $this; | ||
} | ||
|
||
return $this->client->performHttpCallToFullUrl( | ||
OroApiClient::HTTP_DELETE, | ||
$this->links->self | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Digitalprint\Oro\Api\Resources; | ||
|
||
class CustomerproductvisibilityCollection extends CursorCollection | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getCollectionResourceName(): string | ||
{ | ||
return "customerproductvisibilities"; | ||
} | ||
|
||
/** | ||
* @return BaseResource | ||
*/ | ||
protected function createResourceObject(): BaseResource | ||
{ | ||
return new Customerproductvisibility($this->client); | ||
} | ||
} |
Oops, something went wrong.