firstgiving 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +3 -0
- data/lib/firstgiving.rb +1 -0
- data/lib/firstgiving/base.rb +12 -23
- data/lib/firstgiving/lookup.rb +16 -1
- data/lib/firstgiving/response.rb +15 -0
- data/lib/firstgiving/version.rb +1 -1
- data/spec/first_giving_spec.rb +17 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmIwOTM3NTI3MjY3ZmRlM2YxZTU2OTlmODk4YWUwZjI1NDJiM2Q4ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGYwZDhjNGQ3N2I4MjQ0ZmYyOTNmZGU4OTU1NWU2NDkyNjg4ZTBlOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTllMWRhYWZlNjFmY2QzNjdkNGRkY2EyN2Y3Y2VhYzA4ODhmZmQ3M2M0YjZm
|
10
|
+
ZTQyMGNlZjI5ZTA4NGZjODJiMjgyNDU1NGU1ZDkyM2NiOGNiZTMyNWQ5Njcx
|
11
|
+
ODc2ZTllMzQ2YjBlOTQzZTAzYTY1NTFkN2Y2MmVlY2RlMTljODE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjJjZWRlMDkwODAzNmI0YjQ4NWVkYWFhNWYwOGIzNDc2ZmExNTc3OGVkOGY0
|
14
|
+
YTZiNWUwYWE4ODA4MzQ3ZTc3ZDk2NWM3MjFjYzgwZDk1NzU4ZGNkYWRjMTBh
|
15
|
+
N2ZhMjdhMWVlZDcxYjZhNjhkNjZiNzA1Zjk3ZjdjNTk2YTJjYjM=
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# FirstGiving
|
2
2
|
|
3
|
+
[![Code Climate](https://codeclimate.com/github/boosterllc/firstgiving_ruby.png)](https://codeclimate.com/github/boosterllc/firstgiving_ruby)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/firstgiving.svg)](http://badge.fury.io/rb/firstgiving)
|
5
|
+
|
3
6
|
FirstGiving Ruby Client Open Source.
|
4
7
|
|
5
8
|
## Installation
|
data/lib/firstgiving.rb
CHANGED
data/lib/firstgiving/base.rb
CHANGED
@@ -20,29 +20,18 @@ module FirstGiving
|
|
20
20
|
}
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
def get_call(api_endpoint, action, params, headers)
|
37
|
-
conn = Faraday.new(url: api_endpoint) do |faraday|
|
38
|
-
faraday.request :url_encoded # form-encode POST params
|
39
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
40
|
-
end
|
41
|
-
|
42
|
-
conn.get do |req|
|
43
|
-
req.url action
|
44
|
-
req.params = params
|
45
|
-
req.headers = headers
|
23
|
+
[:post, :get].each do |method|
|
24
|
+
define_method "#{method}_call" do |api_endpoint, action, params, headers|
|
25
|
+
conn = Faraday.new(url: api_endpoint) do |faraday|
|
26
|
+
faraday.request :url_encoded
|
27
|
+
faraday.adapter Faraday.default_adapter
|
28
|
+
end
|
29
|
+
|
30
|
+
conn.send("#{method}") do |req|
|
31
|
+
req.url action
|
32
|
+
req.params = params
|
33
|
+
req.headers = headers
|
34
|
+
end
|
46
35
|
end
|
47
36
|
end
|
48
37
|
|
data/lib/firstgiving/lookup.rb
CHANGED
@@ -32,8 +32,23 @@ module FirstGiving
|
|
32
32
|
call(Actions::TRANSACTION_LIST, params, headers)
|
33
33
|
end
|
34
34
|
|
35
|
+
def success_from(response)
|
36
|
+
ack = response['firstGivingDonationApi']['firstGivingResponse']['acknowledgement']
|
37
|
+
ack == 'Success' ? true : false
|
38
|
+
end
|
39
|
+
|
40
|
+
def params_from(response)
|
41
|
+
params = response['firstGivingDonationApi']['firstGivingResponse']['transaction']
|
42
|
+
params ||= response['firstGivingDonationApi']['firstGivingResponse']['transactions']
|
43
|
+
end
|
44
|
+
|
45
|
+
def message_from(response)
|
46
|
+
response['firstGivingDonationApi']['firstGivingResponse']['verboseErrorMessage']
|
47
|
+
end
|
48
|
+
|
35
49
|
def parse(body)
|
36
|
-
Crack::XML.parse(body)
|
50
|
+
response = Crack::XML.parse(body)
|
51
|
+
response = Response.new(success_from(response), message_from(response), params_from(response))
|
37
52
|
end
|
38
53
|
end
|
39
54
|
end
|
data/lib/firstgiving/version.rb
CHANGED
data/spec/first_giving_spec.rb
CHANGED
@@ -72,13 +72,15 @@ describe FirstGiving do
|
|
72
72
|
|
73
73
|
it 'should return a list of transactions' do
|
74
74
|
params = {
|
75
|
-
page_size:
|
75
|
+
page_size: 40,
|
76
76
|
date_from: '1388707200',
|
77
77
|
count: 10,
|
78
78
|
page: 1
|
79
79
|
}
|
80
80
|
resp = FG.lookup.list(params)
|
81
|
-
|
81
|
+
expect(resp.is_a? FirstGiving::Response).to be_true
|
82
|
+
expect(resp.success?).to be_true
|
83
|
+
expect(resp.params).to_not be_nil
|
82
84
|
end
|
83
85
|
|
84
86
|
it 'should return a transaction detail' do
|
@@ -86,7 +88,19 @@ describe FirstGiving do
|
|
86
88
|
transactionId: 'a-0070dde28ca48048a1fc24'
|
87
89
|
}
|
88
90
|
resp = FG.lookup.detail(params)
|
89
|
-
|
91
|
+
expect(resp.is_a? FirstGiving::Response).to be_true
|
92
|
+
expect(resp.success?).to be_true
|
93
|
+
expect(resp.params).to_not be_nil
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should return unsuccesful lookup transaction' do
|
97
|
+
params = {
|
98
|
+
transactionId: 'a-123'
|
99
|
+
}
|
100
|
+
resp = FG.lookup.detail(params)
|
101
|
+
expect(resp.is_a? FirstGiving::Response).to be_true
|
102
|
+
expect(resp.success?).to be_false
|
103
|
+
expect(resp.params).to be_nil
|
90
104
|
end
|
91
105
|
|
92
106
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firstgiving
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Faizal Zakaria
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/firstgiving/base.rb
|
113
113
|
- lib/firstgiving/donation.rb
|
114
114
|
- lib/firstgiving/lookup.rb
|
115
|
+
- lib/firstgiving/response.rb
|
115
116
|
- lib/firstgiving/search.rb
|
116
117
|
- lib/firstgiving/version.rb
|
117
118
|
- spec/first_giving_spec.rb
|