anitabyte / etsyv3

Python client for the Etsy OpenAPI v3
GNU General Public License v3.0
58 stars 24 forks source link

Implemented Create/UpdateShopSection, UpdateShop #10

Closed d-winch closed 1 year ago

d-winch commented 1 year ago

Create Shop Section https://developers.etsy.com/documentation/reference#operation/createShopSection

Usage:

shop_section = CreateShopSectionRequest(title="Test Title")
etsy_api.create_shop_section(
    shop_id=SHOP_ID,
    shop_section_request=shop_section_request
)

{'shop_section_id': 42877511, 'title': 'Test Title', 'rank': 12, 'user_id': 111111111, 'active_listing_count': 0}

Update Shop Section https://developers.etsy.com/documentation/reference#operation/updateShopSection Usage:

shop_section_request = UpdateShopSectionRequest(title="Test Title 2")
etsy_api.update_shop_section(
    shop_id=SHOP_ID,
    shop_section_id=SHOP_SECTION_ID,
    shop_section_request=shop_section_request
)

{'shop_section_id': 42877511, 'title': 'Test Title 2', 'rank': 12, 'user_id': 111111111, 'active_listing_count': 0}

Update Shop https://developers.etsy.com/documentation/reference#operation/updateShop

Usage:

shop_request = UpdateShopRequest(title="Test Title")  
etsy_api.update_shop(
    shop_id=SHOP_ID,
    shop_request=shop_request
)

{"shop_id": 11111111,
"shop_name": "My Shop",
"user_id": 111111111,
"create_date": 1606925019,
"created_timestamp": 1606925019,
"title": "Test Title",
 ...
}

I created the file shop_request.py to keep shop requests out of listing_request.py. In doing so, I had to import Request from listing_request.py.

It may be wise to extract Request into its own file and keep different kinds of request classes in their own files and import Request into them. I didn't want to go changing too much though.

Thanks again for the library! 😀