Skip to content

Commit

Permalink
support-upgrade: Etsy Release ([3.0.0 General Release 2024-07-01] til…
Browse files Browse the repository at this point in the history
…l [3.0.0 General Release 2024-11-20])
  • Loading branch information
amitray007 committed Nov 30, 2024
1 parent 03e2ba7 commit 369a213
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 1 deletion.
41 changes: 41 additions & 0 deletions etsy_python/v3/enums/HolidayPreferences.py
Original file line number Diff line number Diff line change
@@ -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"
20 changes: 20 additions & 0 deletions etsy_python/v3/models/HolidayPreferences.py
Original file line number Diff line number Diff line change
@@ -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,
)
29 changes: 29 additions & 0 deletions etsy_python/v3/resources/HolidayPreferences.py
Original file line number Diff line number Diff line change
@@ -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
)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 369a213

Please sign in to comment.