Metadata-Version: 2.1
Name: ebay-feedsdk
Version: 0.2.0
Summary: Port of https://github.com/eBay/FeedSDK-Python and https://github.com/eBay/ebay-oauth-python-client to python3
Home-page: https://github.com/taxaos/FeedSDK-Python
License: Apache-2.0
Keywords: ebay,ebay-feedsdk
Author: Lars Erler
Author-email: lars@xaospage.de
Requires-Python: >=3.7.1,<4.0.0
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: PyYAML (>=5.4.1,<6.0.0)
Requires-Dist: SQLAlchemy (>=1.3.24,<2.0.0)
Requires-Dist: aenum (>=3.00,<4.0)
Requires-Dist: certifi (>=2020.12.5,<2021.0.0)
Requires-Dist: pandas (>=1.2.4,<2.0.0)
Requires-Dist: requests (>=2.25.1,<3.0.0)
Requires-Dist: urllib3 (>=1.26.4,<2.0.0)
Project-URL: Repository, https://github.com/taxaos/FeedSDK-Python
Description-Content-Type: text/markdown

Feed SDK
==========
Python SDK for downloading and filtering item feed files including oauth authentication.

Forked and merged from [https://github.com/eBay/FeedSDK-Python](https://github.com/eBay/FeedSDK-Python) and [https://github.com/eBay/ebay-oauth-python-client](https://github.com/eBay/ebay-oauth-python-client) and ported to python3

Nothing serious changed, made it barely working. 

Code is not improved yet and would need some maintenance. 

Automatic Tests not working due to the nature the tests were original programmed (you need to provide actual token etc.)

Available as PyPI package under https://pypi.org/project/ebay-feedsdk/

Example code to retrieve oauth token and download file (you need working ebay-config.yaml)
```
import logging

from errors.custom_exceptions import DownloadError
from feed import Feed
from filter.feed_filter import GetFeedResponse
from oauthclient.credentialutil import Credentialutil
from oauthclient.model.model import Environment, OauthToken, EnvType
from oauthclient.oauth2api import Oauth2api


class EbayDownloadExample:
    app_scopes = ["https://api.ebay.com/oauth/api_scope", "https://api.ebay.com/oauth/api_scope/buy.item.feed"]
    config_file = 'ebay-config.yaml'

    def __init__(self, market_place: str, env: EnvType, feed_scope, download_location: str):
        self.env = env
        self.feed_scope = feed_scope
        self.market_place = market_place
        self.download_location = download_location

    def download(self, category_id: str):
        logging.info(
            f'Downloading category {category_id} for {self.market_place} with scope {self.feed_scope}'
            f'to {self.download_location}')

        token = self.get_token()

        feed_obj = Feed(feed_type='item', feed_scope=self.feed_scope, category_id=category_id,
                        marketplace_id=self.market_place,
                        token=token.access_token, environment=self.env.name, download_location=self.download_location)

        feed_response: GetFeedResponse = feed_obj.get()

        if feed_response.status_code != 0:
            raise DownloadError(f'Download failed see: {feed_response.message}')

        logging.info(f'File was downloaded under {feed_response.file_path}')

        return feed_response.file_path

    def get_token(self) -> OauthToken:
        Credentialutil.load(self.config_file)
        oauth2api = Oauth2api()

        token = oauth2api.get_application_token(self.env, self.app_scopes)
        if not token.access_token:
            raise DownloadError(f'Got no token, check: {token.error}')

        return token


if __name__ == "__main__":
    market_place = 'EBAY_DE'
    feed_scope = 'ALL_ACTIVE'
    download_location = '/tmp/feed'
    category_id = '2984'  # string ..
    ebay_download = EbayDownloadExample(market_place, Environment.PRODUCTION, feed_scope, download_location)
    file_path = ebay_download.download(category_id)
```
See also for details:

* [https://github.com/eBay/ebay-oauth-python-client/blob/master/README.adoc](https://github.com/eBay/ebay-oauth-python-client/blob/master/README.adoc)
* [https://github.com/eBay/FeedSDK-Python/blob/master/README.md](https://github.com/eBay/FeedSDK-Python/blob/master/README.md)

