contacts_client 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/padma_contact.rb +11 -7
- metadata +2 -2
data/app/models/padma_contact.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# wrapper for PADMA-Contacts API interaction
|
3
|
-
# Configuration for LogicalModel on /config/initializers/
|
3
|
+
# Configuration for LogicalModel on /config/initializers/contacts_client.rb
|
4
4
|
class PadmaContact < LogicalModel
|
5
5
|
|
6
6
|
self.hydra = Contacts::HYDRA
|
@@ -99,27 +99,31 @@ class PadmaContact < LogicalModel
|
|
99
99
|
end
|
100
100
|
|
101
101
|
ContactAttribute::AVAILABLE_TYPES.each do |type|
|
102
|
-
define_method(type.to_s.pluralize)
|
102
|
+
define_method(type.to_s.pluralize) do
|
103
|
+
if self.contact_attributes
|
104
|
+
self.contact_attributes.reject { |attr| !attr.is_a? type.to_s.camelize.constantize }.sort_by { |x| [x.primary ? 0 : 1, x._id] }
|
105
|
+
end
|
106
|
+
end
|
103
107
|
end
|
104
108
|
|
105
109
|
def facebook_id
|
106
|
-
self.contact_attributes.select{|attr| attr.is_a?(SocialNetworkId) && attr.category == "facebook"}.first
|
110
|
+
self.contact_attributes.select{|attr| attr.is_a?(SocialNetworkId) && attr.category == "facebook"}.first if self.contact_attributes
|
107
111
|
end
|
108
112
|
|
109
113
|
def mobiles
|
110
|
-
self.contact_attributes.select{|attr| attr.is_a?(Telephone) && attr.category == "mobile"}
|
114
|
+
self.contact_attributes.select{|attr| attr.is_a?(Telephone) && attr.category == "mobile"} if self.contact_attributes
|
111
115
|
end
|
112
116
|
|
113
117
|
def non_mobile_phones
|
114
|
-
self.contact_attributes.select{|attr| attr.is_a?(Telephone) && attr.category != "mobile"}
|
118
|
+
self.contact_attributes.select{|attr| attr.is_a?(Telephone) && attr.category != "mobile"} if self.contact_attributes
|
115
119
|
end
|
116
120
|
|
117
121
|
def former_student_at
|
118
|
-
local_statuses.select{|s|s['value']=='former_student'}.map{|s|s['account_name']}
|
122
|
+
local_statuses.select{|s|s['value']=='former_student'}.map{|s|s['account_name']} if self.local_statuses
|
119
123
|
end
|
120
124
|
|
121
125
|
def prospect_at
|
122
|
-
local_statuses.select{|s|s['value']=='prospect'}.map{|s|s['account_name']}
|
126
|
+
local_statuses.select{|s|s['value']=='prospect'}.map{|s|s['account_name']} if self.local_statuses
|
123
127
|
end
|
124
128
|
|
125
129
|
# Returns age in years of the contact or nil if age not available
|
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.16
|
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-07-
|
12
|
+
date: 2013-07-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|