Skip to content

Commit

Permalink
Missing doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
krak3n committed Apr 10, 2015
1 parent 63dbc0b commit 24cd7af
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions fm/serializers/types/spotify.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#!/usr/bin/env python
# encoding: utf-8

"""
fm.serializers.types.spotify
============================
Custom Kim Field Types relating to Spotifu Validation
"""

import httplib
import kim.types as t
import requests
Expand All @@ -7,13 +17,38 @@


class SpotifyURI(t.String):
""" Custom field which validates a Spotify URI with the spotify API. On
marshal the returl value will be the decoded JSON data from the Spotify
API.
"""

track = None

def marshal_value(self, value):
""" Return track data, if present, else returns None.
Arguments
---------
value : str
The Spotiy URI
Returns
-------
dict or None
Track data from validation or None if not valid
"""

return self.track

def validate(self, value):
""" Validates the value with Spotify.
Arguments
---------
value : str
The Spotiy URI
"""

id = value.split(':')[-1]
endpoint = 'https://api.spotify.com/v1/tracks/{0}'.format(id)

Expand Down

0 comments on commit 24cd7af

Please sign in to comment.