contacts_client 0.0.27 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/models/padma_contact.rb +58 -33
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDAyNzU4ZGEyYjczMGY4NWMxYjQwYTJmNjJjYzliNWY1ZDNiMWQ2YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTRiMmYzNDc5MzVhYzVmZjkyMGQwMjVmNjMxOTJjM2MzZTk0ODY2MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWI2ZGUzZWNjYjViYTY1YmMyMzZhNmZhMTI4NzA3ZDU4ZTdhZWVmODIwZjUx
|
10
|
+
ZGM5YjA0Yzc4OTMyOTI2MzVjNTI0NWRkNTBlZDA2MzAwNWZhN2QyNDEzNDMz
|
11
|
+
MTJiODI2YmUxZDA2NzYxMmEzNGE0OTdmMGM3MWQ2NTkwNWJkMWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2VjOGM3ODk2YTJlODY1NTUwYmM0ZTY3ZDNiYmE2Zjg0NzE4Y2IyNWEwNTk5
|
14
|
+
NzNmMDk3NzkwMGZiYWRjOWE4YTdkNzA0YTFiYmNlMWRlNjA3Y2U5ZmYwNmY3
|
15
|
+
YzY3ODJlZTI4ZWQxMzBiZjA3ZDk0YmE3M2E5ODJkZDYzNjU5Nzk=
|
data/app/models/padma_contact.rb
CHANGED
@@ -3,39 +3,39 @@
|
|
3
3
|
# Configuration for LogicalModel on /config/initializers/contacts_client.rb
|
4
4
|
class PadmaContact < LogicalModel
|
5
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
|
-
|
6
|
+
use_hydra Contacts::HYDRA
|
7
|
+
|
8
|
+
set_resource_url Contacts::HOST,'/v0/contacts'
|
9
|
+
set_api_key :app_key, Contacts::API_KEY
|
10
|
+
|
11
|
+
attribute :_id
|
12
|
+
attribute :first_name
|
13
|
+
attribute :last_name
|
14
|
+
attribute :gender
|
15
|
+
attribute :estimated_age
|
16
|
+
attribute :avatar
|
17
|
+
attribute :status
|
18
|
+
attribute :local_status # will only be setted if #find specifies account_name
|
19
|
+
attribute :local_statuses
|
20
|
+
attribute :last_seen_at # will only be setted if #find specifies account_name
|
21
|
+
attribute :last_local_status
|
22
|
+
attribute :local_teacher
|
23
|
+
attribute :global_teacher_username
|
24
|
+
attribute :level
|
25
|
+
attribute :coefficient # will only be setted if #find specifies account_name
|
26
|
+
attribute :coefficients_counts
|
27
|
+
attribute :owner_name
|
28
|
+
attribute :linked # will only be setted if #find specifies account_name
|
29
|
+
attribute :check_duplicates
|
30
|
+
attribute :email # Primary email (contact attribute)
|
31
|
+
attribute :telephone # Primary telephone (contact attribute)
|
32
|
+
attribute :in_active_merge
|
33
|
+
attribute :observation
|
34
|
+
attribute :in_professional_training
|
35
|
+
|
36
|
+
has_many :contact_attributes
|
37
|
+
has_many :attachments
|
38
|
+
has_many :tags
|
39
39
|
|
40
40
|
self.enable_delete_multiple = true
|
41
41
|
|
@@ -208,6 +208,31 @@ class PadmaContact < LogicalModel
|
|
208
208
|
return nil
|
209
209
|
end
|
210
210
|
|
211
|
+
DEFAULT_BATCH_SIZE = 500
|
212
|
+
MAX_FAILS = 5
|
213
|
+
##
|
214
|
+
#
|
215
|
+
# @return [Array] contacts
|
216
|
+
# @return nil if connection failed
|
217
|
+
def self.batch_search(search_options = {}, batch_options = {})
|
218
|
+
batch_options[:batch_size] ||= DEFAULT_BATCH_SIZE
|
219
|
+
ret = [];
|
220
|
+
|
221
|
+
page_elements = nil; page = 1; fails = 0;
|
222
|
+
until page_elements == [] || fails >= MAX_FAILS do
|
223
|
+
page_elements = PadmaContact.search(search_options.merge(per_page: batch_options[:batch_size], page: page))
|
224
|
+
if page_elements
|
225
|
+
ret += page_elements
|
226
|
+
page += 1
|
227
|
+
else
|
228
|
+
fails += 1
|
229
|
+
end
|
230
|
+
fails = 0
|
231
|
+
end
|
232
|
+
|
233
|
+
return (fails >= MAX_FAILS)? nil : ret
|
234
|
+
end
|
235
|
+
|
211
236
|
##
|
212
237
|
# Search is same as paginate but will make POST /search request instead of GET /index
|
213
238
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contacts_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dwayne Macgowan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.6.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.6.0
|
41
41
|
description: This is client library for padma-Contacts-ws
|
42
42
|
email:
|
43
43
|
- dwaynemac@gmail.com
|