shelby-arena-api 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 931e155b3330e3297457065c53aaea47172a4875
4
- data.tar.gz: a9dfb77ccee9f40d6dc9579988f69f20d7927fbe
3
+ metadata.gz: 11b64f9a4f298bbe902f7ab4572836428f253a4a
4
+ data.tar.gz: c311075fa91a574c0848df1f295d6e6072148ddb
5
5
  SHA512:
6
- metadata.gz: bd8f6dc7dc5c054693b48b16a627466222bf571df86b1199d90449bdb5b6c96b9b4986c0fafc893650f079a0c2fcd9a33225b3ebbccde24d6fb457037e82a37e
7
- data.tar.gz: c0948853eed75f02d0ed68da5ad52f5c4da3769db3a418e6e14f8302208ddccef5d05621638e346dfd570485047161feb91ba19b50f69b0cd4ab351bc1896e19
6
+ metadata.gz: a46c778cf608e1e35b6438c1d0e2aa88f2b5addad1295865087a882613331d0fa20a1b5dedd0d67abaa1de7bfc7b19f2e42e21ee94f49ff4657827caedf022be
7
+ data.tar.gz: 00b5bdcbfce8e8125e0f1b56289d13f828a874b7c17c652a80d4f47f3fca57cda6c5f299469c8cb94ee7b6fd82530b241e0fd28f38bd87f00f0fd6607bb537ff
@@ -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
- reader = options[:reader] || ShelbyArena::ContributionListReader.new(options)
18
- @json_data = reader.load_data['ContributionListResult']['Contributions']['Contribution']
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.send(method_to_call, self.family_members.collect { |fm| ShelbyArena::Person.load_by_id(fm[1]['PersonID']) })
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
- reader = options[:reader] || ShelbyArena::FundListReader.new(options)
18
- @json_data = reader.load_data['FundListResult']['Funds']['Fund']
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
@@ -62,6 +62,11 @@ module ShelbyArena
62
62
  # end
63
63
 
64
64
 
65
+ def active
66
+ self.record_status_value.downcase == 'active'
67
+ end
68
+
69
+
65
70
  def family_role
66
71
  self.family_member_role_value.blank? ? 'Other' : self.family_member_role_value
67
72
  end
@@ -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
- @json_data = reader.load_data['PersonListResult']['Persons']['Person']
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(Active
17
- CanPledge
18
- EndDate
19
- FundId
20
- FundName
21
- OnlineName
22
- StartDate
23
- TaxDeductible).sort
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
+
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  PROJECT_GEM = 'shelby-arena-api'
3
- PROJECT_GEM_VERSION = '0.1.0'
3
+ PROJECT_GEM_VERSION = '0.2.0'
4
4
 
5
5
  s.name = PROJECT_GEM
6
6
  s.version = PROJECT_GEM_VERSION
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.1.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-24 00:00:00.000000000 Z
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