diff --git a/src/Data/Responses/Sellers/GetAccountResponse.php b/src/Data/Responses/Sellers/GetAccountResponse.php new file mode 100644 index 00000000..f1ab44bf --- /dev/null +++ b/src/Data/Responses/Sellers/GetAccountResponse.php @@ -0,0 +1,14 @@ + + */ +class MarketplaceLevelAttributesSchemaList extends TypedCollection +{ + public const ITEM_CLASS = MarketplaceLevelAttributesSchema::class; +} diff --git a/src/Data/Schemas/Sellers/MarketplaceParticipationListSchema.php b/src/Data/Schemas/Sellers/MarketplaceParticipationSchemaList.php similarity index 79% rename from src/Data/Schemas/Sellers/MarketplaceParticipationListSchema.php rename to src/Data/Schemas/Sellers/MarketplaceParticipationSchemaList.php index c41790b9..97015e8e 100644 --- a/src/Data/Schemas/Sellers/MarketplaceParticipationListSchema.php +++ b/src/Data/Schemas/Sellers/MarketplaceParticipationSchemaList.php @@ -7,7 +7,7 @@ /** * @template-extends TypedCollection */ -class MarketplaceParticipationListSchema extends TypedCollection +class MarketplaceParticipationSchemaList extends TypedCollection { public const ITEM_CLASS = MarketplaceParticipationSchema::class; } diff --git a/src/Data/Schemas/Sellers/MarketplaceSchema.php b/src/Data/Schemas/Sellers/MarketplaceSchema.php index d64c18a6..4e544f4d 100644 --- a/src/Data/Schemas/Sellers/MarketplaceSchema.php +++ b/src/Data/Schemas/Sellers/MarketplaceSchema.php @@ -10,8 +10,8 @@ public function __construct( public string $id, public string $name, public string $country_code, - public string $default_currency_code, - public string $default_language_code, + public ?string $default_currency_code, + public ?string $default_language_code, public string $domain_name, ) { } diff --git a/src/Data/Schemas/Sellers/PrimaryContactSchema.php b/src/Data/Schemas/Sellers/PrimaryContactSchema.php new file mode 100644 index 00000000..6d7089bf --- /dev/null +++ b/src/Data/Schemas/Sellers/PrimaryContactSchema.php @@ -0,0 +1,15 @@ +http ->responseClass(GetMarketplaceParticipationsResponse::class) - ->get($this->endpoint . self::BASE_PATH); + ->get($this->endpoint . self::BASE_PATH . 'marketplaceParticipations'); + + return $response; + } + + public function getAccount(): GetAccountResponse + { + $response = $this->http + ->responseClass(GetAccountResponse::class) + ->get($this->endpoint . self::BASE_PATH . 'account'); return $response; } diff --git a/tests/Unit/Resources/SellersResourceTest.php b/tests/Unit/Resources/SellersResourceTest.php index 766257af..8959f8b7 100644 --- a/tests/Unit/Resources/SellersResourceTest.php +++ b/tests/Unit/Resources/SellersResourceTest.php @@ -4,6 +4,7 @@ use Illuminate\Http\Client\Request; use Jasara\AmznSPA\AmznSPA; +use Jasara\AmznSPA\Data\Responses\Sellers\GetAccountResponse; use Jasara\AmznSPA\Data\Responses\Sellers\GetMarketplaceParticipationsResponse; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; use PHPUnit\Framework\Attributes\CoversClass; @@ -28,4 +29,22 @@ public function testGetMarketplaceParticipations() return true; }); } + + public function testGetAccount() + { + list($config, $http) = $this->setupConfigWithFakeHttp('sellers/get-account'); + + $amzn = new AmznSPA($config); + $amzn = $amzn->usingMarketplace('ATVPDKIKX0DER'); + $response = $amzn->sellers->getAccount(); + + $this->assertInstanceOf(GetAccountResponse::class, $response); + + $http->assertSent(function (Request $request) { + $this->assertEquals('GET', $request->method()); + $this->assertEquals('https://sellingpartnerapi-na.amazon.com/sellers/v1/account', $request->url()); + + return true; + }); + } } diff --git a/tests/stubs/sellers/get-account.json b/tests/stubs/sellers/get-account.json new file mode 100644 index 00000000..325d092e --- /dev/null +++ b/tests/stubs/sellers/get-account.json @@ -0,0 +1,43 @@ +{ + "payload": { + "businessType": "PRIVATE_LIMITED", + "marketplaceLevelAttributes": [ + { + "marketplace": { + "id": "ATVPDKIKX0DER", + "name": "United States", + "countryCode": "US", + "domainName": "www.amazon.com" + }, + "storeName": "BestSellerStore", + "listingStatus": "ACTIVE", + "sellingPlan": "PROFESSIONAL" + } + ], + "business": { + "name": "BestSeller Inc.", + "nonLatinName": "ベストセラー株式会社", + "registeredBusinessAddress": { + "addressLine1": "123 Main St", + "addressLine2": "Suite 500", + "city": "Seattle", + "stateOrProvinceCode": "WA", + "postalCode": "98101", + "countryCode": "US" + }, + "companyRegistrationNumber": "123456789" + }, + "primaryContact": { + "name": "John Doe", + "nonLatinName": "ジョン・ドゥ", + "address": { + "addressLine1": "456 Oak St", + "addressLine2": "Apt 12", + "city": "Seattle", + "stateOrProvinceCode": "WA", + "postalCode": "98102", + "countryCode": "US" + } + } + } +} \ No newline at end of file