blackbaud-client 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjdiNjZiYTAwNjMzMzNiZjEwNWI2ZWZjZTJmZDliNmNhNTk5YmY4OQ==
4
+ OWI4MTAwMjg4NGU0Yjk2NjZlNGYzNDJjYWJiNjFjYTc1NDg3ZjVjZg==
5
5
  data.tar.gz: !binary |-
6
- NzcyYTkzMjQ0MGY0MGE2ZDgyYzEwYzQyNDdjNjhjYTgwZTE3OTg3Yw==
6
+ OTI2ZTQwNzg4MTY0YTIzYjk5ODA2MjMwYjFlOWI4NGU2MzNhNzU4MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODlmOTY4YjE2NzBiYTg1ZTc2Zjk4MDMzMjkzNzcwYTNjNmUyMGE2YTQ2NDFi
10
- YTExZDQ0Y2IzNDRiMTI4OWM0YjdlNmZlMDZhNDYyNDBmZDYwMGY1NmQyNDY5
11
- NmJlMTJhMDY2MWY3ZTRiMGUwM2JlNGJhMTcxZDhkY2IzZmQwYmM=
9
+ MzU2YWIzZGE1YTA3NjhjMTAwNjM2YWNlZDA3MzY5M2QzOTRiMjQxN2EyMjE0
10
+ NjY3NTZiYTEyZjZjNzNmZGQyNmU3MmU4MzJlZTY3MTk5NjYyYjI4ZjU4ZjNl
11
+ ZWEwMTRjYjg5Njg2N2JkNDlkYzQ3NzkwMzgxZThlOTBlNzExNWM=
12
12
  data.tar.gz: !binary |-
13
- YmRmYmI5NjEyZWMzN2M1NTIwMmMxYjE0NWNjZWZhOTQwZDdkNTQ1ZTZmZmRi
14
- YWU1NGVkYmZjMjI0MGU4YjNhZWU5NDUwZjE3MjNjY2I2YzliZjhlZmU1YjQ3
15
- MGE2ZWI3OWRhODUyNTQxMGEyYTE5ZWQwYjUzNzE0ZWUwMDE3MDc=
13
+ NTdjNGMxZWVlYzAwZDg0NTNkZmZjYWQ1ZTcyODcxN2E0NGU2ZmU1YzIzNDQw
14
+ OTNjOWEwYTdiZWM0MmQ0NWQ2ZTYyMGRiOGUzODIzMGZkNmU3MzIzYjM4NWJl
15
+ ZDVjYTBkZmYwNTZmNTg5ZmQ0Y2MyYjRjNWU4YzY0YzRhMDIwNGQ=
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2013 Alex Dugger, Haiku Learning Systems
3
+ Copyright (c) 2014 Alex Dugger, Haiku Learning Systems
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,11 +1,10 @@
1
- # gem build blackbaud-client.gemspec
2
1
  # -*- encoding: utf-8 -*-
3
2
  lib = File.expand_path('../lib/', __FILE__)
4
3
  $:.unshift lib unless $:.include?(lib)
5
4
 
6
5
  Gem::Specification.new do |gem|
7
6
  gem.name = "blackbaud-client"
8
- gem.version = "0.0.4"
7
+ gem.version = "0.0.5"
9
8
  gem.authors = "Alex Dugger"
10
9
  gem.email = "alexd@haikulearning.com"
11
10
  gem.description = "A client for the Blackbaud API."
@@ -13,4 +12,7 @@ Gem::Specification.new do |gem|
13
12
  gem.summary = "A client for the Blackbaud API."
14
13
  gem.files = `git ls-files`.split($/)
15
14
  gem.require_path = 'lib'
15
+ gem.add_runtime_dependency 'ruby-hmac'
16
+ gem.add_runtime_dependency 'rest-client'
17
+
16
18
  end
@@ -19,20 +19,25 @@ require 'date'
19
19
  module Blackbaud
20
20
  class Client
21
21
 
22
+ USER_TYPE = {
23
+ :faculty => 1,
24
+ :student => 2
25
+ }
26
+
22
27
  def initialize(options)
