Skip to content

Commit

Permalink
Inital boilerplate for implementing channel currency assignments #53
Browse files Browse the repository at this point in the history
  • Loading branch information
jswift committed Apr 13, 2021
1 parent 23b2bce commit 622920b
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 9 deletions.
10 changes: 1 addition & 9 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
### New Features

- Implement the missing _create_ and _update_ endpoints for Brands.
- Implement [Channels APIs](https://developer.bigcommerce.com/api-reference/store-management/channels):
- [Channels](https://developer.bigcommerce.com/api-reference/store-management/channels/channels/listchannels)
- [Active Theme](https://developer.bigcommerce.com/api-reference/store-management/channels/channel-active-theme/get-channel-active-theme)
- [Listings](https://developer.bigcommerce.com/api-reference/store-management/channels/channel-listings/listchannellistings)
- [Site](https://developer.bigcommerce.com/api-reference/store-management/channels/channel-site/get-channel-site)
- Implement the [Channel Currency Assignments API](https://developer.bigcommerce.com/api-reference/store-management/channels/channel-currency-assignments/post-channels-currency-assignments)

### Fixed Issues

- Fixed 404 errors on scripts api (#55), thanks to @kishan93
- Fixed issue where subscribers API was not accessible
- Fixed issue where Widget Template endpoints were incorrect

54 changes: 54 additions & 0 deletions src/BigCommerce/Api/Channels/ChannelCurrencyAssignmentsApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace BigCommerce\ApiV3\Api\Channels;

use BigCommerce\ApiV3\Api\Generic\ResourceWithBatchUpdateApi;
use BigCommerce\ApiV3\ResponseModels\PaginatedResponse;
use BigCommerce\ApiV3\ResponseModels\SingleResourceResponse;

/**
* Channel Currency Assignments API
*
*
*/
class ChannelCurrencyAssignmentsApi extends ResourceWithBatchUpdateApi
{

public function batchUpdate(array $resources): PaginatedResponse
{
// TODO: Implement batchUpdate() method.
}

protected function multipleResourcesEndpoint(): string
{
// TODO: Implement multipleResourcesEndpoint() method.
}

protected function singleResourceEndpoint(): string
{
// TODO: Implement singleResourceEndpoint() method.
}

protected function resourceName(): string
{
// TODO: Implement resourceName() method.
}

public function get(): SingleResourceResponse
{
// TODO: Implement get() method.
}

public function getAll(array $filters = [], int $page = 1, int $limit = 250): PaginatedResponse
{
// TODO: Implement getAll() method.
}

public function create(): SingleResourceResponse
{
}

public function update(): SingleResourceResponse
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace BigCommerce\ApiV3\ResourceModels\Channel;

use BigCommerce\ApiV3\ResourceModels\ResourceModel;

class ChannelCurrencyAssignment extends ResourceModel
{
public int $channel_id;
public array $enabled_currencies;
public string $default_currency;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace BigCommerce\ApiV3\ResponseModels\Channel;

use BigCommerce\ApiV3\ResourceModels\Channel\ChannelCurrencyAssignment;
use BigCommerce\ApiV3\ResponseModels\SingleResourceResponse;
use stdClass;

class ChannelCurrencyAssignmentResponse extends SingleResourceResponse
{
private ChannelCurrencyAssignment $currencyAssignment;

public function getCurrencyAssignment(): ChannelCurrencyAssignment
{
return $this->currencyAssignment;
}

protected function addData(stdClass $rawData): void
{
$this->currencyAssignment = new ChannelCurrencyAssignment($rawData);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace BigCommerce\ApiV3\ResponseModels\Channel;

use BigCommerce\ApiV3\ResourceModels\Channel\ChannelCurrencyAssignment;
use BigCommerce\ApiV3\ResponseModels\PaginatedResponse;

class ChannelCurrencyAssignmentsResponse extends PaginatedResponse
{
/**
* @return ChannelCurrencyAssignment[]
*/
public function getCurrencyAssignments(): array
{
return $this->getData();
}

protected function resourceClass(): string
{
return ChannelCurrencyAssignment::class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace BigCommerce\Tests\Api\Channels;

use BigCommerce\Tests\BigCommerceApiTest;

class ChannelCurrencyAssignmentsApiTest extends BigCommerceApiTest
{
public function testCanGetCurrencyAssignment()
{
$this->markTestIncomplete();
}

public function testCanGetAllCurrencyAssignments()
{
$this->markTestIncomplete();
}
}

0 comments on commit 622920b

Please sign in to comment.