Skip to content

Instantly share code, notes, and snippets.

View maiksprenger's full-sized avatar

Maik Sprenger maiksprenger

View GitHub Profile
@maiksprenger
maiksprenger / etsy_client.py
Created January 5, 2022 17:19
Etsy API v3: Change price for a given SKU
# Excerpt for https://github.com/etsy/open-api/issues/27
# Untested, unproven, don't use this in production!
def _make_request(method, url, data=None):
with open("etsy_token.json", "r") as f:
token = json.loads(f.read())
oauth = OAuth2Session(client_id, token=token)
oauth.refresh_token(
"https://api.etsy.com/v3/public/oauth/token", client_id=client_id
)
@maiksprenger
maiksprenger / unixdatetimefield.py
Last active December 5, 2022 10:21
Django Rest Framework Unix Timestamp Field
class UnixTimestampField(serializers.FloatField):
"""
Stores Django datetimes as a Unix timestamp.
Thank you to Laur Ivan for the inspiration:
https://www.laurivan.com/timestamp-to-datetime-serializer-field-for-drf/
"""
def to_internal_value(self, value):
"""