forked from sNKS/rhodes-api-docs
/
rhocontact-api.txt
270 lines (233 loc) · 6.96 KB
/
rhocontact-api.txt
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
# Rho::RhoContact API
Provides access to a device's phone book and contacts. For a code example, see the view and controller in the [/app/Contacts folder in the System API Samples](https://github.com/rhomobile/rhodes-system-api-samples/blob/master/app/Contacts/controller.rb) application.
## Enabling the Contacts
To use the RhoContact API, you need to enable read and write for the contacts on the device. Do this by adding that capability to the build.yml file:
:::yaml
capabilities:
- pim
## find
Returns the contacts in the device phone book.
:::ruby
Rho::RhoContact.find(argument list)
The argument list can consist of the following arguments.
<table border="1">
<tr>
<td><code>:all</code></td>
<td>Return a hash of hashes of all the contacts in the phonebook.</td>
</tr>
<tr>
<td><code>id</code></td>
<td>return a hash of the properties of the contact identified by this id.</td>
</tr>
</table>
For Android, you can have the following arguments.
<table border="1">
<tr>
<td><code>:first</code></td>
<td>return the first contact in the list.</td>
</tr>
<tr>
<td><code>:count</code></td>
<td>return the total number of contacts in the list.</td>
</tr>
</table>
When you use the `:all`, `:first`, or `:count` arguments with Android or iOS, you can also use the following optional arguments to paginate the contact list. If used with :count, the exact number of returned contacts can be determined (for example for last page).
<table border="1">
<tr>
<td><code>:per_page</code></td>
<td>maximum number of contacts to return.</td>
</tr>
<tr>
<td><code>:offset</code></td>
<td>offset from the beginning of the list.</td>
</tr>
<tr>
<td><code>:max_results</code></td>
<td>used with :count. maximum number of contacts to be returned.</td>
</tr>
<tr>
<td><code>:select</code></td>
<td>Android only. array of string attributes to return with the object. Useful if your contacts have many attributes and your query only needs a few of them. Sample call: <code>companylastnamelist = Phonebook.find(:all, :select => ['last_name','company_name'])</code>
</td>
</tr>
<tr>
<td><code>:conditions</code></td>
<td>Android only. A hash of conditions. </code>
</td>
</tr>
</table>
The :conditions argument will select all contacts that have at least one phone number. The conditions supported are not_nil and is_nil.
:::ruby
@count = Rho::RhoContact.find(:count, :conditions => {:phone => 'not_nil'})
## create!
Create a new contact in the phonebook, setting its properties passed as a parameter hash.
:::ruby
Rho::RhoContact.create!(contact)
<table border="1">
<tr>
<td><code>contact</code></td>
<td>A hash containing the contact properties.</td>
</tr>
</table>
## destroy
Delete this contact from the phonebook.
:::ruby
Rho::RhoContact.destroy(id)
<table border="1">
<tr>
<td><code>id</code></td>
<td>Delete the contact identified by this id</td>
</tr>
</table>
## update_attributes
Create a new contact in the phonebook, setting its properties passed as a parameter hash.
:::ruby
Rho::RhoContact.update_attributes(contact)
<table border="1">
<tr>
<td><code>contact</code></td>
<td>A hash containing the contact properties to change for this contact.</td>
</tr>
</table>
## Contact Properties
The contact properties are stored in a hash.
<table border="1">
<tr>
<td><code>id</code></td>
<td>int. The id for this contact.</td>
</tr>
<tr>
<td><code>first_name</code></td>
<td>String. The first name for this contact.</td>
</tr>
<tr>
<td><code>last_name</code></td>
<td>String. The last name for this contact.</td>
</tr>
<tr>
<td><code>mobile_number</code></td>
<td>String. The mobile phone number for this contact.</td>
</tr>
<tr>
<td><code>business_number</code></td>
<td>String. The business phone number for this contact.</td>
</tr>
<tr>
<td><code>email_address</code></td>
<td>String. The email address for this contact. On iPhone, mapped to "work".</td>
</tr>
<tr>
<td><code>company_name</code></td>
<td>String. The company name for this contact.</td>
</tr>
</table>
### Additional Contact Properties for Android Nexus
Android uses these contact properties (stored in a hash).
<table border="1">
<tr>
<td><code>display_name</code></td>
<td>String. The display name for this contact.</td>
</tr>
<tr>
<td><code>home_number</code></td>
<td>String. The home phone number for this contact.</td>
</tr>
</table>
### Additional Contact Properties for iPhone
<table border="1">
<tr>
<td><code>prefix</code></td>
<td>String. The prefix for the name, such as "Mr."</td>
</tr>
<tr>
<td><code>middle_name</code></td>
<td>String. The middle name for this contact.</td>
</tr>
<tr>
<td><code>suffix</code></td>
<td>String. The suffix for this contact, such as "Jr."</td>
</tr>
<tr>
<td><code>nickname</code></td>
<td>String. The nickname for this contact.</td>
</tr>
<tr>
<td><code>birthday</code></td>
<td>String. The birthday for this contact, formatted as YYYY-MM-DD.</td>
</tr>
<tr>
<td><code>anniversary</code></td>
<td>String. The anniversary for this contact, formatted as YYYY-MM-DD.</td>
</tr>
<tr>
<td><code>created</code></td>
<td>String. The date this contact was created, formatted as YYYY-MM-DD.</td>
</tr>
<tr>
<td><code>updated</code></td>
<td>String. The most recent date this contact was updated, formatted as YYYY-MM-DD.</td>
</tr>
<tr>
<td><code>company_name</code></td>
<td>String. The company name for this contact.</td>
</tr>
<tr>
<td><code>job_title</code></td>
<td>String. The job title for this contact.</td>
</tr>
<tr>
<td><code>assistant_name</code></td>
<td>String. The name of the assistant for this contact.</td>
</tr>
<tr>
<td><code>assistant_number</code></td>
<td>String. The phone number of the assistant for this contact.</td>
</tr>
<tr>
<td><code>spouse_name</code></td>
<td>String. The name of the spouse for this contact.</td>
</tr>
<tr>
<td><code>person_note</code></td>
<td>String. A note for this contact.</td>
</tr>
<tr>
<td><code>home_email_address</code></td>
<td>String. Home email address for this contact.</td>
</tr>
<tr>
<td><code>other_email_address</code></td>
<td>String. Other email address for this contact.</td>
</tr>
<tr>
<td><code>other_email_address</code></td>
<td>String. Other email address for this contact.</td>
</tr>
<tr>
<td><code>home_page</code></td>
<td>String. url of the contact's home page.</td>
</tr>
<tr>
<td><code>main_number</code></br>
<code>pager_number</code></br>
<code>home_fax</code></br>
<code>work_fax</code></br>
</td>
<td>Strings. Additonal phone numbers for iPhone.</td>
</tr>
</table>
### Additional Address Properties for iPhone
<table border="1">
<tr>
<td><code>Address properties mapped to "work"</code></td>
<td>Strings. "street_address_1", "city_1", "state_1", "zip_1", "country_1"</td>
</tr>
<tr>
<td><code>Address properties mapped to "home"</code></td>
<td>Strings. "street_address_2", "city_2", "state_2", "zip_2", "country_2"</td>
</tr>
<tr>
<td><code>Address properties mapped to "other"</code></td>
<td>Strings. "street_address_3", "city_3", "state_3", "zip_3", "country_3"</td>
</tr>
</table>