contacts_client 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/models/tag.rb +31 -1
- metadata +2 -2
data/app/models/tag.rb
CHANGED
@@ -35,4 +35,34 @@ class Tag < LogicalModel
|
|
35
35
|
def self.account_tags(account_name)
|
36
36
|
paginate(per_page: 999, account_name: account_name)
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
|
+
def self.batch_add(tags, contact_ids, account_name)
|
40
|
+
params = { account_name: account_name, tags: tags, contact_ids: contact_ids }
|
41
|
+
params = self.merge_key(params)
|
42
|
+
|
43
|
+
response = nil
|
44
|
+
Timeout::timeout(self.timeout/1000) do
|
45
|
+
response = Typhoeus::Request.post("#{url_protocol_prefix}#{self.host}/v0/accounts/#{account_name}/tags/batch_add",
|
46
|
+
:params => params,
|
47
|
+
:timeout => self.timeout)
|
48
|
+
end
|
49
|
+
|
50
|
+
if response.code == 201 || response.code == 202
|
51
|
+
log_ok(response)
|
52
|
+
return true
|
53
|
+
elsif response.code == 400
|
54
|
+
log_failed(response)
|
55
|
+
ws_errors = ActiveSupport::JSON.decode(response.body)["errors"]
|
56
|
+
ws_errors.each_key do |k|
|
57
|
+
self.errors.add k, ws_errors[k]
|
58
|
+
end
|
59
|
+
return false
|
60
|
+
else
|
61
|
+
log_failed(response)
|
62
|
+
return nil
|
63
|
+
end
|
64
|
+
rescue Timeout::Error
|
65
|
+
self.class.logger.warn "timeout"
|
66
|
+
return nil
|
67
|
+
end
|
68
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|