forked from alexaorrico/AirBnB_clone_v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amenity.py
executable file
·30 lines (26 loc) · 861 Bytes
/
amenity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python
""" holds class Amenity"""
import models
from models.base_model import BaseModel, Base
import sqlalchemy
from sqlalchemy import Column, String
from sqlalchemy.orm import relationship
class Amenity(BaseModel, Base):
"""Representation of Amenity"""
if models.storage_t == 'db':
__tablename__ = 'amenities'
name = Column(String(128), nullable=False)
else:
name = ""
def __init__(self, *args, **kwargs):
"""Initializes Amenity"""
super().__init__(*args, **kwargs)
def to_dict(self):
"""Returns a dictionary representation of the Amenity instance"""
dictionary = {
"id": self.id,
"created_at": self.created_at.isoformat(),
"updated_at": self.updated_at.isoformat(),
"name": self.name
}
return dictionary