blackbaud-client 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +2 -1
- data/Gemfile +5 -0
- data/blackbaud-client.gemspec +5 -3
- data/lib/blackbaud-client/api/academic_year.rb +1 -5
- data/lib/blackbaud-client/api/blackbaud_object.rb +8 -0
- data/lib/blackbaud-client/api/class.rb +1 -5
- data/lib/blackbaud-client/api/code_table.rb +0 -8
- data/lib/blackbaud-client/api/code_table_entry.rb +5 -0
- data/lib/blackbaud-client/api/contact.rb +0 -7
- data/lib/blackbaud-client/api/person.rb +29 -6
- data/lib/blackbaud-client/api/relation.rb +16 -0
- data/lib/blackbaud-client/api/session.rb +1 -6
- data/lib/blackbaud-client/api/static_code_table.rb +0 -8
- data/lib/blackbaud-client/api/table_entry.rb +0 -8
- data/lib/blackbaud-client/api/term.rb +0 -8
- data/lib/blackbaud-client/version.rb +20 -0
- data/lib/blackbaud-client.rb +53 -22
- metadata +14 -11
- data/lib/blackbaud-client/api/contact_type.rb +0 -12
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDYxY2VhMGY4M2MzNWI4NGQ1NGYxYTg2YzVlNDg2ZjhiNzUwZWVhMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MThhYWYxNTJjNmMzZmZjYjNlOTk4ZGM3YThlNjI1MjI5ZTM3MTFmNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjdmZGIwNTM1MTA1MzY0NjBhNTVkZDRiYWVhODNhMjM3ZWE1NzdjM2Y4OTlh
|
10
|
+
Y2Q5ZGYyMjA4NzNiZjI4YmQ0YWUyZjJmNmRlM2VkM2Y3YTgzYWNhNTVlNDBm
|
11
|
+
MTlkYzUyMjUxY2NmOWQ5ZDM2MTY4Y2I2YjQxZTdmYjFjN2QyNjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWZlMWZjNWFjZWYxNjVkZjRhY2JlYTBkOGZmY2M4ZTBjMTM1NTJmNDA5ZGUz
|
14
|
+
MjhiMjQ0OWRmYTI2NDVlMmQ2NmFlNGU0YTQ4NGYzZmUzOGIwNmFhODRhNTY5
|
15
|
+
Njc4ZjdiM2I3NzY4MzVlYTBjYzUyMGQxN2M3YWM2NGNlNWIzYjA=
|
data/.gitignore
CHANGED
data/blackbaud-client.gemspec
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
lib = File.expand_path('../lib/', __FILE__)
|
3
3
|
$:.unshift lib unless $:.include?(lib)
|
4
4
|
|
5
|
+
require 'blackbaud-client/version'
|
6
|
+
|
5
7
|
Gem::Specification.new do |gem|
|
6
8
|
gem.name = "blackbaud-client"
|
7
|
-
gem.version =
|
9
|
+
gem.version = Blackbaud::Client::Version.to_s
|
8
10
|
gem.authors = "Alex Dugger"
|
9
11
|
gem.email = "alexd@haikulearning.com"
|
10
12
|
gem.description = "A client for the Blackbaud API."
|
@@ -12,7 +14,7 @@ Gem::Specification.new do |gem|
|
|
12
14
|
gem.summary = "A client for the Blackbaud API."
|
13
15
|
gem.files = `git ls-files`.split($/)
|
14
16
|
gem.require_path = 'lib'
|
15
|
-
gem.add_runtime_dependency 'ruby-hmac'
|
16
|
-
gem.add_runtime_dependency 'rest-client'
|
17
17
|
|
18
|
+
gem.add_runtime_dependency 'ruby-hmac', '~>0.4'
|
19
|
+
gem.add_runtime_dependency 'rest-client', '~>1.6'
|
18
20
|
end
|
@@ -3,7 +3,6 @@ module Blackbaud
|
|
3
3
|
attr_accessor(:description, :ea7_academic_year_id, :end_date, :school_id, :school_name, :sessions, :short_description, :start_date, :links)
|
4
4
|
|
5
5
|
def initialize(values)
|
6
|
-
|
7
6
|
values["sessions"].map! {|s| Blackbaud::Session.new(s)} if values["sessions"]
|
8
7
|
|
9
8
|
["start_date", "end_date"].each do |date|
|
@@ -11,9 +10,7 @@ module Blackbaud
|
|
11
10
|
values.delete("#{date}")
|
12
11
|
end
|
13
12
|
|
14
|
-
values
|
15
|
-
send("#{k}=".intern, v)
|
16
|
-
end
|
13
|
+
super(values)
|
17
14
|
|
18
15
|
def connection_string
|
19
16
|
"academic_years/#{self.ea7_academic_year_id}"
|
@@ -22,7 +19,6 @@ module Blackbaud
|
|
22
19
|
def terms
|
23
20
|
self.sessions.inject([]) {|r, s| r + s.terms}
|
24
21
|
end
|
25
|
-
|
26
22
|
end
|
27
23
|
|
28
24
|
end
|
@@ -3,13 +3,9 @@ module Blackbaud
|
|
3
3
|
attr_accessor(:ea7_class_id, :course_id, :course_name, :section, :ea7_term_id, :ea7_term_name, :faculty, :students)
|
4
4
|
|
5
5
|
def initialize(values)
|
6
|
-
|
7
6
|
values["faculty"].map! {|s| Blackbaud::Person.new(s, 1)} if values["faculty"]
|
8
7
|
values["students"].map! {|s| Blackbaud::Person.new(s, 2)} if values["students"]
|
9
|
-
|
10
|
-
values.each do |k,v|
|
11
|
-
send("#{k}=".intern, v)
|
12
|
-
end
|
8
|
+
super(values)
|
13
9
|
end
|
14
10
|
|
15
11
|
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
module Blackbaud
|
2
2
|
class Person < BlackbaudObject
|
3
|
-
attr_accessor(:ea7_record_id, :name_for_display, :type, :birth_date, :first_name, :import_id, :last_name, :record_type, :title, :suffix, :middle_name, :user_defined_id, :nickname, :contacts)
|
3
|
+
attr_accessor(:ea7_record_id, :name_for_display, :type, :birth_date, :first_name, :import_id, :last_name, :record_type, :title, :suffix, :middle_name, :user_defined_id, :nickname, :contacts, :relations, :online_user_id)
|
4
4
|
|
5
|
-
|
5
|
+
USER_TYPE = {
|
6
|
+
:faculty => 1,
|
7
|
+
:student => 2,
|
8
|
+
:undefined => nil,
|
9
|
+
}
|
6
10
|
|
11
|
+
def initialize(values, type_id)
|
7
12
|
values["type"] = type_id
|
8
13
|
|
9
14
|
if values["bio"]
|
@@ -12,15 +17,33 @@ module Blackbaud
|
|
12
17
|
end
|
13
18
|
|
14
19
|
if values["contact_info"]
|
15
|
-
values["contacts"] = values["contact_info"].map
|
20
|
+
values["contacts"] = values["contact_info"].map {|c| Blackbaud::Contact.new(c)}
|
16
21
|
values.delete("contact_info")
|
22
|
+
else
|
23
|
+
values["contacts"] = []
|
24
|
+
end
|
25
|
+
|
26
|
+
if values["relations"]
|
27
|
+
values["relations"].map! {|r| Blackbaud::Relation.new(r)}
|
28
|
+
else
|
29
|
+
values["relations"] = []
|
17
30
|
end
|
18
31
|
|
19
32
|
values["birth_date"] = format_date(values["birth_date"]) if values["birth_date"]
|
20
33
|
|
21
|
-
values
|
22
|
-
|
23
|
-
|
34
|
+
super(values)
|
35
|
+
end
|
36
|
+
|
37
|
+
def faculty?
|
38
|
+
type == USER_TYPE[:faculty]
|
39
|
+
end
|
40
|
+
|
41
|
+
def student?
|
42
|
+
type == USER_TYPE[:student]
|
43
|
+
end
|
44
|
+
|
45
|
+
def undefined_type?
|
46
|
+
type == USER_TYPE[:undefined]
|
24
47
|
end
|
25
48
|
|
26
49
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Blackbaud
|
2
|
+
class Relation < BlackbaudObject
|
3
|
+
attr_accessor(:relationship_code_id, :relationship_code_value, :reciprocal_code_id, :reciprocal_code_value, :person)
|
4
|
+
|
5
|
+
def initialize(values)
|
6
|
+
if values["person"]
|
7
|
+
values["person"] = Blackbaud::Person.new(values["person"], Blackbaud::Person::USER_TYPE[:undefined])
|
8
|
+
end
|
9
|
+
|
10
|
+
values.each do |k,v|
|
11
|
+
send("#{k}=".intern, v)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -3,13 +3,8 @@ module Blackbaud
|
|
3
3
|
attr_accessor(:name, :ea7_session_id, :terms, :links)
|
4
4
|
|
5
5
|
def initialize(values)
|
6
|
-
|
7
6
|
values["terms"].map! {|t| Blackbaud::Term.new(t)} if values["terms"]
|
8
|
-
|
9
|
-
values.each do |k,v|
|
10
|
-
send("#{k}=".intern, v)
|
11
|
-
end
|
12
|
-
|
7
|
+
super(values)
|
13
8
|
end
|
14
9
|
|
15
10
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Blackbaud
|
2
|
+
class Client
|
3
|
+
class Version
|
4
|
+
MAJOR = 0
|
5
|
+
MINOR = 1
|
6
|
+
PATCH = 0
|
7
|
+
STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
8
|
+
|
9
|
+
class << self
|
10
|
+
# A String representing the current version of the OEmbed gem.
|
11
|
+
def inspect
|
12
|
+
STRING
|
13
|
+
end
|
14
|
+
alias_method :to_s, :inspect
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
VERSION = Version::STRING
|
19
|
+
end
|
20
|
+
end
|
data/lib/blackbaud-client.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
+
require 'blackbaud-client/version.rb'
|
1
2
|
require 'blackbaud-client/api/blackbaud_object.rb'
|
2
3
|
require 'blackbaud-client/api/academic_year.rb'
|
3
4
|
require 'blackbaud-client/api/class.rb'
|
4
5
|
require 'blackbaud-client/api/code_table.rb'
|
5
6
|
require 'blackbaud-client/api/person.rb'
|
7
|
+
require 'blackbaud-client/api/contact.rb'
|
8
|
+
require 'blackbaud-client/api/relation.rb'
|
6
9
|
require 'blackbaud-client/api/session.rb'
|
7
10
|
require 'blackbaud-client/api/static_code_table.rb'
|
8
11
|
require 'blackbaud-client/api/table_entry.rb'
|
9
12
|
require 'blackbaud-client/api/term.rb'
|
10
|
-
require 'blackbaud-client/api/
|
11
|
-
require 'blackbaud-client/api/contact.rb'
|
13
|
+
require 'blackbaud-client/api/code_table_entry.rb'
|
12
14
|
require 'hmac-sha1'
|
13
15
|
require 'cgi'
|
14
16
|
require 'base64'
|
@@ -19,11 +21,6 @@ require 'date'
|
|
19
21
|
module Blackbaud
|
20
22
|
class Client
|
21
23
|
|
22
|
-
USER_TYPE = {
|
23
|
-
:faculty => 1,
|
24
|
-
:student => 2
|
25
|
-
}
|
26
|
-
|
27
24
|
def initialize(options)
|
28
25
|
auth_params = {
|
29
26
|
:database_key => options[:database_key],
|
@@ -36,14 +33,10 @@ module Blackbaud
|
|
36
33
|
|
37
34
|
end
|
38
35
|
|
39
|
-
def construct_url(web_services_url, endpoint, filters=nil)
|
40
|
-
@url = "#{web_services_url}/#{endpoint}?token=#{@token}"
|
41
|
-
@url << "&filter=(#{filters})" if filters
|
42
|
-
end
|
43
|
-
|
44
36
|
def connect(endpoint, filters=nil)
|
45
|
-
construct_url(@web_services_url, endpoint, filters)
|
46
|
-
|
37
|
+
url = construct_url(@web_services_url, endpoint, filters)
|
38
|
+
#puts url.inspect
|
39
|
+
JSON.parse(RestClient::Request.execute(:method=>'get', :url=>url))
|
47
40
|
end
|
48
41
|
|
49
42
|
def academic_years(id)
|
@@ -53,17 +46,40 @@ module Blackbaud
|
|
53
46
|
|
54
47
|
def contact_types
|
55
48
|
results = connect("global/code_tables/phone%20type")
|
56
|
-
results["table_entries"].collect {|
|
49
|
+
results["table_entries"].collect {|entry| Blackbaud::CodeTableEntry.new(entry)}
|
50
|
+
end
|
51
|
+
|
52
|
+
def relationships
|
53
|
+
results = connect("global/code_tables/relationship")
|
54
|
+
results["table_entries"].collect {|entry| Blackbaud::CodeTableEntry.new(entry)}
|
57
55
|
end
|
58
56
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
57
|
+
# Return an Array of Person records
|
58
|
+
#
|
59
|
+
# Available filter_opts:
|
60
|
+
# * :contact_types: An Array of id values that correspond to code_table table_entry records from the "phone type" code_table
|
61
|
+
# * :relationships: An Array of id values that correspond to code_table table_entry records from the "relationship" code_table
|
62
|
+
def people(scope, filter_opts={})
|
63
|
+
filters = {}
|
64
|
+
|
65
|
+
filters["contact.type_id"] = filter_opts[:contact_types]
|
66
|
+
filters["relation.relationship_code_id"] = filter_opts[:relationships]
|
67
|
+
|
68
|
+
results = connect("person/#{scope.connection_string}/people", filters )
|
69
|
+
r = []
|
70
|
+
|
71
|
+
{
|
72
|
+
'faculty' => Blackbaud::Person::USER_TYPE[:faculty],
|
73
|
+
'students' => Blackbaud::Person::USER_TYPE[:student],
|
74
|
+
}.each do |response_key, type_id|
|
75
|
+
ppl = results["people"].first[response_key]
|
76
|
+
ppl = [] unless ppl.is_a?(Enumerable)
|
77
|
+
ppl.each do |person|
|
78
|
+
r << Blackbaud::Person.new(person, type_id)
|
79
|
+
end
|
65
80
|
end
|
66
|
-
|
81
|
+
|
82
|
+
r
|
67
83
|
end
|
68
84
|
|
69
85
|
def classes(scope)
|
@@ -85,5 +101,20 @@ module Blackbaud
|
|
85
101
|
results = connect("global/static_code_tables/#{id}")
|
86
102
|
results["table_entries"].collect {|c| Blackbaud::TableEntry.new(c)}
|
87
103
|
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def construct_url(web_services_url, endpoint, filters=nil)
|
108
|
+
url = "#{web_services_url}/#{endpoint}?token=#{@token}"
|
109
|
+
filters = Array(filters).map do |k,v|
|
110
|
+
v = Array(v)
|
111
|
+
"(#{k}%20eq%20#{v.join(',')})" if v && !v.join.empty?
|
112
|
+
end
|
113
|
+
|
114
|
+
url << "&filter=#{filters.join}"
|
115
|
+
|
116
|
+
url
|
117
|
+
end
|
118
|
+
|
88
119
|
end
|
89
120
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackbaud-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dugger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-hmac
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '0.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rest-client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.6'
|
41
41
|
description: A client for the Blackbaud API.
|
42
42
|
email: alexd@haikulearning.com
|
43
43
|
executables: []
|
@@ -45,6 +45,7 @@ extensions: []
|
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
47
|
- .gitignore
|
48
|
+
- Gemfile
|
48
49
|
- LICENSE.txt
|
49
50
|
- README.md
|
50
51
|
- blackbaud-client.gemspec
|
@@ -53,13 +54,15 @@ files:
|
|
53
54
|
- lib/blackbaud-client/api/blackbaud_object.rb
|
54
55
|
- lib/blackbaud-client/api/class.rb
|
55
56
|
- lib/blackbaud-client/api/code_table.rb
|
57
|
+
- lib/blackbaud-client/api/code_table_entry.rb
|
56
58
|
- lib/blackbaud-client/api/contact.rb
|
57
|
-
- lib/blackbaud-client/api/contact_type.rb
|
58
59
|
- lib/blackbaud-client/api/person.rb
|
60
|
+
- lib/blackbaud-client/api/relation.rb
|
59
61
|
- lib/blackbaud-client/api/session.rb
|
60
62
|
- lib/blackbaud-client/api/static_code_table.rb
|
61
63
|
- lib/blackbaud-client/api/table_entry.rb
|
62
64
|
- lib/blackbaud-client/api/term.rb
|
65
|
+
- lib/blackbaud-client/version.rb
|
63
66
|
homepage: https://github.com/haikulearning/blackbaud-api-client
|
64
67
|
licenses: []
|
65
68
|
metadata: {}
|