|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +""" |
| 4 | +This file is part of the Ingram Micro Cloud Blue Connect SDK. |
| 5 | +Copyright (c) 2019 Ingram Micro. All Rights Reserved. |
| 6 | +""" |
| 7 | + |
| 8 | +from marshmallow import fields, post_load |
| 9 | + |
| 10 | +from .base import BaseModel, BaseSchema |
| 11 | + |
| 12 | + |
| 13 | +class PhoneNumber(BaseModel): |
| 14 | + pass |
| 15 | + |
| 16 | + |
| 17 | +class PhoneNumberSchema(BaseSchema): |
| 18 | + country_code = fields.Str() |
| 19 | + area_code = fields.Str() |
| 20 | + phone_number = fields.Str() |
| 21 | + extension = fields.Str() |
| 22 | + |
| 23 | + @post_load |
| 24 | + def make_object(self, data): |
| 25 | + return PhoneNumber(**data) |
| 26 | + |
| 27 | + |
| 28 | +class Contact(BaseModel): |
| 29 | + pass |
| 30 | + |
| 31 | + |
| 32 | +class ContactSchema(BaseSchema): |
| 33 | + email = fields.Str() |
| 34 | + first_name = fields.Str() |
| 35 | + last_name = fields.Str() |
| 36 | + phone_number = fields.Nested(PhoneNumberSchema) |
| 37 | + |
| 38 | + @post_load |
| 39 | + def make_object(self, data): |
| 40 | + return Contact(**data) |
| 41 | + |
| 42 | + |
| 43 | +class ContactInfo(BaseModel): |
| 44 | + pass |
| 45 | + |
| 46 | + |
| 47 | +class ContactInfoSchema(BaseSchema): |
| 48 | + address_line1 = fields.Str() |
| 49 | + address_line2 = fields.Str() |
| 50 | + city = fields.Str() |
| 51 | + contact = fields.Nested(ContactSchema) |
| 52 | + country = fields.Str() |
| 53 | + postal_code = fields.Str() |
| 54 | + state = fields.Str() |
| 55 | + |
| 56 | + @post_load |
| 57 | + def make_object(self, data): |
| 58 | + return ContactInfo(**data) |
0 commit comments