Skip to content

Commit

Permalink
Fix fn_sku
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbrink committed Oct 6, 2021
1 parent fe11bc6 commit 8c0cd0c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/Resources/FbaInventoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
namespace Jasara\AmznSPA\Resources;

use Carbon\CarbonImmutable;
use Illuminate\Support\Arr;
use Jasara\AmznSPA\AmznSPAHttp;
use Jasara\AmznSPA\Constants\AmazonEnums;
use Jasara\AmznSPA\Constants\MarketplacesList;
use Jasara\AmznSPA\Contracts\ResourceContract;
use Jasara\AmznSPA\DataTransferObjects\Responses\CatalogItems\GetCatalogItemResponse;
use Jasara\AmznSPA\DataTransferObjects\Responses\CatalogItems\ItemSearchResults;
use Jasara\AmznSPA\DataTransferObjects\Responses\FbaInventory\GetInventorySummariesResponse;
use Jasara\AmznSPA\Traits\ValidatesParameters;

Expand Down
6 changes: 4 additions & 2 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Str;

if (! function_exists('array_keys_to_snake')) { // @codeCoverageIgnore
if (!function_exists('array_keys_to_snake')) { // @codeCoverageIgnore
function array_keys_to_snake(array $array): array
{
$snakecased_array = [];
Expand All @@ -15,7 +15,9 @@ function array_keys_to_snake(array $array): array
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
}

$key = Str::snake(implode('_', $result));
$key = (string) Str::of(implode('_', $result))
->snake()
->replace('fn_sku', 'fnsku');
}
if (is_array($value)) {
$value = array_keys_to_snake($value);
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function testArrayKeysToSnake()
'abc12345abc' => 0,
'aBc12345Abc' => 0,
'SKUInboundGuidanceList' => 0,
'fnSku' => 0,
];

$array = array_keys_to_snake($array);
Expand All @@ -41,6 +42,7 @@ public function testArrayKeysToSnake()
$this->assertArrayHasKey('abc_12345_abc', $array);
$this->assertArrayHasKey('a_bc_12345_abc', $array);
$this->assertArrayHasKey('sku_inbound_guidance_list', $array);
$this->assertArrayHasKey('fnsku', $array);
$this->assertArrayHasKey('test_deep_camel', $array['test_camel']);
$this->assertArrayHasKey('test_deep_array_with_objects', $array['test_camel']);
$this->assertArrayHasKey('test_collection', $array['test_camel']['test_deep_array_with_objects'][0]);
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Resources/FbaInventoryResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function testGetInventorySummaries()
$this->assertInstanceOf(GetInventorySummariesResponse::class, $response);
$this->assertEquals('seed', $response->pagination->next_token);
$this->assertEquals('B0020MLK00', $response->payload->inventory_summaries->first()->asin);
$this->assertEquals('B0020MLK00', $response->payload->inventory_summaries->first()->fnsku);

$http->assertSent(function (Request $request) use ($sku) {
$this->assertEquals('GET', $request->method());
Expand Down

0 comments on commit 8c0cd0c

Please sign in to comment.