sapientpro / ebay-account-sdk-php
eBay Account API
Requires
- php: ^8.1
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- phpdocumentor/reflection-docblock: ^5.3
- symfony/property-access: ^6.2
- symfony/serializer: ^6.2
- symfony/validator: ^6.3
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.2
- squizlabs/php_codesniffer: ^3.6
This package is not auto-updated.
Last update: 2024-12-16 17:51:53 UTC
README
The Account API gives sellers the ability to configure their eBay seller accounts, including the seller's policies (eBay business policies and seller-defined custom policies), opt in and out of eBay seller programs, configure sales tax tables, and get account information.
For details on the availability of the methods in this API, see <a href="/api-docs/sell/account/overview.html#requirements">Account API requirements and restrictions.
This PHP package is automatically generated by the Swagger Codegen project:
- API version: v1.9.0
- Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen
Requirements
- PHP 8.1 or later
- ext-json and ext-curl extensions enabled
Installation & Usage
Install the package using composer:
composer require sapientpro/ebay-account-sdk-php
Example usage
Please follow the installation procedure and then run the following:
<?php use SapientPro\EbayAccountSDK\Configuration; use SapientPro\EbayAccountSDK\Api\CustomPolicyApi; use SapientPro\EbayAccountSDK\Models\CustomPolicyCreateRequest; use SapientPro\EbayAccountSDK\Enums\MarketplaceIdEnum; use SapientPro\EbayAccountSDK\Enums\CustomPolicyTypeEnum; // Configure OAuth2 access token for authorization: api_auth $config = Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new CustomPolicyApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. ebayClient: GuzzleHttp\Client(), config: $config ); // you can create and fill a Model class that implements EbayModelInterface using fromArray() method // exception will be thrown if a property does not exist in the model class $body = CustomPolicyCreateRequest::fromArray([ 'description' => 'description_example', 'name' => 'name_example', 'label' => 'label_example', 'custom_policy_type_enum' => CustomPolicyTypeEnum::PRODUCT_COMPLIANCE, ]); try { $result = $apiInstance->createCustomPolicy($body, MarketplaceIdEnum::EBAY_US); print_r($result); // there is also a custom ApiException for non 2xx responses } catch (Exception $e) { echo 'Exception when calling CustomPolicyApi->createCustomPolicy: ', $e->getMessage(), PHP_EOL; }
Creating Models
Some SDK methods require $body
variable as a parameter. It refers to a Model class that implements EbayModelInterface.
There are several ways to create a Model class:
fromArray()
You can create a Model class using fromArray() method. It will throw an exception if a property does not exist in the model class.
If the model has a property of type that implements EbayModelInterface, you must create an instance of that class using fromArray() method.
In this example, the property price
is of type ConvertedAmount
that also implements EbayModelInterface.
Item::fromArray([ 'price' => ConvertedAmount::fromArray([ 'value' => '6.90', 'currency' => CurrencyCodeEnum::USD )] ])
fromPlainArray()
It is also possible to create a Model from plain associative array. The previous example can be rewritten as follows:
Item::fromPlainArray([ 'price' => [ 'value' => '6.90', 'currency' => CurrencyCodeEnum::USD ] ])
fromJson()
It is also possible to create a Model from JSON string.
Item::fromJson('{"price": {"value": "6.90", "currency": "USD"}}')
Documentation for API Endpoints
All URIs are relative to https://api.ebay.com/sell/account/v1
Documentation For Models
- Amount
- CategoryType
- CompactCustomPolicyResponse
- CustomPolicy
- CustomPolicyCreateRequest
- CustomPolicyRequest
- CustomPolicyResponse
- Deposit
- Error
- ErrorParameter
- FulfillmentPolicy
- FulfillmentPolicyRequest
- FulfillmentPolicyResponse
- InternationalReturnOverrideType
- KycCheck
- KycResponse
- PaymentMethod
- PaymentPolicy
- PaymentPolicyRequest
- PaymentPolicyResponse
- PaymentsProgramOnboardingResponse
- PaymentsProgramOnboardingSteps
- PaymentsProgramResponse
- Program
- Programs
- RateTable
- RateTableResponse
- RecipientAccountReference
- Region
- RegionSet
- ReturnPolicy
- ReturnPolicyRequest
- ReturnPolicyResponse
- SalesTax
- SalesTaxBase
- SalesTaxes
- SellingLimit
- SellingPrivileges
- SetFulfillmentPolicyResponse
- SetPaymentPolicyResponse
- SetReturnPolicyResponse
- ShippingOption
- ShippingService
- TimeDuration
Documentation For Authorization
api_auth
- Type: OAuth
- Flow: accessCode
- Authorization URL: https://auth.ebay.com/oauth2/authorize
- Scopes:
- https://api.ebay.com/oauth/api_scope/sell.account.readonly: View your account settings
- https://api.ebay.com/oauth/api_scope/sell.account: View and manage your account settings