UNPKG

8.48 kBTypeScriptView Raw
1export declare type ContactFieldType = '*' | 'addresses' | 'birthday' | 'categories' | 'country' | 'department' | 'displayName' | 'emails' | 'familyName' | 'formatted' | 'givenName' | 'honorificPrefix' | 'honorificSuffix' | 'id' | 'ims' | 'locality' | 'middleName' | 'name' | 'nickname' | 'note' | 'organizations' | 'phoneNumbers' | 'photos' | 'postalCode' | 'region' | 'streetAddress' | 'title' | 'urls';
2/**
3 * @private
4 */
5export interface IContactProperties {
6 /** A globally unique identifier. */
7 id?: string;
8 /** The name of this Contact, suitable for display to end users. */
9 displayName?: string;
10 /** An object containing all components of a persons name. */
11 name?: IContactName;
12 /** A casual name by which to address the contact. */
13 nickname?: string;
14 /** An array of all the contact's phone numbers. */
15 phoneNumbers?: IContactField[];
16 /** An array of all the contact's email addresses. */
17 emails?: IContactField[];
18 /** An array of all the contact's addresses. */
19 addresses?: IContactAddress[];
20 /** An array of all the contact's IM addresses. */
21 ims?: IContactField[];
22 /** An array of all the contact's organizations. */
23 organizations?: IContactOrganization[];
24 /** The birthday of the contact. */
25 birthday?: Date;
26 /** A note about the contact. */
27 note?: string;
28 /** An array of the contact's photos. */
29 photos?: IContactField[];
30 /** An array of all the user-defined categories associated with the contact. */
31 categories?: IContactField[];
32 /** An array of web pages associated with the contact. */
33 urls?: IContactField[];
34}
35/**
36 * @private
37 */
38export declare class Contact implements IContactProperties {
39 private _objectInstance;
40 id: string;
41 displayName: string;
42 name: IContactName;
43 nickname: string;
44 phoneNumbers: IContactField[];
45 emails: IContactField[];
46 addresses: IContactAddress[];
47 ims: IContactField[];
48 organizations: IContactOrganization[];
49 birthday: Date;
50 note: string;
51 photos: IContactField[];
52 categories: IContactField[];
53 urls: IContactField[];
54 constructor();
55 clone(): Contact;
56 remove(): Promise<any>;
57 save(): Promise<any>;
58}
59/**
60 * @private
61 */
62export interface IContactError {
63 /** Error code */
64 code: number;
65 /** Error message */
66 message: string;
67}
68/**
69 * @private
70 */
71export declare var ContactError: {
72 new (code: number): IContactError;
73 UNKNOWN_ERROR: number;
74 INVALID_ARGUMENT_ERROR: number;
75 TIMEOUT_ERROR: number;
76 PENDING_OPERATION_ERROR: number;
77 IO_ERROR: number;
78 NOT_SUPPORTED_ERROR: number;
79 PERMISSION_DENIED_ERROR: number;
80};
81export interface IContactName {
82 /** The complete name of the contact. */
83 formatted?: string;
84 /** The contact's family name. */
85 familyName?: string;
86 /** The contact's given name. */
87 givenName?: string;
88 /** The contact's middle name. */
89 middleName?: string;
90 /** The contact's prefix (example Mr. or Dr.) */
91 honorificPrefix?: string;
92 /** The contact's suffix (example Esq.). */
93 honorificSuffix?: string;
94}
95/**
96 * @private
97 */
98export declare class ContactName implements IContactName {
99 formatted: string;
100 familyName: string;
101 givenName: string;
102 middleName: string;
103 honorificPrefix: string;
104 honorificSuffix: string;
105 constructor(formatted?: string, familyName?: string, givenName?: string, middleName?: string, honorificPrefix?: string, honorificSuffix?: string);
106}
107export interface IContactField {
108 /** A string that indicates what type of field this is, home for example. */
109 type?: string;
110 /** The value of the field, such as a phone number or email address. */
111 value?: string;
112 /** Set to true if this ContactField contains the user's preferred value. */
113 pref?: boolean;
114}
115/**
116 * @private
117 */
118export declare class ContactField implements IContactField {
119 type: string;
120 value: string;
121 pref: boolean;
122 constructor(type?: string, value?: string, pref?: boolean);
123}
124export interface IContactAddress {
125 /** Set to true if this ContactAddress contains the user's preferred value. */
126 pref?: boolean;
127 /** A string indicating what type of field this is, home for example. */
128 type?: string;
129 /** The full address formatted for display. */
130 formatted?: string;
131 /** The full street address. */
132 streetAddress?: string;
133 /** The city or locality. */
134 locality?: string;
135 /** The state or region. */
136 region?: string;
137 /** The zip code or postal code. */
138 postalCode?: string;
139 /** The country name. */
140 country?: string;
141}
142/**
143 * @private
144 */
145export declare class ContactAddress implements IContactAddress {
146 pref: boolean;
147 type: string;
148 formatted: string;
149 streetAddress: string;
150 locality: string;
151 region: string;
152 postalCode: string;
153 country: string;
154 constructor(pref?: boolean, type?: string, formatted?: string, streetAddress?: string, locality?: string, region?: string, postalCode?: string, country?: string);
155}
156export interface IContactOrganization {
157 /** Set to true if this ContactOrganization contains the user's preferred value. */
158 pref?: boolean;
159 /** A string that indicates what type of field this is, home for example. */
160 type?: string;
161 /** The name of the organization. */
162 name?: string;
163 /** The department the contract works for. */
164 department?: string;
165 /** The contact's title at the organization. */
166 title?: string;
167}
168/**
169 * @private
170 */
171export declare class ContactOrganization implements IContactOrganization {
172 type: string;
173 name: string;
174 department: string;
175 title: string;
176 pref: boolean;
177 constructor(type?: string, name?: string, department?: string, title?: string, pref?: boolean);
178}
179/** Search options to filter navigator.contacts. */
180export interface IContactFindOptions {
181 /** The search string used to find navigator.contacts. */
182 filter?: string;
183 /** Determines if the find operation returns multiple navigator.contacts. Defaults to false. */
184 multiple?: boolean;
185 /** Contact fields to be returned back. If specified, the resulting Contact object only features values for these fields. */
186 desiredFields?: string[];
187 /**
188 * (Android only): Filters the search to only return contacts with a phone number informed.
189 */
190 hasPhoneNumber?: boolean;
191}
192/**
193 * @private
194 */
195export declare class ContactFindOptions implements IContactFindOptions {
196 filter: string;
197 multiple: boolean;
198 desiredFields: string[];
199 hasPhoneNumber: boolean;
200 constructor(filter?: string, multiple?: boolean, desiredFields?: string[], hasPhoneNumber?: boolean);
201}
202/**
203 * @name Contacts
204 * @description
205 * Access and manage Contacts on the device.
206 *
207 * @usage
208 *
209 * ```typescript
210 * import { Contacts, Contact, ContactField, ContactName } from 'ionic-native';
211 *
212 *
213 * let contact: Contact = Contacts.create();
214 *
215 * contact.name = new ContactName(null, 'Smith', 'John');
216 * contact.phoneNumbers = [new ContactField('mobile', '6471234567')];
217 * contact.save().then(
218 * () => console.log('Contact saved!', contact),
219 * (error: any) => console.error('Error saving contact.', error)
220 * );
221 *
222 * ```
223 * @interfaces
224 * IContactProperties
225 * IContactError
226 * IContactName
227 * IContactField
228 * IContactAddress
229 * IContactOrganization
230 * IContactFindOptions
231 */
232export declare class Contacts {
233 /**
234 * Create a single contact.
235 * @returns {Contact} Returns a Contact object
236 */
237 static create(): Contact;
238 /**
239 * Search for contacts in the Contacts list.
240 * @param fields {ContactFieldType[]} Contact fields to be used as a search qualifier
241 * @param options {IContactFindOptions} Optional options for the query
242 * @returns {Promise<Contact[]>} Returns a Promise that resolves with the search results (an array of Contact objects)
243 */
244 static find(fields: ContactFieldType[], options?: IContactFindOptions): Promise<Contact[]>;
245 /**
246 * Select a single Contact.
247 * @returns {Promise<Contact>} Returns a Promise that resolves with the selected Contact
248 */
249 static pickContact(): Promise<Contact>;
250}
251
\No newline at end of file