-
Notifications
You must be signed in to change notification settings - Fork 2
/
cordova_contacts.mli
285 lines (259 loc) · 11.1 KB
/
cordova_contacts.mli
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
(* -------------------------------------------------------------------------- *)
type field =
| Addresses [@js "addresses" ]
| Birthday [@js "birthday" ]
| Categories [@js "categories"]
| Country [@js "country"]
| Department [@js "department"]
| Display_name [@js "displayName"]
| Emails [@js "emails"]
| Family_name [@js "familyName"]
| Formatted [@js "formatted"]
| Given_name [@js "givenName"]
| Honorific_prefix [@js "honorificPrefix"]
| Honorific_suffix [@js "honorificSuffix"]
| Id [@js "id"]
| Ims [@js "ims"]
| Locality [@js "locality"]
| Middle_name [@js "middleName"]
| Name [@js "name"]
| Nickname [@js "nickname"]
| Note [@js "note"]
| Organizations [@js "organizations"]
| Phone_numbers [@js "phoneNumbers"]
| Photos [@js "photos"]
| Postal_code [@js "postalCode"]
| Region [@js "region"]
| Street_address [@js "streetAddress"]
| Title [@js "title"]
| Urls [@js "urls"]
[@@js.enum]
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
type error =
| Unknown_error [@js 0]
| Invalid_argument_error [@js 1]
| Timeout_error [@js 2]
| Pending_operation_error [@js 3]
| Io_error [@js 4]
| Not_supported_error [@js 5]
| Operation_cancelled_error [@js 6]
| Permission_denied_error [@js 20]
[@@js.enum]
module ContactError: sig
type t
val code : t -> error [@@js.get]
end
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
module ContactField: sig
type t
val type_: t -> string [@@js.get "type"]
val value: t -> string [@@js.get]
val pref : t -> bool [@@js.get]
end
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
module ContactName: sig
type t
val formatted : t -> string option [@@js.get]
val family_name : t -> string option [@@js.get]
val given_name : t -> string option [@@js.get]
val middle_name : t -> string option [@@js.get]
val honorific_prefix : t -> string option [@@js.get]
val honorific_suffix : t -> string option [@@js.get]
end
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
module ContactAddress: sig
type t
val create_contact_address :
(* Set to true if this ContactAddress contains the user's preferred
* value. *)
?pref:bool ->
(* A string indicating what type of field this is, home for example. *)
?type_:(string [@js "type"]) ->
(* The full address formatted for display. *)
?formatted:string ->
(* The full street address. *)
?street_address:string ->
(* The city or locality. *)
?locality:string ->
(* The state or region. *)
?region:string ->
(* The zip code or postal code. *)
?postal_code:string ->
(* The country name. *)
?country:string ->
unit ->
t
[@@js.builder]
val pref : t -> bool
val type_ : t -> string option [@@js.get "type"]
val formatted : t -> string option
val street_address : t -> string option
val locality : t -> string option
val region : t -> string option
val postal_code : t -> string option
val country : t -> string option
end
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
module ContactOrganization: sig
type t
val create_contact_organization :
(* Set to true if this ContactOrganization contains the user's preferred
* value. *)
?pref:bool ->
(* A string that indicates what type of field this is, home for example. *)
?type_:string option ->
(* The name of the organization. *)
?name:string option ->
(* The department the contract works for. *)
?department:string option ->
(* The contact's title at the organization. *)
?title:string option ->
unit ->
t
[@@js.builder]
val pref : t -> bool
val type_ : t -> string option
val name : t -> string option
val department : t -> string option
val title : t -> string option
end
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
module Contact : sig
type t
val create_contact :
?display_name:string ->
?name:ContactName.t ->
?nick_name:string ->
?phone_numbers:ContactField.t list ->
?emails:ContactField.t list ->
?addresses:ContactAddress.t list ->
?ims:ContactField.t list ->
?organizations:ContactOrganization.t list ->
?birthday:Js_date.t ->
?note:string ->
?photos:ContactField.t list ->
?categories:ContactField.t list ->
?urls:ContactField.t list ->
unit ->
t
[@@js.builder]
(* A globally unique identifier. *)
val id : t -> string option
(* The name of this Contact, suitable for display to end users. *)
val display_name : t -> string option
(* An object containing all components of a persons name. *)
val name : t -> ContactName.t option
(* A casual name by which to address the contact. *)
val nick_name : t -> string option
(* An array of all the contact's phone numbers. *)
val phone_numbers : t -> ContactField.t list option
(* A list of all the contact's email addresses. *)
val emails : t -> ContactField.t list option
(* A list of all the contact's addresses. *)
val addresses : t -> ContactAddress.t list option
(* A list of all the contact's IM addresses. *)
val ims : t -> ContactField.t list option
(* A list of all the contact's organizations. *)
val organizations : t -> ContactOrganization.t list option
(* The birthday of the contact. *)
(* Js_date is defined in the binding of the javascript standard library. See
* documentation *)
val birthday : t -> Js_date.t option
(* A note about the contact. *)
val note : t -> string option
(* A list of the contact's photos. *)
val photos : t -> ContactField.t list option
(* A list of all the user-defined categories associated with the contact. *)
val categories : t -> ContactField.t list option
(* A list of web pages associated with the contact. *)
val urls : t -> ContactField.t list option
val clone : t -> t
(* Removes the contact from the device contacts database, otherwise executes
* an error callback with a ContactError object.
* remove [success_callback] [error_callback]
* *)
val remove : (unit -> unit) ->
(ContactError.t -> unit) ->
unit
(* Saves a new contact to the device contacts database, or updates an
* existing contact if a contact with the same id already exists.
* save [success_callback] [error_callback]
* *)
val save : (t -> unit) ->
(ContactError.t -> unit) ->
unit
end
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
module ContactFindOptions: sig
type t
val create_contact_find_options :
?filter : (string [@js.default ""]) ->
?multiple : (bool [@js.default false]) ->
?desired_fields : (field list option [@js.default None]) ->
?has_phone_number : (bool [@js.default false]) ->
unit ->
t
[@@js.builder]
val filter : t -> string
val multiple : t -> bool
val desired_fields : t -> string list option
val has_phone_number : t -> bool
end
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
module Contacts: sig
type t
(* ---------------------------------------------------------------------- *)
(* The navigator.contacts.create method is synchronous, and returns a new
* Contact object.
* This method does not retain the Contact object in the device contacts
* database, for which you need to invoke the Contact.save method. *)
val create : ?contact:Contact.t -> unit -> Contact.t
(* ---------------------------------------------------------------------- *)
(* ---------------------------------------------------------------------- *)
(* This val executes asynchronously, querying the device contacts
* database and returning an list of Contact objects.
* The resulting objects are passed to the contactSuccess callback
* function specified by the contactSuccess
* parameter. *)
(* find [fields] [success_callback] *)
val find : string list ->
(Contact.t list -> unit) ->
unit
(* find [fields] [success_callback] [error_callback] *)
val find_err : string list ->
(Contact.t list -> unit) ->
(string -> unit) ->
unit
[@@js.call "find"]
(* find [fields] [success_callback] [error_callback] [find_options] *)
val find_opt : string ->
(Contact.t list -> unit) ->
(string -> unit) ->
ContactFindOptions.t ->
unit
[@@js.call "find"]
(* ---------------------------------------------------------------------- *)
(* ---------------------------------------------------------------------- *)
(* The navigator.contacts.pickContact method launches the Contact Picker to
* select a single contact. The resulting object is passed to the
* contactSuccess callback function specified by the contactSuccess
* parameter. *)
(* pick_contact [success_cb] *)
val pick_contact : (Contact.t -> unit) ->
unit
(* pick_contact [success_cb] [error_cb] *)
val pick_contact_err : (Contact.t -> unit) ->
(string -> unit) ->
unit
[@@js.call "pickContact"]
(* ---------------------------------------------------------------------- *)
end
[@js.scope "navigator.contacts"]