diff --git a/README.md b/README.md index 7cb1507..cc74dc2 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,106 @@ PHP SDK for Bonanza Marketplace and its "Bonapitit" REST API. Package currently has got support for calling Bonanza's methods: -* fetchToken -* getBoothItems -* getCategories -* getCategoryTraits -* getOrders -* getSingleItem -* getUnlistedItem -* getUser -* addFixedPriceItem -* reviseFixedPriceItem -* endFixedPriceItem -* updateBooth -* setNotificationPreferences -* getNotificationPreferences - -Please refer to the Bonanza's API docs here: https://api.bonanza.com/docs \ No newline at end of file +| Method name | Is secure | +| ------------- | ------------- | +| fetchToken | no | +| getCategories | no | +| getCategoryTraits | no | +| getSingleItem | no | +| getBoothItems | for basic data - no, for more detailed data - yes| +| getUnlistedItem | yes | +| getOrders | yes | +| getUser | yes | +| addFixedPriceItem | yes | +| reviseFixedPriceItem | yes | +| endFixedPriceItem | yes | +| updateBooth | yes | +| setNotificationPreferences | yes | +| getNotificationPreferences | yes | + +Please refer to the Bonanza's API docs here: https://api.bonanza.com/docs + +# Basic usage + +For every call you need devID and certID that you can obtain here: https://api.bonanza.com/accounts/new + +###Unsecure calls + +```php +page = 1; +$request->itemsPerPage = 3; +$request->boothId = 'boothName'; + +//Make a call and receive GetBoothItemsResponse object +$response = $client->getBoothItems($request); +``` + +###Secure calls + +To make secure call, you need to obtain user auth token first. +To receive it, you need to make fetchToken call: + +```php +validationCompleteURL = 'http://return.to/url'; + +//Make a call and get the authorization URL +$response = $client->fetchToken($request); + +//You have the auth token here, but it is inactive, so you can save it for example in the session +$authToken = $response->fetchTokenResponse->authToken; + +//Then you redirect user to the page, where he need to log in and confirm the token. +// After confirmation the user is taken back to the validationCompleteURL. +header('Location: '.$response->fetchTokenResponse->authenticationURL); +``` + +When the access token is signed, you can make a secure call. + +```php +bonanzleAuthToken = 'authToken'; + +//Create request and pass the requesterCredentials to authorize the request +$request = new GetBoothItemsRequest(); +$request->requesterCredentials = $requesterCredentials; +$request->page = 1; +$request->itemsPerPage = 3; +$request->boothId = 'boothName'; + +//Make a call and receive GetBoothItemsResponse object +$response = $client->getBoothItems($request); +``` \ No newline at end of file diff --git a/src/Shoplo/BonanzaApi/Client/BonanzaClient.php b/src/Shoplo/BonanzaApi/Client/BonanzaClient.php index e7a381d..6b416ab 100644 --- a/src/Shoplo/BonanzaApi/Client/BonanzaClient.php +++ b/src/Shoplo/BonanzaApi/Client/BonanzaClient.php @@ -236,13 +236,13 @@ public function updateBooth(UpdateBoothRequest $request): UpdateBoothResponse return $this->post(__FUNCTION__, $request, true); } - public function setNotificationPreferences(SetNotificationPreferencesRequest $request): SetNotificationPreferencesResponse - { - return $this->post(__FUNCTION__, $request, true); - } - - public function getNotificationPreferences(GetNotificationPreferencesRequest $request): GetNotificationPreferencesResponse - { - return $this->post(__FUNCTION__, $request, true); - } + public function setNotificationPreferences(SetNotificationPreferencesRequest $request): SetNotificationPreferencesResponse + { + return $this->post(__FUNCTION__, $request, true); + } + + public function getNotificationPreferences(GetNotificationPreferencesRequest $request): GetNotificationPreferencesResponse + { + return $this->post(__FUNCTION__, $request, true); + } } \ No newline at end of file diff --git a/src/Shoplo/BonanzaApi/Credentials/Credentials.php b/src/Shoplo/BonanzaApi/Credentials/Credentials.php index c310a32..e2de25d 100644 --- a/src/Shoplo/BonanzaApi/Credentials/Credentials.php +++ b/src/Shoplo/BonanzaApi/Credentials/Credentials.php @@ -21,7 +21,6 @@ class Credentials implements CredentialsInterface private $devId; /** - * @param string $appId Application ID * @param string $certId Certificate ID * @param string $devId Developer ID */ diff --git a/src/Shoplo/BonanzaApi/Enums/DeliveryUrlDetailsStatusType.php b/src/Shoplo/BonanzaApi/Enums/DeliveryUrlDetailsStatusType.php index 579492c..642df93 100644 --- a/src/Shoplo/BonanzaApi/Enums/DeliveryUrlDetailsStatusType.php +++ b/src/Shoplo/BonanzaApi/Enums/DeliveryUrlDetailsStatusType.php @@ -4,6 +4,6 @@ class DeliveryUrlDetailsStatusType { - const STATUS_ENABLE = 'Enable'; - const STATUS_DISABLE = 'Disable'; + const STATUS_ENABLE = 'Enable'; + const STATUS_DISABLE = 'Disable'; } \ No newline at end of file diff --git a/src/Shoplo/BonanzaApi/Enums/NotificationEnableStatusType.php b/src/Shoplo/BonanzaApi/Enums/NotificationEnableStatusType.php index b03b8ed..25d96b8 100644 --- a/src/Shoplo/BonanzaApi/Enums/NotificationEnableStatusType.php +++ b/src/Shoplo/BonanzaApi/Enums/NotificationEnableStatusType.php @@ -4,6 +4,6 @@ class NotificationEnableStatusType { - const ENABLE = 'Enable'; - const DISABLE = 'Disable'; + const ENABLE = 'Enable'; + const DISABLE = 'Disable'; } \ No newline at end of file diff --git a/src/Shoplo/BonanzaApi/Enums/NotificationType.php b/src/Shoplo/BonanzaApi/Enums/NotificationType.php index 597aefa..cec1c23 100644 --- a/src/Shoplo/BonanzaApi/Enums/NotificationType.php +++ b/src/Shoplo/BonanzaApi/Enums/NotificationType.php @@ -4,8 +4,8 @@ class NotificationType { - const ASK_SELLER_QUESTION = 'askSellerQuestion'; - const FEEDBACK = 'feedback'; - const FIXED_PRICE_TRANSACTION = 'fixedPriceTransaction'; - const ITEM_MARKED_SHIPPED = 'itemMarkedShipped'; + const ASK_SELLER_QUESTION = 'askSellerQuestion'; + const FEEDBACK = 'feedback'; + const FIXED_PRICE_TRANSACTION = 'fixedPriceTransaction'; + const ITEM_MARKED_SHIPPED = 'itemMarkedShipped'; } \ No newline at end of file diff --git a/src/Shoplo/BonanzaApi/Enums/PackageSizeType.php b/src/Shoplo/BonanzaApi/Enums/PackageSizeType.php index 82b028c..644df63 100644 --- a/src/Shoplo/BonanzaApi/Enums/PackageSizeType.php +++ b/src/Shoplo/BonanzaApi/Enums/PackageSizeType.php @@ -6,14 +6,14 @@ class PackageSizeType { - const DIGITAL_DOWNLOAD = 'Digital download'; - const LARGE_ENVELOPE = 'Large envelope'; - const NORMAL_PACKAGE = 'Normal package'; - const LARGE_PACKAGE = 'Large package'; - const VERY_LARGE_PACKAGE = 'Very large package'; - const USPS_PRIORITY_MAIL_SMALL_FLAT_RATE_BOX = 'USPS Priority Mail Small Flat Rate Box'; - const USPS_PRIORITY_MAIL_MEDIUM_FLAT_RATE_BOX = 'USPS Priority Mail Medium Flat Rate Box'; - const USPS_PRIORITY_MAIL_LARGE_FLAT_RATE_BOX = 'USPS Priority Mail Large Flat Rate Box'; + const DIGITAL_DOWNLOAD = 'Digital download'; + const LARGE_ENVELOPE = 'Large envelope'; + const NORMAL_PACKAGE = 'Normal package'; + const LARGE_PACKAGE = 'Large package'; + const VERY_LARGE_PACKAGE = 'Very large package'; + const USPS_PRIORITY_MAIL_SMALL_FLAT_RATE_BOX = 'USPS Priority Mail Small Flat Rate Box'; + const USPS_PRIORITY_MAIL_MEDIUM_FLAT_RATE_BOX = 'USPS Priority Mail Medium Flat Rate Box'; + const USPS_PRIORITY_MAIL_LARGE_FLAT_RATE_BOX = 'USPS Priority Mail Large Flat Rate Box'; const USPS_PRIORITY_MAIL_FLAT_RATE_ENVELOPE = 'USPS Priority Mail Flat Rate Envelope'; const USPS_PRIORITY_MAIL_PADDED_FLAT_RATE_ENVELOPE = 'USPS Priority Mail Padded Flat Rate Envelope'; const USPS_PRIORITY_MAIL_LEGAL_FLAT_RATE_ENVELOPE = 'USPS Priority Mail Legal Flat Rate Envelope'; diff --git a/src/Shoplo/BonanzaApi/Request/AddFixedPriceItemRequest.php b/src/Shoplo/BonanzaApi/Request/AddFixedPriceItemRequest.php index 31da2c3..a788bb6 100644 --- a/src/Shoplo/BonanzaApi/Request/AddFixedPriceItemRequest.php +++ b/src/Shoplo/BonanzaApi/Request/AddFixedPriceItemRequest.php @@ -8,15 +8,8 @@ use Shoplo\BonanzaApi\Type\AddItemType; use Shoplo\BonanzaApi\Type\RequesterCredentialsType; -class AddFixedPriceItemRequest +class AddFixedPriceItemRequest extends SecureRequest { - /** - * @var RequesterCredentialsType - * - * @Serializer\Type("Shoplo\BonanzaApi\Type\RequesterCredentialsType") - */ - public $requesterCredentials; - /** * @var AddItemType * diff --git a/src/Shoplo/BonanzaApi/Request/EndFixedPriceItemRequest.php b/src/Shoplo/BonanzaApi/Request/EndFixedPriceItemRequest.php index 3d1c7b6..0b6cfac 100644 --- a/src/Shoplo/BonanzaApi/Request/EndFixedPriceItemRequest.php +++ b/src/Shoplo/BonanzaApi/Request/EndFixedPriceItemRequest.php @@ -7,15 +7,8 @@ use JMS\Serializer\Annotation as Serializer; use Shoplo\BonanzaApi\Type\RequesterCredentialsType; -class EndFixedPriceItemRequest +class EndFixedPriceItemRequest extends SecureRequest { - /** - * @var RequesterCredentialsType - * - * @Serializer\Type("Shoplo\BonanzaApi\Type\RequesterCredentialsType") - */ - public $requesterCredentials; - /** * @var int * diff --git a/src/Shoplo/BonanzaApi/Request/GetBoothItemsRequest.php b/src/Shoplo/BonanzaApi/Request/GetBoothItemsRequest.php index 7b2a3e3..2a97710 100644 --- a/src/Shoplo/BonanzaApi/Request/GetBoothItemsRequest.php +++ b/src/Shoplo/BonanzaApi/Request/GetBoothItemsRequest.php @@ -7,15 +7,8 @@ use JMS\Serializer\Annotation as Serializer; use Shoplo\BonanzaApi\Type\RequesterCredentialsType; -class GetBoothItemsRequest +class GetBoothItemsRequest extends SecureRequest { - /** - * @var RequesterCredentialsType - * - * @Serializer\Type("Shoplo\BonanzaApi\Type\RequesterCredentialsType") - */ - public $requesterCredentials; - /** * @var string * diff --git a/src/Shoplo/BonanzaApi/Request/GetNotificationPreferencesRequest.php b/src/Shoplo/BonanzaApi/Request/GetNotificationPreferencesRequest.php index 63cafa8..50e4d6f 100644 --- a/src/Shoplo/BonanzaApi/Request/GetNotificationPreferencesRequest.php +++ b/src/Shoplo/BonanzaApi/Request/GetNotificationPreferencesRequest.php @@ -3,19 +3,6 @@ namespace Shoplo\BonanzaApi\Request; -use JMS\Serializer\Annotation as Serializer; -use Shoplo\BonanzaApi\Type\AddItemType; -use Shoplo\BonanzaApi\Type\DeliveryURLDetailsType; -use Shoplo\BonanzaApi\Type\ApplicationDeliveryPreferencesType; -use Shoplo\BonanzaApi\Type\RequesterCredentialsType; -use Shoplo\BonanzaApi\Type\UserDeliveryPreferenceArrayType; - -class GetNotificationPreferencesRequest +class GetNotificationPreferencesRequest extends SecureRequest { - /** - * @var RequesterCredentialsType - * - * @Serializer\Type("Shoplo\BonanzaApi\Type\RequesterCredentialsType") - */ - public $requesterCredentials; } diff --git a/src/Shoplo/BonanzaApi/Request/GetOrdersRequest.php b/src/Shoplo/BonanzaApi/Request/GetOrdersRequest.php index a4a1e70..d829c7b 100644 --- a/src/Shoplo/BonanzaApi/Request/GetOrdersRequest.php +++ b/src/Shoplo/BonanzaApi/Request/GetOrdersRequest.php @@ -8,15 +8,8 @@ use Shoplo\BonanzaApi\Type\PaginationInputType; use Shoplo\BonanzaApi\Type\RequesterCredentialsType; -class GetOrdersRequest +class GetOrdersRequest extends SecureRequest { - /** - * @var RequesterCredentialsType - * - * @Serializer\Type("Shoplo\BonanzaApi\Type\RequesterCredentialsType") - */ - public $requesterCredentials; - /** * @var \DateTime * diff --git a/src/Shoplo/BonanzaApi/Request/GetUnlistedItemRequest.php b/src/Shoplo/BonanzaApi/Request/GetUnlistedItemRequest.php index a080905..1b12fd6 100644 --- a/src/Shoplo/BonanzaApi/Request/GetUnlistedItemRequest.php +++ b/src/Shoplo/BonanzaApi/Request/GetUnlistedItemRequest.php @@ -5,17 +5,9 @@ use JMS\Serializer\Annotation as Serializer; -use Shoplo\BonanzaApi\Type\RequesterCredentialsType; -class GetUnlistedItemRequest +class GetUnlistedItemRequest extends SecureRequest { - /** - * @var RequesterCredentialsType - * - * @Serializer\Type("Shoplo\BonanzaApi\Type\RequesterCredentialsType") - */ - public $requesterCredentials; - /** * @var string * diff --git a/src/Shoplo/BonanzaApi/Request/GetUserRequest.php b/src/Shoplo/BonanzaApi/Request/GetUserRequest.php index 18b9c94..a73f354 100644 --- a/src/Shoplo/BonanzaApi/Request/GetUserRequest.php +++ b/src/Shoplo/BonanzaApi/Request/GetUserRequest.php @@ -4,15 +4,6 @@ namespace Shoplo\BonanzaApi\Request; -use JMS\Serializer\Annotation as Serializer; -use Shoplo\BonanzaApi\Type\RequesterCredentialsType; - -class GetUserRequest +class GetUserRequest extends SecureRequest { - /** - * @var RequesterCredentialsType - * - * @Serializer\Type("Shoplo\BonanzaApi\Type\RequesterCredentialsType") - */ - public $requesterCredentials; } diff --git a/src/Shoplo/BonanzaApi/Request/SecureRequest.php b/src/Shoplo/BonanzaApi/Request/SecureRequest.php new file mode 100644 index 0000000..8b8a291 --- /dev/null +++ b/src/Shoplo/BonanzaApi/Request/SecureRequest.php @@ -0,0 +1,18 @@ +") - */ - public $notificationEnable; + /** + * @var NotificationEnableType[] + * + * @Serializer\Type("array") + */ + public $notificationEnable; } \ No newline at end of file