collegiatelink 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/collegiatelink/client.rb +9 -1
- data/lib/collegiatelink/organization.rb +49 -0
- metadata +2 -2
@@ -18,10 +18,11 @@ module CollegiateLink
|
|
18
18
|
@opts = {
|
19
19
|
sharedkey: sharedkey,
|
20
20
|
}
|
21
|
+
@@proxy = Net::HTTP
|
21
22
|
end
|
22
23
|
|
23
24
|
def self.proxy
|
24
|
-
@@proxy
|
25
|
+
@@proxy
|
25
26
|
end
|
26
27
|
|
27
28
|
def use_socks_proxy(host, port)
|
@@ -68,6 +69,13 @@ module CollegiateLink
|
|
68
69
|
events.map{ |o| CollegiateLink::Event.parse(o.to_s) }
|
69
70
|
end
|
70
71
|
|
72
|
+
def roster(id, params = {})
|
73
|
+
params.merge!(:id => id)
|
74
|
+
|
75
|
+
members = request('organization/roster', params)
|
76
|
+
members.map{ |m| CollegiateLink::Member.parse(m.to_s) }
|
77
|
+
end
|
78
|
+
|
71
79
|
private
|
72
80
|
|
73
81
|
def request(action, params = {})
|
@@ -100,4 +100,53 @@ module CollegiateLink
|
|
100
100
|
|
101
101
|
has_one :organization, Organization
|
102
102
|
end
|
103
|
+
|
104
|
+
##
|
105
|
+
# A position of someone in an organization
|
106
|
+
#
|
107
|
+
class Position
|
108
|
+
include HappyMapper
|
109
|
+
|
110
|
+
element :name, String
|
111
|
+
element :enddate, Integer
|
112
|
+
element :startdate, Integer
|
113
|
+
element :userstartdate, Integer
|
114
|
+
element :userenddate, Integer
|
115
|
+
|
116
|
+
def current?
|
117
|
+
use_startdate = (userstartdate > 0) ? userstartdate : startdate
|
118
|
+
indefinite = (userenddate < 0) && (enddate < 0)
|
119
|
+
|
120
|
+
starts = Time.at(use_startdate / 1000, use_startdate % 1000)
|
121
|
+
|
122
|
+
if indefinite
|
123
|
+
return (starts < Time.now)
|
124
|
+
else
|
125
|
+
use_enddate = (userenddate > 0) ? userenddate : enddate
|
126
|
+
ends = Time.at(use_enddate / 1000, use_enddate % 1000)
|
127
|
+
return (starts < Time.now && Time.now < ends)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
##
|
133
|
+
# A Member record returned by CollegiateLink
|
134
|
+
#
|
135
|
+
class Member
|
136
|
+
include HappyMapper
|
137
|
+
|
138
|
+
#element :affiliation # Not sure the format of this...
|
139
|
+
element :campusemail, String
|
140
|
+
element :firstname, String
|
141
|
+
element :id, Integer
|
142
|
+
element :lastname, String
|
143
|
+
element :preferredemail, String
|
144
|
+
element :username, String
|
145
|
+
|
146
|
+
has_many :positions, Position
|
147
|
+
|
148
|
+
def active_positions
|
149
|
+
positions.keep_if { |p| p.current? }
|
150
|
+
end
|
151
|
+
end
|
103
152
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collegiatelink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
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: 2012-01-
|
12
|
+
date: 2012-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guid
|