diff --git a/etsy_python/v3/enums/HolidayPreferences.py b/etsy_python/v3/enums/HolidayPreferences.py new file mode 100644 index 0000000..8ef6974 --- /dev/null +++ b/etsy_python/v3/enums/HolidayPreferences.py @@ -0,0 +1,41 @@ +from enum import Enum + +""" +Reference: +Official Documentation: https://developer.etsy.com/documentation/tutorials/fulfillment/#country-holidays +""" + +class HOLIDAYS(Enum): + """ + # Note: + 1. More Holidays are pending to be added, as Etsy only supports US and CA holidays as of Release (3.0.0 General Release 2024-07-24). + 2. String values from "1" till "105" are supported by Etsy based on selected regions. + """ + pass + +class US_HOLIDAYS(Enum): + NEW_YEARS_DAY = "1" + MARTIN_LUTHER_KING_JR_DAY = "2" + PRESIDENTS_DAY = "3" + MEMORIAL_DAY = "4" + JUNETEENTH = "5" + INDEPENDENCE_DAY = "6" + LABOR_DAY = "7" + COLUMBUS_DAY = "8" + VETERANS_DAY = "9" + THANKSGIVING_DAY = "10" + CHRISTMAS_DAY = "11" + +class CA_HOLIDAYS(Enum): + GOOD_FRIDAY = "12" + EASTER = "13" + VICTORIA_DAY = "14" + CANADA_DAY = "15" + TRUTH_AND_RECONCILIATION_DAY = "16" + REMEMBRANCE_DAY = "17" + CIVIC_HOLIDAY = "18" + BOXING_DAY = "19" + NEW_YEARS_DAY = "20" + LABOR_DAY = "21" + THANKSGIVING_DAY = "22" + CHRISTMAS_DAY = "23" diff --git a/etsy_python/v3/models/HolidayPreferences.py b/etsy_python/v3/models/HolidayPreferences.py new file mode 100644 index 0000000..6b89098 --- /dev/null +++ b/etsy_python/v3/models/HolidayPreferences.py @@ -0,0 +1,20 @@ +from typing import Optional + +from etsy_python.v3.models.Request import Request + +class UpdateHolidayPreferencesRequest(Request): + nullable = [ + ] + mandatory = [ + "is_working" + ] + + def __init__( + self, + is_working: Optional[bool] = False, + ): + self.is_working = is_working + super().__init__( + nullable=UpdateHolidayPreferencesRequest.nullable, + mandatory=UpdateHolidayPreferencesRequest.mandatory, + ) diff --git a/etsy_python/v3/resources/HolidayPreferences.py b/etsy_python/v3/resources/HolidayPreferences.py new file mode 100644 index 0000000..a3206c2 --- /dev/null +++ b/etsy_python/v3/resources/HolidayPreferences.py @@ -0,0 +1,29 @@ +from dataclasses import dataclass +from typing import Optional, Union + +from etsy_python.v3.enums.HolidayPreferences import CA_HOLIDAYS, HOLIDAYS, US_HOLIDAYS +from etsy_python.v3.models.HolidayPreferences import UpdateHolidayPreferencesRequest +from etsy_python.v3.resources.enums.Request import Method +from etsy_python.v3.exceptions.RequestException import RequestException +from etsy_python.v3.resources.Session import EtsyClient +from etsy_python.v3.resources.Response import Response + + +@dataclass +class HolidayPreferencesResource: + session: EtsyClient + + def get_holiday_preferences(self, shop_id: int) -> Union[Response, RequestException]: + endpoint = f"/shops/{shop_id}/holiday-preferences" + return self.session.make_request(endpoint) + + def update_holiday_preferences( + self, + shop_id: int, + holiday_id: Optional[Union[HOLIDAYS, US_HOLIDAYS, CA_HOLIDAYS, str]], + holiday_preference: UpdateHolidayPreferencesRequest, + ) -> Union[Response, RequestException]: + endpoint = f"/shops/{shop_id}/holiday-preferences/{holiday_id}" + return self.session.make_request( + endpoint, method=Method.PUT, payload=holiday_preference + ) diff --git a/setup.py b/setup.py index e7e41a0..4184b19 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh: long_description = "\n" + fh.read() -VERSION = "1.0.16" +VERSION = "1.0.17" DESCRIPTION = "Etsy API Client Library for Python" # Setting up