sapientpro / ebay-inventory-sdk-php
PHP SDK for Ebay Inventory 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:22:14 UTC
README
The Inventory API is used to create and manage inventory, and then to publish and manage this inventory on an eBay marketplace. There are also methods in this API that will convert eligible, active eBay listings into the Inventory API model.
This PHP package is automatically generated by the Swagger Codegen project:
- API version: 1.16.2
- Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen
Requirements
- PHP 8.1 and later
- ext-curl and ext-json extensions enabled
Installation & Usage
Install the package using composer:
composer require sapientpro/ebay-account-sdk-php
Getting Started
Please follow the installation procedure and then run the following:
<?php use SapientPro\EbayInventorySDK\Configuration; use SapientPro\EbayInventorySDK\Api\InventoryItemApi; use SapientPro\EbayInventorySDK\Models\BulkInventoryItem; // Configure OAuth2 access token for authorization: api_auth $config = Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new InventoryItemApi( 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 = BulkInventoryItem::fromArray([]); try { $result = $apiInstance->bulkCreateOrReplaceInventoryItem($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling InventoryItemApi->bulkCreateOrReplaceInventoryItem: ', $e->getMessage(), PHP_EOL; }
Note: Some methods require $contentLanguage
argument. It's value should be of string type and correspond to the LocaleEnum cases, but should be in kebab case:
LocaleEnum::en_US -> 'en-US'
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/inventory/v1
Documentation For Models
- Address
- Amount
- Availability
- AvailabilityDistribution
- AvailabilityWithAll
- BaseResponse
- BestOffer
- BulkEbayOfferDetailsWithKeys
- BulkGetInventoryItem
- BulkGetInventoryItemResponse
- BulkInventoryItem
- BulkInventoryItemResponse
- BulkMigrateListing
- BulkMigrateListingResponse
- BulkOffer
- BulkOfferResponse
- BulkPriceQuantity
- BulkPriceQuantityResponse
- BulkPublishResponse
- Charity
- Compatibility
- CompatibleProduct
- Dimension
- EbayOfferDetailsWithAll
- EbayOfferDetailsWithId
- EbayOfferDetailsWithKeys
- Error
- ErrorParameter
- ExtendedProducerResponsibility
- Fee
- FeeSummary
- FeesSummaryResponse
- FormatAllocation
- GeoCoordinates
- GetInventoryItem
- GetInventoryItemResponse
- Interval
- InventoryItem
- InventoryItemGroup
- InventoryItemListing
- InventoryItemResponse
- InventoryItemWithSkuLocale
- InventoryItemWithSkuLocaleGroupKeys
- InventoryItemWithSkuLocaleGroupid
- InventoryItems
- InventoryLocation
- InventoryLocationFull
- InventoryLocationResponse
- ListingDetails
- ListingPolicies
- Location
- LocationDetails
- LocationResponse
- MigrateListing
- MigrateListingResponse
- NameValueList
- OfferKeyWithId
- OfferKeysWithId
- OfferPriceQuantity
- OfferResponse
- OfferResponseWithListingId
- OfferSkuResponse
- Offers
- OperatingHours
- PackageWeightAndSize
- PickupAtLocationAvailability
- PriceQuantity
- PriceQuantityResponse
- PricingSummary
- Product
- ProductFamilyProperties
- ProductIdentifier
- PublishByInventoryItemGroupRequest
- PublishResponse
- ShipToLocationAvailability
- ShipToLocationAvailabilityWithAll
- ShippingCostOverride
- SpecialHours
- Specification
- Tax
- TimeDuration
- VariesBy
- Version
- Weight
- WithdrawByInventoryItemGroupRequest
- WithdrawResponse
Authorization
api_auth
- Type: OAuth
- Flow: accessCode
- Authorization URL: https://auth.ebay.com/oauth2/authorize
- Scopes:
- https://api.ebay.com/oauth/api_scope/sell.inventory: View and manage your inventory and offers
- https://api.ebay.com/oauth/api_scope/sell.inventory.readonly: View your inventory and offers