-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support-upgrade: Etsy Release ([3.0.0 General Release 2024-07-01] til…
…l [3.0.0 General Release 2024-11-20])
- Loading branch information
1 parent
03e2ba7
commit 369a213
Showing
4 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters