/
contact.idl
93 lines (78 loc) · 2.15 KB
/
contact.idl
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// Error codes
// -----------
//
// * `100` - Invalid Input
// * `101` - Permission Denied
// * `102` - Limit Exceeded
// Services
// --------
//
// The ContactService keeps track of addresses for users.
// All data is partitioned by userId, which is a string UUID
interface ContactService {
// Adds or updates the contact
// If the contactId field is not set, the server will create a UUID for it
// If the userId has more than 10 contacts, a "Limit Exceeded" error is returned
//
// Returns the UUID of the contact
put(contact Contact) string
// Returns the contact with the given contactId
//
// If no contact exists with this id, a null result is returned
//
// If the contact exists but is not associated with the provided
// userId, then a "Permission Denied" error is returned
get(contactId string, userId string) Contact [optional]
// Returns all contacts for the given user
// If the user has no contacts, an empty list is returned
getAll(userId string) []Contact
// Deletes the contact with the given contactId
//
// If the contact exists but is not associated with the provided
// userId, then a "Permission Denied" error is returned
//
// Returns false if no contact is found with this contactId
// Returns true if the contact is found and is associated with the
// provided userId
delete(contactId string, userId string) bool
}
// Data Structures
// ---------------
// Types of phone numbers
enum PhoneType {
home
work
mobile
}
// A single contact
struct Contact {
// Key of the contact. Must be globally unique.
contactId string
// User ID that owns the contact
userId string
// User's name
firstName string
lastName string
// Email address
email string
// Contacts can have 0..5 phones
phones []Phone
// Contacts may optionally have an address
address Address [optional]
}
struct Address {
street1 string
street2 string [optional]
city string
state string
postalCode string
country string
}
// A single phone number
// All fields are required
struct Phone {
type PhoneType
countryCode int
number int
}