shelby-arena-api 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/api/contribution.rb +52 -0
- data/lib/api/contribution_list.rb +7 -2
- data/lib/api/family.rb +3 -2
- data/lib/api/fund_list.rb +7 -2
- data/lib/api/person.rb +5 -0
- data/lib/api/person_list.rb +6 -1
- data/lib/api/search.rb +19 -0
- data/lib/readers/contribution_list_reader.rb +17 -9
- data/shelby_arena_api.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11b64f9a4f298bbe902f7ab4572836428f253a4a
|
4
|
+
data.tar.gz: c311075fa91a574c0848df1f295d6e6072148ddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a46c778cf608e1e35b6438c1d0e2aa88f2b5addad1295865087a882613331d0fa20a1b5dedd0d67abaa1de7bfc7b19f2e42e21ee94f49ff4657827caedf022be
|
7
|
+
data.tar.gz: 00b5bdcbfce8e8125e0f1b56289d13f828a874b7c17c652a80d4f47f3fca57cda6c5f299469c8cb94ee7b6fd82530b241e0fd28f38bd87f00f0fd6607bb537ff
|
data/lib/api/contribution.rb
CHANGED
@@ -37,6 +37,58 @@ module ShelbyArena
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
|
41
|
+
# Helper methods
|
42
|
+
|
43
|
+
def fund_id
|
44
|
+
begin
|
45
|
+
self.contribution_funds['ContributionFund']['Fund']['FundId']
|
46
|
+
rescue
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def fund_name
|
53
|
+
begin
|
54
|
+
self.contribution_funds['ContributionFund']['Fund']['FundName']
|
55
|
+
rescue
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def first_name_with_nickname
|
62
|
+
begin
|
63
|
+
fname = self.person_information['FirstName']
|
64
|
+
if self.person_information['NickName'].strip != '' and
|
65
|
+
self.person_information['NickName'].strip != fname
|
66
|
+
fname += " (#{self.person_information['NickName']})"
|
67
|
+
end
|
68
|
+
fname
|
69
|
+
rescue
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def first_name
|
76
|
+
begin
|
77
|
+
self.person_information['FirstName']
|
78
|
+
rescue
|
79
|
+
nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def last_name
|
85
|
+
begin
|
86
|
+
self.person_information['NickName']
|
87
|
+
rescue
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
40
92
|
end
|
41
93
|
|
42
94
|
end
|
@@ -14,8 +14,13 @@ module ShelbyArena
|
|
14
14
|
# Options:
|
15
15
|
# :reader - (optional) The Reader to use to load the data.
|
16
16
|
def initialize(options = {})
|
17
|
-
|
18
|
-
|
17
|
+
@json_data = []
|
18
|
+
reader = options[:reader] || ShelbyArena::ContributionListReader.new(options)
|
19
|
+
data = reader.load_data['ContributionListResult']['Contributions']
|
20
|
+
unless data.nil?
|
21
|
+
# needs to be an array of hashes.
|
22
|
+
@json_data = data['Contribution'].is_a?(Array) ? data['Contribution'] : [data['Contribution']]
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
# Get the specified contribution.
|
data/lib/api/family.rb
CHANGED
@@ -39,9 +39,10 @@ module ShelbyArena
|
|
39
39
|
# The data loaded from family_members is useless. It is best to just reload all the family
|
40
40
|
# members as person objects so all attributes are set.
|
41
41
|
# fm[0] is 'Person'
|
42
|
-
# fm[1] is a Hash of person info to match some, not all, of the attributes above.
|
42
|
+
# fm[1] is an array of Hashes or a sigle Hash of person info to match some, not all, of the attributes above.
|
43
43
|
method_to_call = "#{ShelbyArena::attr_underscore('family_members')}="
|
44
|
-
self.
|
44
|
+
members = self.family_members.first[1].is_a?(Array) ? self.family_members.first[1] : [self.family_members.first[1]]
|
45
|
+
self.send(method_to_call, members.collect { |m| ShelbyArena::Person.load_by_id(m['PersonID']) })
|
45
46
|
end
|
46
47
|
|
47
48
|
end
|
data/lib/api/fund_list.rb
CHANGED
@@ -14,8 +14,13 @@ module ShelbyArena
|
|
14
14
|
# Options:
|
15
15
|
# :reader - (optional) The Reader to use to load the data.
|
16
16
|
def initialize(options = {})
|
17
|
-
|
18
|
-
|
17
|
+
@json_data = []
|
18
|
+
reader = options[:reader] || ShelbyArena::FundListReader.new(options)
|
19
|
+
data = reader.load_data['FundListResult']['Funds']
|
20
|
+
unless data.nil?
|
21
|
+
# needs to be an array of hashes.
|
22
|
+
@json_data = data['Fund'].is_a?(Array) ? data['Fund'] : [data['Fund']]
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
# Get the specified fund.
|
data/lib/api/person.rb
CHANGED
data/lib/api/person_list.rb
CHANGED
@@ -11,8 +11,13 @@ module ShelbyArena
|
|
11
11
|
# Options:
|
12
12
|
# :reader - (optional) The Reader to use to load the data.
|
13
13
|
def initialize(options = {})
|
14
|
+
@json_data = []
|
14
15
|
reader = options[:reader] || ShelbyArena::PersonListReader.new(options)
|
15
|
-
|
16
|
+
data = reader.load_data['PersonListResult']['Persons']
|
17
|
+
unless data.nil?
|
18
|
+
# needs to be an array of hashes.
|
19
|
+
@json_data = data['Person'].is_a?(Array) ? data['Person'] : [data['Person']]
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
# Get the specified person.
|
data/lib/api/search.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module ShelbyArena
|
2
|
+
|
3
|
+
class Search
|
4
|
+
|
5
|
+
def self.search_for_contributions_by_date_range(start_date, end_date)
|
6
|
+
options = {from_date: start_date, to_date: end_date}
|
7
|
+
reader = ShelbyArena::ContributionListReader.new(options)
|
8
|
+
ContributionList.new({reader: reader})
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.search_for_contributions_by_person(first_name, last_name)
|
12
|
+
options = {first_name: first_name, last_name: last_name}
|
13
|
+
reader = ShelbyArena::ContributionListReader.new(options)
|
14
|
+
ContributionList.new({reader: reader})
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -3,26 +3,34 @@ module ShelbyArena
|
|
3
3
|
class ContributionListReader < ApiReader
|
4
4
|
|
5
5
|
# Constructor.
|
6
|
+
#
|
7
|
+
# Options:
|
8
|
+
# :person_id - (optional) search for receipts containing the PersonId that is passed with this parameter.
|
9
|
+
# :start_date - (optional) search for receipts with a received date greater than or equal to this parameter.
|
10
|
+
# :end_date - (optional) search for receipts with a received date less than or equal to this parameter.
|
6
11
|
def initialize(options = {})
|
7
12
|
# page = options[:page] || 1
|
8
13
|
# per_page = options[:per_page] || 100
|
9
14
|
|
10
15
|
@url_data_params = {}
|
11
16
|
valid_fields.each { |field| @url_data_params[field] = options[ShelbyArena::attr_underscore(field).to_sym] unless options[ShelbyArena::attr_underscore(field).to_sym].nil? }
|
12
|
-
@url_data_path = 'contribution/list'
|
17
|
+
@url_data_path = 'contribution/list'
|
18
|
+
|
13
19
|
end
|
14
20
|
|
15
21
|
def valid_fields
|
16
|
-
%W(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
%W(FirstName
|
23
|
+
LastName
|
24
|
+
FromDate
|
25
|
+
ToDate
|
26
|
+
TypeFilter
|
27
|
+
FundFilter
|
28
|
+
ProjectFilter
|
29
|
+
Transaction
|
30
|
+
SortExpression).sort
|
24
31
|
end
|
25
32
|
|
26
33
|
end
|
27
34
|
|
28
35
|
end
|
36
|
+
|
data/shelby_arena_api.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelby-arena-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wes Hays
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/api/fund_list.rb
|
64
64
|
- lib/api/person.rb
|
65
65
|
- lib/api/person_list.rb
|
66
|
+
- lib/api/search.rb
|
66
67
|
- lib/api/shelby_session.rb
|
67
68
|
- lib/auto_load.rb
|
68
69
|
- lib/common.rb
|