collegiatelink 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/collegiatelink.rb +3 -7
- data/lib/collegiatelink/client.rb +4 -4
- data/lib/collegiatelink/member.rb +36 -53
- data/lib/collegiatelink/organization.rb +38 -46
- data/lib/collegiatelink/request.rb +2 -5
- metadata +3 -3
data/lib/collegiatelink.rb
CHANGED
@@ -21,15 +21,11 @@ require 'collegiatelink/member'
|
|
21
21
|
#
|
22
22
|
module CollegiateLink
|
23
23
|
# Currently-supported CollegiateLink action request types
|
24
|
-
OLD_ACTIONS = [
|
25
|
-
'organization/list',
|
26
|
-
'organization/roster',
|
27
|
-
#'user/memberships',
|
28
|
-
#'user/position',
|
29
|
-
'event/list',
|
30
|
-
]
|
31
24
|
NEW_ACTIONS = [
|
25
|
+
'organizations',
|
32
26
|
'financetransactions',
|
27
|
+
'events',
|
28
|
+
'memberships',
|
33
29
|
]
|
34
30
|
|
35
31
|
# Raised when performing a CollegiateLink::Request for an action that is not
|
@@ -40,7 +40,7 @@ module CollegiateLink
|
|
40
40
|
# See CollegiateLink::Request#initialize for a list of optional parameters
|
41
41
|
#
|
42
42
|
def organizations(params = {})
|
43
|
-
orgs = request('
|
43
|
+
orgs = request('organizations', CollegiateLink::Organization, params)
|
44
44
|
end
|
45
45
|
|
46
46
|
def financetransactions(params = {})
|
@@ -73,13 +73,13 @@ module CollegiateLink
|
|
73
73
|
params[:startdate] = params[:startdate].to_i * 1000
|
74
74
|
params[:enddate] = params[:enddate].to_i * 1000
|
75
75
|
|
76
|
-
events = request('
|
76
|
+
events = request('events', CollegiateLink::Event, params)
|
77
77
|
end
|
78
78
|
|
79
79
|
def roster(id, params = {})
|
80
|
-
params.merge!(:
|
80
|
+
params.merge!(:organizationId => id)
|
81
81
|
|
82
|
-
members = request('
|
82
|
+
members = request('memberships', CollegiateLink::Member, params)
|
83
83
|
end
|
84
84
|
|
85
85
|
private
|
@@ -1,73 +1,56 @@
|
|
1
1
|
module CollegiateLink
|
2
|
+
|
2
3
|
##
|
3
|
-
# A
|
4
|
+
# A Member record returned by CollegiateLink
|
4
5
|
#
|
5
|
-
class
|
6
|
-
include Representable::
|
6
|
+
class Member < OpenStruct
|
7
|
+
include Representable::JSON
|
8
|
+
|
9
|
+
property :membershipId
|
10
|
+
property :organizationId
|
11
|
+
property :organizationName
|
12
|
+
property :organizationShortName
|
13
|
+
property :positionTemplate
|
14
|
+
property :positionTypeName
|
15
|
+
property :positionId
|
16
|
+
property :positionName
|
17
|
+
property :userId
|
18
|
+
property :username
|
19
|
+
property :userFirstName
|
20
|
+
property :userLastName
|
21
|
+
property :userCampusEmail
|
22
|
+
property :preferredemail
|
23
|
+
property :positionRecordedStartDate
|
24
|
+
property :positionRecordedEndDate
|
25
|
+
property :positionReportedStartDate
|
26
|
+
property :positionReportedEndDate
|
7
27
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
property :userstartdate
|
12
|
-
property :userenddate
|
28
|
+
def id
|
29
|
+
membershipId
|
30
|
+
end
|
13
31
|
|
14
32
|
def current?
|
15
|
-
use_startdate =
|
16
|
-
|
33
|
+
if (use_startdate = positionReportedStartDate.to_i) == 0
|
34
|
+
use_startdate = positionRecordedStartDate.to_i
|
35
|
+
end
|
36
|
+
if (use_enddate = positionReportedEndDate.to_i) == 0
|
37
|
+
use_enddate = positionRecordedEndDate.to_i
|
38
|
+
end
|
39
|
+
|
40
|
+
indefinite = (positionReportedEndDate.to_i <= 0) && (positionRecordedEndDate.to_i <= 0)
|
17
41
|
|
18
42
|
starts = Time.at(use_startdate / 1000, use_startdate % 1000)
|
19
43
|
|
20
44
|
if indefinite
|
21
45
|
return (starts < Time.now)
|
22
46
|
else
|
23
|
-
use_enddate = (userenddate.to_i > 0) ? userenddate.to_i : enddate.to_i
|
24
47
|
ends = Time.at(use_enddate / 1000, use_enddate % 1000)
|
25
48
|
return (starts < Time.now && Time.now < ends)
|
26
49
|
end
|
27
50
|
end
|
28
|
-
end
|
29
|
-
|
30
|
-
module PositionRepresenter
|
31
|
-
include Representable::XML
|
32
|
-
|
33
|
-
property :name
|
34
|
-
property :enddate
|
35
|
-
property :startdate
|
36
|
-
property :userstartdate
|
37
|
-
property :userenddate
|
38
|
-
end
|
39
|
-
|
40
|
-
class PositionList < OpenStruct
|
41
|
-
include Representable::XML
|
42
|
-
|
43
|
-
collection :positions, :extend => PositionRepresenter, :class => Position, :as => :position
|
44
|
-
end
|
45
|
-
|
46
|
-
##
|
47
|
-
# A Member record returned by CollegiateLink
|
48
|
-
#
|
49
|
-
class Member < OpenStruct
|
50
|
-
include Representable::XML
|
51
|
-
|
52
|
-
#property :affiliation # Not sure the format of this...
|
53
|
-
property :campusemail
|
54
|
-
property :firstname
|
55
|
-
property :id
|
56
|
-
property :lastname
|
57
|
-
property :preferredemail
|
58
|
-
property :username
|
59
|
-
property :positionList, :class => PositionList, :as => :positions
|
60
|
-
|
61
|
-
def positions
|
62
|
-
positionList.positions
|
63
|
-
end
|
64
|
-
|
65
|
-
def active_positions
|
66
|
-
positions.keep_if { |p| p.current? }
|
67
|
-
end
|
68
51
|
|
69
|
-
def self.parse(
|
70
|
-
|
52
|
+
def self.parse(json)
|
53
|
+
new(json)
|
71
54
|
end
|
72
55
|
end
|
73
56
|
end
|
@@ -41,35 +41,32 @@ module CollegiateLink
|
|
41
41
|
|
42
42
|
##
|
43
43
|
# An Organization record returned by CollegiateLink
|
44
|
-
# See: http://support.collegiatelink.net/entries/332558-web-services-developer-documentation#orgList
|
45
|
-
#
|
46
|
-
# ==== Properties:
|
47
|
-
# * <tt>:id </tt> - Integer
|
48
|
-
# * <tt>:parentId</tt> - Integer
|
49
|
-
# * <tt>:name </tt> - String
|
50
|
-
# * <tt>:description </tt> - String
|
51
|
-
# * <tt>:shortName </tt> - String
|
52
|
-
# * <tt>:siteUrl </tt> - String
|
53
|
-
# * <tt>:status </tt> - String
|
54
|
-
# * <tt>:type </tt> - String
|
55
|
-
# * <tt>:addresses </tt> - Array of CollegiateLink::Address
|
56
|
-
# * <tt>:categories </tt> - Array of CollegiateLink::Category
|
57
44
|
class Organization < OpenStruct
|
58
|
-
include Representable::
|
45
|
+
include Representable::JSON
|
59
46
|
|
60
|
-
property :
|
61
|
-
property :parentId
|
47
|
+
property :organizationId
|
62
48
|
property :name
|
63
|
-
property :description
|
64
|
-
property :shortName
|
65
|
-
property :siteUrl
|
66
49
|
property :status
|
67
|
-
property :
|
68
|
-
|
69
|
-
|
50
|
+
property :shortName
|
51
|
+
property :summary
|
52
|
+
property :description
|
53
|
+
property :addressStreet1
|
54
|
+
property :addressStreet2
|
55
|
+
property :addressCity
|
56
|
+
property :addressStateProvince
|
57
|
+
property :addressZipPostal
|
58
|
+
property :phoneNumber
|
59
|
+
property :email
|
60
|
+
property :externalWebsite
|
61
|
+
property :facebookUrl
|
62
|
+
property :twitterUrl
|
63
|
+
property :profileUrl
|
64
|
+
property :typeId
|
65
|
+
property :typeName
|
66
|
+
property :parentId
|
70
67
|
|
71
|
-
def self.parse(
|
72
|
-
|
68
|
+
def self.parse(json)
|
69
|
+
new(json)
|
73
70
|
end
|
74
71
|
end
|
75
72
|
|
@@ -77,33 +74,28 @@ module CollegiateLink
|
|
77
74
|
# An Event record returned by CollegiateLink
|
78
75
|
# See: http://support.collegiatelink.net/entries/332558-web-services-developer-documentation#eventList
|
79
76
|
#
|
80
|
-
# ==== Properties:
|
81
|
-
# * <tt>:id </tt> - Integer
|
82
|
-
# * <tt>:name </tt> - String
|
83
|
-
# * <tt>:description</tt> - String
|
84
|
-
# * <tt>:startDate </tt> - Integer
|
85
|
-
# * <tt>:endDate </tt> - Integer
|
86
|
-
# * <tt>:location </tt> - String
|
87
|
-
# * <tt>:status </tt> - String
|
88
|
-
# * <tt>:urlLarge </tt> - String
|
89
|
-
# * <tt>:urlSmall </tt> - String
|
90
|
-
# * <tt>:organization</tt> - The hosting Organization (..todo?)
|
91
|
-
#
|
92
77
|
class Event < OpenStruct
|
93
|
-
include Representable::
|
78
|
+
include Representable::JSON
|
94
79
|
|
95
|
-
property :
|
96
|
-
property :
|
80
|
+
property :eventId
|
81
|
+
property :eventName
|
82
|
+
property :organizationId
|
83
|
+
property :organizationName
|
84
|
+
property :startDateTime
|
85
|
+
property :endDateTime
|
86
|
+
property :externalLocationId
|
87
|
+
property :locationId
|
88
|
+
property :otherLocation
|
89
|
+
# properties for address here...
|
97
90
|
property :description
|
98
|
-
property :
|
99
|
-
property :
|
100
|
-
property :
|
91
|
+
property :flyerUrl
|
92
|
+
property :thumbnailUrl
|
93
|
+
property :typeId
|
94
|
+
property :typeName
|
101
95
|
property :status
|
102
|
-
property :urlLarge
|
103
|
-
property :urlSmall
|
104
96
|
|
105
|
-
def self.parse(
|
106
|
-
|
97
|
+
def self.parse(json)
|
98
|
+
new(json)
|
107
99
|
end
|
108
100
|
end
|
109
101
|
|
@@ -28,11 +28,8 @@ module CollegiateLink
|
|
28
28
|
|
29
29
|
raise AuthenticationException unless opts.include?(:sharedkey)
|
30
30
|
|
31
|
-
if
|
32
|
-
@opts[:url_base] ||= 'https://casewestern.collegiatelink.net/
|
33
|
-
@opts[:response_format] = 'XML'
|
34
|
-
elsif NEW_ACTIONS.include?(action)
|
35
|
-
@opts[:url_base] ||= 'https://casewestern.collegiatelink.net/api/' % @params[:apikey]
|
31
|
+
if NEW_ACTIONS.include?(action)
|
32
|
+
@opts[:url_base] ||= 'https://casewestern.collegiatelink.net/api/'
|
36
33
|
@opts[:response_format] = 'JSON'
|
37
34
|
else
|
38
35
|
raise UnknownAction, 'Action not supported!'
|
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.
|
4
|
+
version: 0.2.0
|
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-
|
12
|
+
date: 2012-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guid
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
description:
|
111
|
-
email:
|
111
|
+
email: tomdooner@gmail.com
|
112
112
|
executables: []
|
113
113
|
extensions: []
|
114
114
|
extra_rdoc_files: []
|