Adding URL to download premium voices
parent
d90e80d463
commit
32f7363d1f
|
@ -23,6 +23,7 @@ from .endpoints.device_subscription import DeviceSubscriptionEndpoint
|
|||
from .endpoints.google_stt import GoogleSTTEndpoint
|
||||
from .endpoints.oauth_callback import OauthCallbackEndpoint
|
||||
from .endpoints.open_weather_map import OpenWeatherMapEndpoint
|
||||
from .endpoints.premium_voice import PremiumVoiceEndpoint
|
||||
from .endpoints.wolfram_alpha import WolframAlphaEndpoint
|
||||
from .endpoints.wolfram_alpha_spoken import WolframAlphaSpokenEndpoint
|
||||
|
||||
|
@ -130,13 +131,18 @@ public.add_url_rule(
|
|||
methods=['GET']
|
||||
)
|
||||
|
||||
public.add_url_rule(
|
||||
'/v1/device/<string:device_id>/voice',
|
||||
view_func=PremiumVoiceEndpoint.as_view('premium_voice_api'),
|
||||
methods=['GET']
|
||||
)
|
||||
|
||||
public.add_url_rule(
|
||||
'/v1/device/<string:device_id>/<string:oauth_path>/<string:credentials>',
|
||||
view_func=OauthServiceEndpoint.as_view('oauth_api'),
|
||||
methods=['GET']
|
||||
)
|
||||
|
||||
|
||||
"""
|
||||
This is a workaround to allow the API return 401 when we call a non existent path. Use case:
|
||||
GET /device/{uuid} with empty uuid. Core today uses the 401 to validate if it needs to perform a pairing process
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
import os
|
||||
from http import HTTPStatus
|
||||
|
||||
from selene.api import SeleneEndpoint
|
||||
from selene.data.account import AccountRepository
|
||||
|
||||
|
||||
class PremiumVoiceEndpoint(SeleneEndpoint):
|
||||
def __init__(self):
|
||||
super(PremiumVoiceEndpoint, self).__init__()
|
||||
|
||||
def get(self, device_id):
|
||||
self._authenticate()
|
||||
arch = self.request.args.get('arch')
|
||||
account = AccountRepository(self.db).get_account_by_device_id(device_id)
|
||||
if account and account.membership:
|
||||
link = self._get_premium_voice_link(arch)
|
||||
response = {'link': link}, HTTPStatus.OK
|
||||
else:
|
||||
response = '', HTTPStatus.NO_CONTENT
|
||||
return response
|
||||
|
||||
def _get_premium_voice_link(self, arch):
|
||||
if arch == 'arm':
|
||||
response = os.environ['URL_VOICE_ARM']
|
||||
elif arch == 'x86_86':
|
||||
response = os.environ['URL_VOICE_X86_64']
|
||||
else:
|
||||
response = ''
|
||||
return response
|
Loading…
Reference in New Issue