Skip to content

Commit

Permalink
Merge pull request #2 from gisce/adding_models
Browse files Browse the repository at this point in the history
Adding models
  • Loading branch information
ecarreras committed Dec 19, 2013
2 parents e926384 + 6eaad61 commit dbd4ea5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
56 changes: 56 additions & 0 deletions empowering/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from marshmallow import Serializer, fields


class CustomerAddress(Serializer):
city = fields.String()
cityCode = fields.String()
countryCode = fields.String()
street = fields.String()
postalCode = fields.String()


class Customer(Serializer):
customerId = fields.UUID()
address = fields.Nested(CustomerAddress)


class Device(Serializer):
dateStart = fields.DateTime(format='iso')
dateEnd = fields.DateTime(format='iso')
deviceId = fields.UUID()


class Contract(Serializer):
companyId = fields.Integer()
ownerId = fields.UUID()
payerId = fields.UUID()
dateStart = fields.DateTime(format='iso')
dateEnd = fields.DateTime(format='iso')
contractId = fields.String()
tariffId = fields.String()
power = fields.Integer()
version = fields.Integer()
activityCode = fields.String()
meteringPointId = fields.UUID()
customer = fields.Nested(Customer)
devices = fields.List(fields.Nested(Device))


class Reading(Serializer):
type = fields.Selection(['electricityConsumption'])
unit = fields.Selection(['kWh', 'Wh'])
period = fields.Selection(['INSTANT', 'CUMULATIVE', 'PULSE'])


class Measurement(Serializer):
type = fields.Selection(['electricityConsumption'])
timestamp = fields.DateTime(format='iso')
value = fields.Float()


class AmonMeasure(Serializer):
companyId = fields.Integer()
deviceId = fields.UUID()
meteringPointId = fields.UUID()
readings = fields.List(fields.Nested(Reading))
measurements = fields.List(fields.Nested(Measurement))
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ ooop
times
libsaas
Flask
marshmallow
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

install_requires = [
'libsaas',
'marshmallow'
]

setup(
name='empowering',
version='0.1.0-alpha2',
version='0.2.0-alpha1',
author='GISCE-TI, S.L.',
author_email='[email protected]',
url='http://code.gisce.net/empowering',
Expand Down

0 comments on commit dbd4ea5

Please sign in to comment.