contact_sync 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/contact_sync/syncable.rb +24 -19
- data/lib/contact_sync/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26d68d12a21bf1a35d0c0e9f7992b93555b86af8
|
4
|
+
data.tar.gz: e43cd2f1ceecce72e477a2c03d97735a12e6a674
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2b09f6a4d89b9040fb4fadcb86139e31b82741ae116aed519453822486ffe8b968c8af37f9a92684d70f86ab88cfa3c741ba97e30ff9033ea503f4445f3581b
|
7
|
+
data.tar.gz: 272d6f5dbdc9a3e0b3963cf06f818b1f8c5dcff5212a6077134c5cca5ee50af9aa4897866fff7948c3d8a807d88b1a8ba040eae43ff463d06cbc0dba9c551334
|
@@ -18,9 +18,9 @@ module ContactSync
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
def sync_contacts(contact_hash = {})
|
21
|
-
result = {:new => {success:[], failed:[]}, modified: {success:[], failed:[]}, deleted: {success:[], failed:[]}}
|
21
|
+
result = {:new => {success:[], failed:[], duplicate: []}, modified: {success:[], failed:[]}, deleted: {success:[], failed:[]}}
|
22
22
|
raise ArgumentError, "You need to provide contacts hash." if contact_hash.blank?
|
23
|
-
|
23
|
+
raise ArgumentError, "You need to provide Device Identifier as deviceID" if contact_hash[:device_id].blank?
|
24
24
|
##########################################################################
|
25
25
|
#########################Create new Contacts##############################
|
26
26
|
if !contact_hash[:new].blank?
|
@@ -31,23 +31,28 @@ module ContactSync
|
|
31
31
|
|
32
32
|
aContact.delete :phones
|
33
33
|
aContact.delete :emails
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
phones
|
38
|
-
|
34
|
+
begin
|
35
|
+
newContact = Contact.new(contact_params(aContact))
|
36
|
+
newContact.device_id = contact_hash[:device_id]
|
37
|
+
if phones
|
38
|
+
phones.each do |aPhone|
|
39
|
+
newContact.phones.build(phone_params(aPhone))
|
40
|
+
end
|
39
41
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
if emails
|
43
|
+
emails.each do |anEmail|
|
44
|
+
newContact.emails.build(email_params(anEmail))
|
45
|
+
end
|
44
46
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
if newContact.save
|
48
|
+
# result[:new][:success] << newContact.record_id
|
49
|
+
self.contacts << newContact
|
50
|
+
else
|
51
|
+
result[:new][:failed] << newContact.record_id
|
52
|
+
end
|
53
|
+
rescue ActiveRecord::RecordNotUnique => e
|
54
|
+
puts "Rescuing Duplicate Record"
|
55
|
+
result[:new][:duplicate] << newContact.record_id
|
51
56
|
end
|
52
57
|
end
|
53
58
|
end
|
@@ -139,11 +144,11 @@ module ContactSync
|
|
139
144
|
end
|
140
145
|
|
141
146
|
def phone_params aPhone
|
142
|
-
aPhone.permit(:label, :number)
|
147
|
+
aPhone.permit(:label, :number, :encrypted_number, :cc_prefix)
|
143
148
|
end
|
144
149
|
|
145
150
|
def email_params anEmail
|
146
|
-
anEmail.permit(:label, :email)
|
151
|
+
anEmail.permit(:label, :email, :encrypted_email)
|
147
152
|
end
|
148
153
|
|
149
154
|
def after_contact_sync
|
data/lib/contact_sync/version.rb
CHANGED