Skip to content

Commit

Permalink
Add App Integrations API
Browse files Browse the repository at this point in the history
  • Loading branch information
jlevers committed Sep 30, 2024
1 parent b0c2501 commit 1c58a9b
Show file tree
Hide file tree
Showing 15 changed files with 2,340 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ $sellerConnector = SellingPartnerApi::seller(/* ... */);
```php
$amazonWarehousingAndDistributionApi = $sellerConnector->amazonWarehousingAndDistributionV20240509();
```
* **App Integrations API (v2024-04-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/app-integrations-api-v2024-04-01-reference))
```php
$appIntegrationsApi = $sellerConnector->appIntegrationsV20240401();
```
* **Application Management API (v2023-11-30)** ([docs](https://developer-docs.amazon.com/sp-api/docs/application-management-api-v2023-11-30-reference))
```php
$applicationManagementApi = $sellerConnector->applicationManagementV20231130();
Expand Down
9 changes: 9 additions & 0 deletions resources/apis.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
}
]
},
"app-integrations": {
"name": "App Integrations",
"versions": [
{
"version": "2024-04-01",
"url": "https://raw.githubusercontent.com/amzn/selling-partner-api-models/refs/heads/main/models/application-integrations-api-model/appIntegrations-2024-04-01.json"
}
]
},
"application-management": {
"name": "Application Management",
"versions": [
Expand Down
968 changes: 968 additions & 0 deletions resources/models/raw/seller/app-integrations/v2024-04-01.json

Large diffs are not rendered by default.

968 changes: 968 additions & 0 deletions resources/models/seller/app-integrations/v2024-04-01.json

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions src/Seller/AppIntegrationsV20240401/Api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace SellingPartnerApi\Seller\AppIntegrationsV20240401;

use Saloon\Http\Response;
use SellingPartnerApi\BaseResource;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Dto\CreateNotificationRequest;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Dto\DeleteNotificationsRequest;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Dto\RecordActionFeedbackRequest;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Requests\CreateNotification;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Requests\DeleteNotifications;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Requests\RecordActionFeedback;

class Api extends BaseResource
{
/**
* @param CreateNotificationRequest $createNotificationRequest The request for the `createNotification` operation.
*/
public function createNotification(CreateNotificationRequest $createNotificationRequest): Response
{
$request = new CreateNotification($createNotificationRequest);

return $this->connector->send($request);
}

/**
* @param DeleteNotificationsRequest $deleteNotificationsRequest The request for the `deleteNotifications` operation.
*/
public function deleteNotifications(DeleteNotificationsRequest $deleteNotificationsRequest): Response
{
$request = new DeleteNotifications($deleteNotificationsRequest);

return $this->connector->send($request);
}

/**
* @param string $notificationId A `notificationId` uniquely identifies a notification.
* @param RecordActionFeedbackRequest $recordActionFeedbackRequest The request for the `recordActionFeedback` operation.
*/
public function recordActionFeedback(
string $notificationId,
RecordActionFeedbackRequest $recordActionFeedbackRequest,
): Response {
$request = new RecordActionFeedback($notificationId, $recordActionFeedbackRequest);

return $this->connector->send($request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* This file is auto-generated by Saloon SDK Generator
* Generator: Crescat\SaloonSdkGenerator\Generators\DtoGenerator
* Do not modify it directly.
*/

declare(strict_types=1);

namespace SellingPartnerApi\Seller\AppIntegrationsV20240401\Dto;

use SellingPartnerApi\Dto;

final class CreateNotificationRequest extends Dto
{
/**
* @param string $templateId The unique identifier of the notification template you used to onboard your application.
* @param array[] $notificationParameters The dynamic parameters required by the notification templated specified by `templateId`.
* @param ?string $marketplaceId An encrypted marketplace identifier for the posted notification.
*/
public function __construct(
public string $templateId,
public array $notificationParameters,
public ?string $marketplaceId = null,
) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* This file is auto-generated by Saloon SDK Generator
* Generator: Crescat\SaloonSdkGenerator\Generators\DtoGenerator
* Do not modify it directly.
*/

declare(strict_types=1);

namespace SellingPartnerApi\Seller\AppIntegrationsV20240401\Dto;

use SellingPartnerApi\Dto;

final class DeleteNotificationsRequest extends Dto
{
/**
* @param string $templateId The unique identifier of the notification template you used to onboard your application.
* @param string $deletionReason The unique identifier that maps each notification status to a reason code.
*/
public function __construct(
public string $templateId,
public string $deletionReason,
) {}
}
27 changes: 27 additions & 0 deletions src/Seller/AppIntegrationsV20240401/Dto/Error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* This file is auto-generated by Saloon SDK Generator
* Generator: Crescat\SaloonSdkGenerator\Generators\DtoGenerator
* Do not modify it directly.
*/

declare(strict_types=1);

namespace SellingPartnerApi\Seller\AppIntegrationsV20240401\Dto;

use SellingPartnerApi\Dto;

final class Error extends Dto
{
/**
* @param string $code An error code that identifies the type of error that occurred.
* @param string $message A message that describes the error condition.
* @param ?string $details Additional details that can help the caller understand or fix the issue.
*/
public function __construct(
public string $code,
public string $message,
public ?string $details = null,
) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* This file is auto-generated by Saloon SDK Generator
* Generator: Crescat\SaloonSdkGenerator\Generators\DtoGenerator
* Do not modify it directly.
*/

declare(strict_types=1);

namespace SellingPartnerApi\Seller\AppIntegrationsV20240401\Dto;

use SellingPartnerApi\Dto;

final class RecordActionFeedbackRequest extends Dto
{
/**
* @param string $feedbackActionCode The unique identifier for each notification status.
*/
public function __construct(
public string $feedbackActionCode,
) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/**
* This file is auto-generated by Saloon SDK Generator
* Generator: SellingPartnerApi\Generator\Generators\RequestGenerator
* Do not modify it directly.
*/

declare(strict_types=1);

namespace SellingPartnerApi\Seller\AppIntegrationsV20240401\Requests;

use Exception;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
use SellingPartnerApi\Request;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Dto\CreateNotificationRequest;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Responses\CreateNotificationResponse;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Responses\ErrorList;

/**
* createNotification
*/
class CreateNotification extends Request implements HasBody
{
use HasJsonBody;

protected Method $method = Method::POST;

/**
* @param CreateNotificationRequest $createNotificationRequest The request for the `createNotification` operation.
*/
public function __construct(
public CreateNotificationRequest $createNotificationRequest,
) {}

public function resolveEndpoint(): string
{
return '/appIntegrations/2024-04-01/notifications';
}

public function createDtoFromResponse(Response $response): CreateNotificationResponse|ErrorList
{
$status = $response->status();
$responseCls = match ($status) {
200 => CreateNotificationResponse::class,
400, 401, 403, 404, 413, 415, 429, 500, 503 => ErrorList::class,
default => throw new Exception("Unhandled response status: {$status}")
};

return $responseCls::deserialize($response->json());
}

public function defaultBody(): array
{
return $this->createNotificationRequest->toArray();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/**
* This file is auto-generated by Saloon SDK Generator
* Generator: SellingPartnerApi\Generator\Generators\RequestGenerator
* Do not modify it directly.
*/

declare(strict_types=1);

namespace SellingPartnerApi\Seller\AppIntegrationsV20240401\Requests;

use Exception;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
use SellingPartnerApi\EmptyResponse;
use SellingPartnerApi\Request;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Dto\DeleteNotificationsRequest;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Responses\ErrorList;

/**
* deleteNotifications
*/
class DeleteNotifications extends Request implements HasBody
{
use HasJsonBody;

protected Method $method = Method::POST;

/**
* @param DeleteNotificationsRequest $deleteNotificationsRequest The request for the `deleteNotifications` operation.
*/
public function __construct(
public DeleteNotificationsRequest $deleteNotificationsRequest,
) {}

public function resolveEndpoint(): string
{
return '/appIntegrations/2024-04-01/notifications/deletion';
}

public function createDtoFromResponse(Response $response): EmptyResponse|ErrorList
{
$status = $response->status();
$responseCls = match ($status) {
204 => EmptyResponse::class,
400, 413, 403, 404, 415, 429, 500, 503 => ErrorList::class,
default => throw new Exception("Unhandled response status: {$status}")
};

return $responseCls::deserialize($response->json());
}

public function defaultBody(): array
{
return $this->deleteNotificationsRequest->toArray();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/**
* This file is auto-generated by Saloon SDK Generator
* Generator: SellingPartnerApi\Generator\Generators\RequestGenerator
* Do not modify it directly.
*/

declare(strict_types=1);

namespace SellingPartnerApi\Seller\AppIntegrationsV20240401\Requests;

use Exception;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
use SellingPartnerApi\EmptyResponse;
use SellingPartnerApi\Request;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Dto\RecordActionFeedbackRequest;
use SellingPartnerApi\Seller\AppIntegrationsV20240401\Responses\ErrorList;

/**
* recordActionFeedback
*/
class RecordActionFeedback extends Request implements HasBody
{
use HasJsonBody;

protected Method $method = Method::POST;

/**
* @param string $notificationId A `notificationId` uniquely identifies a notification.
* @param RecordActionFeedbackRequest $recordActionFeedbackRequest The request for the `recordActionFeedback` operation.
*/
public function __construct(
protected string $notificationId,
public RecordActionFeedbackRequest $recordActionFeedbackRequest,
) {}

public function resolveEndpoint(): string
{
return "/appIntegrations/2024-04-01/notifications/{$this->notificationId}/feedback";
}

public function createDtoFromResponse(Response $response): EmptyResponse|ErrorList
{
$status = $response->status();
$responseCls = match ($status) {
204 => EmptyResponse::class,
400, 413, 401, 403, 404, 415, 429, 500, 503 => ErrorList::class,
default => throw new Exception("Unhandled response status: {$status}")
};

return $responseCls::deserialize($response->json());
}

public function defaultBody(): array
{
return $this->recordActionFeedbackRequest->toArray();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* This file is auto-generated by Saloon SDK Generator
* Generator: SellingPartnerApi\Generator\Generators\ResponseGenerator
* Do not modify it directly.
*/

declare(strict_types=1);

namespace SellingPartnerApi\Seller\AppIntegrationsV20240401\Responses;

use SellingPartnerApi\Response;

final class CreateNotificationResponse extends Response
{
/**
* @param ?string $notificationId The unique identifier assigned to each notification.
*/
public function __construct(
public readonly ?string $notificationId = null,
) {}
}
Loading

0 comments on commit 1c58a9b

Please sign in to comment.