siebel_donations 1.0.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/.gitignore +18 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/siebel_donations.rb +21 -0
- data/lib/siebel_donations/address.rb +10 -0
- data/lib/siebel_donations/balance.rb +17 -0
- data/lib/siebel_donations/base.rb +34 -0
- data/lib/siebel_donations/contact.rb +17 -0
- data/lib/siebel_donations/designation.rb +21 -0
- data/lib/siebel_donations/donation.rb +10 -0
- data/lib/siebel_donations/donor.rb +17 -0
- data/lib/siebel_donations/email_address.rb +9 -0
- data/lib/siebel_donations/phone_number.rb +9 -0
- data/lib/siebel_donations/profile.rb +16 -0
- data/lib/siebel_donations/version.rb +3 -0
- data/siebel_donations.gemspec +24 -0
- data/spec/donation_spec.rb +18 -0
- data/spec/spec_helper.rb +11 -0
- metadata +117 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Josh Starcher
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# SiebelDonations
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'siebel_donations'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install siebel_donations
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_support/core_ext/string/inflections'
|
2
|
+
require 'siebel_donations/base'
|
3
|
+
|
4
|
+
Dir[File.dirname(__FILE__) + '/siebel_donations/*.rb'].each do |file|
|
5
|
+
require file
|
6
|
+
end
|
7
|
+
|
8
|
+
module SiebelDonations
|
9
|
+
class << self
|
10
|
+
attr_accessor :base_url, :oauth_token
|
11
|
+
|
12
|
+
def configure
|
13
|
+
yield self
|
14
|
+
end
|
15
|
+
|
16
|
+
def base_url
|
17
|
+
@base_url ||= "http://hart-a321.net.ccci.org:9980/wsapi/rest"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SiebelDonations
|
2
|
+
class Balance < Base
|
3
|
+
|
4
|
+
def self.path() '/staffAccount/balances'; end
|
5
|
+
|
6
|
+
attr_reader :id, :primary, :staff_conference_savings_fund, :italian_savings_fund,
|
7
|
+
:reimbursement_advance, :re_entry_fund, :return_travel_fund, :salary_advance
|
8
|
+
|
9
|
+
def initialize(json)
|
10
|
+
@id = json.first
|
11
|
+
|
12
|
+
super(json.last)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'oj'
|
3
|
+
|
4
|
+
module SiebelDonations
|
5
|
+
class Base
|
6
|
+
|
7
|
+
def initialize(json)
|
8
|
+
json.each do |key, value|
|
9
|
+
instance_variable_set("@#{key.underscore}", value)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.get(path, params)
|
14
|
+
raise 'You need to configure SiebelDonations with your oauth_token.' unless SiebelDonations.oauth_token
|
15
|
+
url = SiebelDonations.base_url + path
|
16
|
+
RestClient.get(url, {params: params, timeout: -1, authorization: "Bearer #{SiebelDonations.oauth_token}"}) { |response, request, result, &block|
|
17
|
+
case response.code
|
18
|
+
when 200
|
19
|
+
Oj.load(response)
|
20
|
+
else
|
21
|
+
puts response.inspect
|
22
|
+
puts request.inspect
|
23
|
+
raise result.inspect
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.find(params)
|
29
|
+
get(path, params).collect { |json| new(json) }
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SiebelDonations
|
2
|
+
class Contact < Base
|
3
|
+
|
4
|
+
attr_reader :id, :primary, :first_name, :preferred_name, :middle_name, :last_name,
|
5
|
+
:title, :sufix, :sex, :phone_numbers, :email_addresses
|
6
|
+
|
7
|
+
def initialize(json)
|
8
|
+
super
|
9
|
+
|
10
|
+
@phone_numbers = json['phoneNumbers'].collect { |phone_json| SiebelDonations::PhoneNumber.new(phone_json) } if json['phoneNumbers']
|
11
|
+
@email_addresses = json['emailAddresses'].collect { |email_json| SiebelDonations::EmailAddress.new(email_json) } if json['emailAddresses']
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SiebelDonations
|
2
|
+
class Designation < Base
|
3
|
+
|
4
|
+
attr_reader :number, :description, :chartfield, :staff_account_id
|
5
|
+
|
6
|
+
def account_type
|
7
|
+
@chartfield.present? ? 'Chartfield' : 'StaffAccount'
|
8
|
+
end
|
9
|
+
|
10
|
+
def balances(account_types = nil)
|
11
|
+
if @account_type == 'Chartfield'
|
12
|
+
raise 'Balance information is not currently available for chartfields'
|
13
|
+
else
|
14
|
+
Balance.find(employee_ids: @staff_account_id, staff_account_types: account_types || 'primary').first
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SiebelDonations
|
2
|
+
class Donor < Base
|
3
|
+
|
4
|
+
def self.path() '/donors'; end
|
5
|
+
|
6
|
+
attr_reader :id, :account_name, :contacts, :addresses, :type
|
7
|
+
|
8
|
+
def initialize(json)
|
9
|
+
super
|
10
|
+
|
11
|
+
@contacts = json['contacts'].collect { |contact_json| SiebelDonations::Contact.new(contact_json) } if json['contacts']
|
12
|
+
@addresses = json['addresses'].collect { |address_json| SiebelDonations::Address.new(address_json) } if json['addresses']
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module SiebelDonations
|
2
|
+
class Profile < Base
|
3
|
+
|
4
|
+
def self.path() '/profiles'; end
|
5
|
+
|
6
|
+
attr_reader :id, :name, :designations
|
7
|
+
|
8
|
+
def initialize(json)
|
9
|
+
super
|
10
|
+
|
11
|
+
@designations = json['designations'].collect { |designation_json| Designation.new(designation_json) }
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'siebel_donations/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "siebel_donations"
|
8
|
+
gem.version = SiebelDonations::VERSION
|
9
|
+
gem.authors = ["Josh Starcher"]
|
10
|
+
gem.email = ["josh.starcher@gmail.com"]
|
11
|
+
gem.description = %q{This gem wraps an API to get donation, donor and account information out of Siebel Donor.}
|
12
|
+
gem.summary = %q{Get donation information from Siebel Donor}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency('rest-client', '~> 1.6.7')
|
21
|
+
gem.add_dependency('oj', '~> 1.4.5')
|
22
|
+
gem.add_dependency('activesupport')
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SiebelDonations::Donation do
|
4
|
+
context '.find' do
|
5
|
+
context 'by a designation number' do
|
6
|
+
it "returns an array of donations" do
|
7
|
+
donation_json = Oj.load '[ { "id": "XGF5T", "amount": "10.00", "designation": "0588176", "donorId": "000599596", "donationDate": "2007-10-21", "paymentMethod": "Credit Card", "paymentType": "Visa", "channel": "Recurring", "campaignCode": "CCWBST" } ]'
|
8
|
+
SiebelDonations::Donation.should_receive(:get).and_return(donation_json)
|
9
|
+
|
10
|
+
donations = SiebelDonations::Donation.find(designations: '0559826',
|
11
|
+
start_date: '2012-01-01',
|
12
|
+
end_date: '2013-01-01')
|
13
|
+
|
14
|
+
donations.length.should == 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require'rspec'
|
4
|
+
require'siebel_donations'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
RSpec.configure do |config|
|
7
|
+
end
|
8
|
+
|
9
|
+
SiebelDonations.configure do |config|
|
10
|
+
config.oauth_token = 'foo'
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: siebel_donations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josh Starcher
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.6.7
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.6.7
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: oj
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.4.5
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.4.5
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: activesupport
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: This gem wraps an API to get donation, donor and account information
|
63
|
+
out of Siebel Donor.
|
64
|
+
email:
|
65
|
+
- josh.starcher@gmail.com
|
66
|
+
executables: []
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- lib/siebel_donations.rb
|
76
|
+
- lib/siebel_donations/address.rb
|
77
|
+
- lib/siebel_donations/balance.rb
|
78
|
+
- lib/siebel_donations/base.rb
|
79
|
+
- lib/siebel_donations/contact.rb
|
80
|
+
- lib/siebel_donations/designation.rb
|
81
|
+
- lib/siebel_donations/donation.rb
|
82
|
+
- lib/siebel_donations/donor.rb
|
83
|
+
- lib/siebel_donations/email_address.rb
|
84
|
+
- lib/siebel_donations/phone_number.rb
|
85
|
+
- lib/siebel_donations/profile.rb
|
86
|
+
- lib/siebel_donations/version.rb
|
87
|
+
- siebel_donations.gemspec
|
88
|
+
- spec/donation_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
homepage: ''
|
91
|
+
licenses: []
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 1.8.24
|
111
|
+
signing_key:
|
112
|
+
specification_version: 3
|
113
|
+
summary: Get donation information from Siebel Donor
|
114
|
+
test_files:
|
115
|
+
- spec/donation_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
has_rdoc:
|