act_blue_reporter 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -1
- data/act_blue_reporter.gemspec +1 -1
- data/lib/act_blue_reporter/campaign.rb +8 -16
- data/lib/act_blue_reporter/connect.rb +5 -0
- data/lib/act_blue_reporter/exceptions.rb +0 -6
- data/lib/act_blue_reporter/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1fb11f172ddbec69ae35cab10d2f44848e544fa
|
4
|
+
data.tar.gz: e92c05017f1b82855d821668cb436feff3c2904a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 494af4ada1b134c599b22d804c54988b6e6c08e83086b21e80c100f103b5108d9308b133c093c543707dad57b3d4bd4e161de96656d39e7b7898b5c7c56b8791
|
7
|
+
data.tar.gz: ba62c8910f40feb734bfe9538b0be23ee82359be32575349a0c4298f4e21f0e231607fb33faec8e8b2dd852cc71106e221ea79e07ee2245ea3de8bbb168e1d47
|
data/README.md
CHANGED
@@ -10,6 +10,8 @@ ActBlue. It is designed to work across multiple ActBlue campaigns.
|
|
10
10
|
It is not a full-fledged wrapper for the ActBlue API; it doesn't do much more
|
11
11
|
than retrieve data.
|
12
12
|
|
13
|
+
Extracted from [DonorStack](http://donorstack.com/).
|
14
|
+
|
13
15
|
## Installation
|
14
16
|
|
15
17
|
Add this line to your application's Gemfile:
|
@@ -26,7 +28,42 @@ Or install it yourself as:
|
|
26
28
|
|
27
29
|
## Usage
|
28
30
|
|
29
|
-
|
31
|
+
Create a campaign object. The login and password are the same as you use for
|
32
|
+
the web interface. The entity ID can be obtain from the web interface. It is
|
33
|
+
usually visible in the url.
|
34
|
+
|
35
|
+
campaign = ActBlueReporter::Campaign.new(act_blue_login,
|
36
|
+
act_blue_password,
|
37
|
+
act_blue_entity_id)
|
38
|
+
|
39
|
+
You can use the campaign object to get data
|
40
|
+
|
41
|
+
# returns a hash of campaign details. Useful for checking credentials.
|
42
|
+
campaign.details
|
43
|
+
|
44
|
+
# returns a hash of all the campaign's contributions. Use with care.
|
45
|
+
campaign.all_contributions
|
46
|
+
|
47
|
+
# returns the contributions in the last 24 hours
|
48
|
+
campaign.contributions_in_last_24_hours
|
49
|
+
|
50
|
+
# returns contributions in a certain time range. Arguments must be
|
51
|
+
# ISO 8601 formatted strings.
|
52
|
+
contributions_in_time_range(start_time, end_time)
|
53
|
+
|
54
|
+
One of the problems with ActBlue's API is the structure of the response is
|
55
|
+
different if there is one contribution, or more than one. In particular,
|
56
|
+
responses containing multiple contributions are nested on level more than
|
57
|
+
single contributions. This class abstracts that away and returns a predictable
|
58
|
+
structure.
|
59
|
+
|
60
|
+
payload = campaign.all_contributions
|
61
|
+
formatter = ActBlueReporter::ContributionReport.new(payload)
|
62
|
+
report = formatter.report
|
63
|
+
|
64
|
+
# you can also get the count of contributions from the formatter object
|
65
|
+
formatter.count
|
66
|
+
|
30
67
|
|
31
68
|
## Contributing
|
32
69
|
|
data/act_blue_reporter.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
-
spec.add_development_dependency "rspec", "~> 3.
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
25
|
spec.add_development_dependency "pry", "~> 0.10"
|
26
26
|
spec.add_development_dependency "pry-remote", "~> 0.1"
|
27
27
|
spec.add_development_dependency "pry-nav", "~> 0.2"
|
@@ -15,35 +15,27 @@ module ActBlueReporter
|
|
15
15
|
def details
|
16
16
|
request_uri = "/entities/#{@act_blue_entity_id}"
|
17
17
|
response = make_request(request_uri, @auth)
|
18
|
-
|
19
|
-
raise ActBlueReporter::Exceptions::PayloadError unless payload
|
20
|
-
return payload
|
18
|
+
response["entity"]
|
21
19
|
end
|
22
20
|
|
23
21
|
def all_contributions
|
24
22
|
request_uri = "/contributions?destination=#{@act_blue_entity_id}"
|
25
23
|
response = make_request(request_uri, @auth)
|
26
|
-
|
27
|
-
raise ActBlueReporter::Exceptions::PayloadError unless payload
|
28
|
-
return payload
|
24
|
+
response["contributions"]
|
29
25
|
end
|
30
26
|
|
31
27
|
def contributions_in_time_range(start_time, end_time)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
raise ActBlueReporter::Exceptions::PayloadError unless payload
|
38
|
-
return payload
|
28
|
+
request_uri = "/contributions?destination=#{@entity.to_s}&" +
|
29
|
+
"payment_timestamp=#{start_time.to_s}/" +
|
30
|
+
"#{end_time.to_s}"
|
31
|
+
response = make_request(request_uri, @auth)
|
32
|
+
response["contributions"]
|
39
33
|
end
|
40
34
|
|
41
35
|
def contributions_in_last_24_hrs
|
42
36
|
start_time = (Time.now.at_beginning_of_day - 24.hours).iso8601
|
43
37
|
end_time = Time.now.at_beginning_of_day.iso8601
|
44
|
-
|
45
|
-
raise ActBlueReporter::Exceptions::PayloadError unless payload
|
46
|
-
return payload
|
38
|
+
contributions_in_time_range(start_time, end_time)
|
47
39
|
end
|
48
40
|
end
|
49
41
|
end
|
@@ -47,6 +47,11 @@ module ActBlueReporter
|
|
47
47
|
unless response.success?
|
48
48
|
raise_error("HTTP response code: #{response.response.code}")
|
49
49
|
end
|
50
|
+
|
51
|
+
# raise an error if the response is not a hash
|
52
|
+
unless response.is_a? Hash
|
53
|
+
raise_error("Response is a #{response.class}. Expecting hash")
|
54
|
+
end
|
50
55
|
end
|
51
56
|
|
52
57
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: act_blue_reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Johnson
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|