collegiatelink 0.2.0 → 0.3.0
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/lib/collegiatelink/client.rb +16 -11
- data/lib/collegiatelink/request.rb +4 -4
- metadata +2 -2
@@ -6,17 +6,22 @@ module CollegiateLink
|
|
6
6
|
# Creates a CollegiateLink client.
|
7
7
|
#
|
8
8
|
# ==== Parameters:
|
9
|
-
# * +
|
10
|
-
#
|
11
|
-
#
|
9
|
+
# * +options+ - A hash containing the following values:
|
10
|
+
# * +apikey+ - The CollegiateLink "apikey"
|
11
|
+
# * +ip+ - (Optional) The IP address that the +apikey+ is approved for,
|
12
|
+
# if and only if that is how the +apikey+ is configured on CollegiateLink's
|
13
|
+
# side.
|
14
|
+
# * +privatekey+ - The shared key granted by CollegiateLink to your IP and
|
15
|
+
# institution.
|
12
16
|
#
|
13
|
-
def initialize(
|
17
|
+
def initialize(options = {})
|
14
18
|
@params = {
|
15
|
-
apikey: apikey,
|
16
|
-
ip: ip,
|
19
|
+
apikey: options[:apikey],
|
17
20
|
}
|
21
|
+
@params.merge(ip: options[:ip]) if options[:ip]
|
22
|
+
|
18
23
|
@opts = {
|
19
|
-
|
24
|
+
privatekey: options[:privatekey],
|
20
25
|
}
|
21
26
|
@@proxy = Net::HTTP
|
22
27
|
end
|
@@ -40,7 +45,7 @@ module CollegiateLink
|
|
40
45
|
# See CollegiateLink::Request#initialize for a list of optional parameters
|
41
46
|
#
|
42
47
|
def organizations(params = {})
|
43
|
-
|
48
|
+
request('organizations', CollegiateLink::Organization, params)
|
44
49
|
end
|
45
50
|
|
46
51
|
def financetransactions(params = {})
|
@@ -49,7 +54,7 @@ module CollegiateLink
|
|
49
54
|
params[:startdate] ||= (Time.now.to_i - seven_days)
|
50
55
|
params[:startdate] = params[:startdate].to_i * 1000
|
51
56
|
|
52
|
-
|
57
|
+
request('financetransactions', CollegiateLink::FinanceTransaction, params)
|
53
58
|
end
|
54
59
|
|
55
60
|
##
|
@@ -73,13 +78,13 @@ module CollegiateLink
|
|
73
78
|
params[:startdate] = params[:startdate].to_i * 1000
|
74
79
|
params[:enddate] = params[:enddate].to_i * 1000
|
75
80
|
|
76
|
-
|
81
|
+
request('events', CollegiateLink::Event, params)
|
77
82
|
end
|
78
83
|
|
79
84
|
def roster(id, params = {})
|
80
85
|
params.merge!(:organizationId => id)
|
81
86
|
|
82
|
-
|
87
|
+
request('memberships', CollegiateLink::Member, params)
|
83
88
|
end
|
84
89
|
|
85
90
|
private
|
@@ -18,7 +18,7 @@ module CollegiateLink
|
|
18
18
|
# Options are ways to pass in additional parameters about the request. The
|
19
19
|
# following options are supported.
|
20
20
|
#
|
21
|
-
# * <tt>:
|
21
|
+
# * <tt>:privatekey</tt> - (Required) The shared key which is used, but not included in the URL of requests
|
22
22
|
# * <tt>:debug</tt> - Print debug information as the request happens.
|
23
23
|
#
|
24
24
|
def initialize(action, params = {}, opts = {})
|
@@ -26,7 +26,7 @@ module CollegiateLink
|
|
26
26
|
@params = params
|
27
27
|
@opts = opts
|
28
28
|
|
29
|
-
raise AuthenticationException unless opts.include?(:
|
29
|
+
raise AuthenticationException unless opts.include?(:privatekey)
|
30
30
|
|
31
31
|
if NEW_ACTIONS.include?(action)
|
32
32
|
@opts[:url_base] ||= 'https://casewestern.collegiatelink.net/api/'
|
@@ -52,7 +52,7 @@ module CollegiateLink
|
|
52
52
|
time: Time.now.to_i * 1000,
|
53
53
|
random: Guid.new
|
54
54
|
})
|
55
|
-
request_params[:hash] = hash(request_params.merge(
|
55
|
+
request_params[:hash] = hash(request_params.merge(privatekey: @opts[:privatekey]))
|
56
56
|
|
57
57
|
# Then, compute the URL...
|
58
58
|
url = URI([
|
@@ -134,7 +134,7 @@ module CollegiateLink
|
|
134
134
|
params[:ip],
|
135
135
|
params[:time].to_i,
|
136
136
|
params[:random],
|
137
|
-
params[:
|
137
|
+
params[:privatekey],
|
138
138
|
].join
|
139
139
|
end
|
140
140
|
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.
|
4
|
+
version: 0.3.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:
|
12
|
+
date: 2014-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guid
|