Skip to content

Commit 03cd3e4

Browse files
Merge pull request #18 from JaviCerveraIngram/contactinfo
ContactInfo, Contact and PhoneNumber models
2 parents 23da37f + e830119 commit 03cd3e4

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

connect/models/contact.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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)

connect/models/tiers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from marshmallow import Schema, fields, post_load
99

1010
from .base import BaseModel, BaseSchema
11+
from .contact import ContactInfoSchema
1112

1213

1314
class Tier(BaseModel):
@@ -16,7 +17,7 @@ class Tier(BaseModel):
1617

1718
class TierSchema(BaseSchema):
1819
name = fields.Str()
19-
contact_info = fields.Dict()
20+
contact_info = fields.Nested(ContactInfoSchema)
2021
external_id = fields.Str()
2122
external_uid = fields.UUID()
2223

0 commit comments

Comments
 (0)