pass a dictionary with device attributes rather than the attributes themselves
parent
6849cfa0c5
commit
02cc26ffa4
|
@ -76,18 +76,14 @@ class DeviceRepository(object):
|
||||||
# TODO: Remove the @ in the API v2
|
# TODO: Remove the @ in the API v2
|
||||||
return {'@type': rate_period} if rate_period is not None else {'@type': 'free'}
|
return {'@type': rate_period} if rate_period is not None else {'@type': 'free'}
|
||||||
|
|
||||||
def add_device(self, account_id: str, name: str, wake_word_id: str, text_to_speech_id: str, geography_id: str) -> str:
|
def add_device(self, account_id: str, device: dict) -> str:
|
||||||
""" Creates a new device with a given name and associate it to an account"""
|
"""Insert a row on the device table"""
|
||||||
# TODO: validate foreign keys
|
db_request_args = dict(account_id=account_id)
|
||||||
|
db_request_args.update(device)
|
||||||
|
del(db_request_args['pairing_code'])
|
||||||
query = DatabaseRequest(
|
query = DatabaseRequest(
|
||||||
sql=get_sql_from_file(path.join(SQL_DIR, 'add_device.sql')),
|
sql=get_sql_from_file(path.join(SQL_DIR, 'add_device.sql')),
|
||||||
args=dict(
|
args=db_request_args
|
||||||
account_id=account_id,
|
|
||||||
name=name,
|
|
||||||
wake_word_id=wake_word_id,
|
|
||||||
text_to_speech_id=text_to_speech_id,
|
|
||||||
geography_id=geography_id
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
result = self.cursor.insert_returning(query)
|
result = self.cursor.insert_returning(query)
|
||||||
return result['id']
|
return result['id']
|
||||||
|
|
Loading…
Reference in New Issue