contacts_client 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/padma_contact.rb +2 -1
- data/app/models/tag.rb +58 -0
- metadata +50 -58
data/app/models/padma_contact.rb
CHANGED
@@ -28,7 +28,7 @@ class PadmaContact < LogicalModel
|
|
28
28
|
:telephone, # Primary telephone (contact attribute)
|
29
29
|
:in_active_merge
|
30
30
|
]
|
31
|
-
self.has_many_keys = [:contact_attributes, :attachments]
|
31
|
+
self.has_many_keys = [:contact_attributes, :attachments, :tags]
|
32
32
|
self.use_api_key = true
|
33
33
|
self.api_key_name = "app_key"
|
34
34
|
self.api_key = Contacts::API_KEY
|
@@ -42,6 +42,7 @@ class PadmaContact < LogicalModel
|
|
42
42
|
|
43
43
|
validates_associated :contact_attributes
|
44
44
|
validates_associated :attachments
|
45
|
+
validates_associated :tags
|
45
46
|
|
46
47
|
def json_root
|
47
48
|
:contact
|
data/app/models/tag.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
class Tag < LogicalModel
|
2
|
+
attr_accessor :name
|
3
|
+
|
4
|
+
self.attribute_keys = [:_id, :name, :contact_ids, :account_name]
|
5
|
+
|
6
|
+
self.hydra = Contacts::HYDRA
|
7
|
+
self.resource_path = "/v0/tags"
|
8
|
+
self.use_api_key = true
|
9
|
+
self.api_key_name = "app_key"
|
10
|
+
self.api_key = Contacts::API_KEY
|
11
|
+
self.host = Contacts::HOST
|
12
|
+
|
13
|
+
validates :name, :presence => true
|
14
|
+
|
15
|
+
def json_root
|
16
|
+
:tag
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_key
|
20
|
+
[self._id]
|
21
|
+
end
|
22
|
+
|
23
|
+
def id
|
24
|
+
self._id
|
25
|
+
end
|
26
|
+
|
27
|
+
def id= id
|
28
|
+
self._id = id
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
# Returns all the tags associated with a given account
|
33
|
+
def self.account_tags(account_name)
|
34
|
+
params = { account_name: account_name }
|
35
|
+
params = self.merge_key(params)
|
36
|
+
|
37
|
+
|
38
|
+
response = nil
|
39
|
+
Timeout::timeout(self.timeout/1000) do
|
40
|
+
response = Typhoeus::Request.get( "#{url_protocol_prefix}#{self.host}/v0/accounts/#{account_name}/tags", :params => params, :timeout => self.timeout )
|
41
|
+
end
|
42
|
+
|
43
|
+
if response.code == 200
|
44
|
+
log_ok(response)
|
45
|
+
result_set = self.from_json(response.body)
|
46
|
+
return result_set[:collection]
|
47
|
+
elsif response.code == 400
|
48
|
+
log_failed(response)
|
49
|
+
return false
|
50
|
+
else
|
51
|
+
log_failed(response)
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
rescue Timeout::Error
|
55
|
+
self.logger.warn "timeout"
|
56
|
+
return nil
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,66 +1,61 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: contacts_client
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 10
|
9
|
-
version: 0.0.10
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.11
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Dwayne Macgowan
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: railties
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 3
|
30
|
-
- 1
|
31
|
-
version: "3.1"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: logical_model
|
36
23
|
prerelease: false
|
37
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: logical_model
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
38
33
|
none: false
|
39
|
-
requirements:
|
34
|
+
requirements:
|
40
35
|
- - ~>
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
- 4
|
45
|
-
- 1
|
36
|
+
- !ruby/object:Gem::Version
|
46
37
|
version: 0.4.1
|
47
38
|
type: :runtime
|
48
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.4.1
|
49
46
|
description: This is client library for padma-Contacts-ws
|
50
|
-
email:
|
47
|
+
email:
|
51
48
|
- dwaynemac@gmail.com
|
52
49
|
executables: []
|
53
|
-
|
54
50
|
extensions: []
|
55
|
-
|
56
51
|
extra_rdoc_files: []
|
57
|
-
|
58
|
-
files:
|
52
|
+
files:
|
59
53
|
- app/validators/email_format_validator.rb
|
60
54
|
- app/models/date_attribute.rb
|
61
55
|
- app/models/address.rb
|
62
56
|
- app/models/identification.rb
|
63
57
|
- app/models/email.rb
|
58
|
+
- app/models/tag.rb
|
64
59
|
- app/models/telephone.rb
|
65
60
|
- app/models/custom_attribute.rb
|
66
61
|
- app/models/social_network_id.rb
|
@@ -74,37 +69,34 @@ files:
|
|
74
69
|
- lib/contacts/railties.rb
|
75
70
|
- lib/contacts/belongs_to_contact.rb
|
76
71
|
- config/initializers/contacts_client.rb
|
77
|
-
|
78
|
-
homepage: ""
|
72
|
+
homepage: ''
|
79
73
|
licenses: []
|
80
|
-
|
81
74
|
post_install_message:
|
82
75
|
rdoc_options: []
|
83
|
-
|
84
|
-
require_paths:
|
76
|
+
require_paths:
|
85
77
|
- lib
|
86
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
79
|
none: false
|
88
|
-
requirements:
|
89
|
-
- -
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
segments:
|
92
85
|
- 0
|
93
|
-
|
94
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
hash: -735541987
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
88
|
none: false
|
96
|
-
requirements:
|
97
|
-
- -
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
segments:
|
100
94
|
- 0
|
101
|
-
|
95
|
+
hash: -735541987
|
102
96
|
requirements: []
|
103
|
-
|
104
97
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.
|
98
|
+
rubygems_version: 1.8.25
|
106
99
|
signing_key:
|
107
100
|
specification_version: 3
|
108
101
|
summary: Client library for padma-contacts-ws
|
109
102
|
test_files: []
|
110
|
-
|