23
28
  auth_params = {
24
- :password => options[:password],
25
- :key => options[:key],
26
- :user_name => options[:username],
27
- :database_number => options[:database]
29
+ :database_key => options[:database_key],
30
+ :database_number => options[:database_number],
31
+ :vendor_id => options[:vendor_id],
32
+ :vendor_key => options[:vendor_key]
28
33
  }.to_json
29
34
  @web_services_url = options[:url]
30
- @token = JSON.parse(RestClient.post (@web_services_url+'security/access_token'), auth_params, {:content_type=>'application/json'})["token"]
35
+ @token = JSON.parse(RestClient.post (@web_services_url+'/security/access_token'), auth_params, {:content_type=>'application/json'})["token"]
31
36
 
32
37
  end
33
38
 
34
39
  def construct_url(web_services_url, endpoint, filters=nil)
35
- @url = "#{web_services_url}#{endpoint}?token=#{@token}"
40
+ @url = "#{web_services_url}/#{endpoint}?token=#{@token}"
36
41
  @url << "&filter=(#{filters})" if filters
37
42
  end
38
43
 
@@ -51,18 +56,18 @@ module Blackbaud
51
56
  results["table_entries"].collect {|ct| Blackbaud::ContactType.new(ct)}
52
57
  end
53
58
 
54
- def people(year)
55
- results = connect("person/academic_years/#{year.ea7_academic_year_id}/people")
56
- results["people"].first["faculty"].collect {|person| Blackbaud::Person.new(person, 1)} + results["people"].first["students"].collect {|person| Blackbaud::Person.new(person, 2)}
57
- end
58
-
59
- def people_with_contacts(year, contact_types)
60
- results = connect("person/academic_years/#{year.ea7_academic_year_id}/people", "contact.type_id%20eq%20#{contact_types.join(',')}" )
61
- results["people"].first["faculty"].collect {|person| Blackbaud::Person.new(person, 1)} + results["people"].first["students"].collect {|person| Blackbaud::Person.new(person, 2)}
59
+ def people(scope, contact_types=nil)
60
+ filter = contact_types.is_a?(Array) ? "contact.type_id%20eq%20#{contact_types.join(',')}" : nil
61
+ results = connect("person/#{scope.connection_string}/people", filter )
62
+ r = [:faculty, :students].collect do |t|
63
+ p = results["people"].first[t.to_s]
64
+ (p.nil? ? [] : p.collect {|person| Blackbaud::Person.new(person, (USER_TYPE[t]))})
65
+ end
66
+ r.flatten(1)
62
67
  end
63
68
 
64
- def classes(year)
65
- results = connect("schedule/academic_years/#{year.ea7_academic_year_id}/classes")
69
+ def classes(scope)
70
+ results = connect("schedule/#{scope.connection_string}/classes")
66
71
  results["classes"].collect {|c| Blackbaud::Class.new(c)}
67
72
  end
68
73
 
@@ -15,6 +15,14 @@ module Blackbaud
15
15
  send("#{k}=".intern, v)
16
16
  end
17
17
 
18
+ def connection_string
19
+ "academic_years/#{self.ea7_academic_year_id}"
20
+ end
21
+
22
+ def terms
23
+ self.sessions.inject([]) {|r, s| r + s.terms}
24
+ end
25
+
18
26
  end
19
27
 
20
28
  end
@@ -10,5 +10,9 @@ module Blackbaud
10
10
 
11
11
  end
12
12
 
13
+ def connection_string
14
+ "terms/#{self.ea7_term_id}"
15
+ end
16
+
13
17
  end
14
18
  end
metadata CHANGED
@@ -1,15 +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
4
+ version: 0.0.5
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-03-13 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-hmac
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description: A client for the Blackbaud API.
14
42
  email: alexd@haikulearning.com
15
43
  executables: []
@@ -51,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
79
  version: '0'
52
80
  requirements: []
53
81
  rubyforge_project:
54
- rubygems_version: 2.2.1
82
+ rubygems_version: 2.2.2
55
83
  signing_key:
56
84
  specification_version: 4
57
85
  summary: A client for the Blackbaud API.