firstgiving 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6a6851db81358b18da79f91eddc7d506c891ac2f
4
- data.tar.gz: ebda58663a88fad10c5274b5633519c3aca1b132
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTBmYmNjYzNmNGMwODhjN2QzMTE1ZWIyZjU4MGIyYmRhMGM4ZmRiOA==
5
+ data.tar.gz: !binary |-
6
+ NmNhYTY2YTA5OGY4ZWQxZTIzZmMwNmFiMDMwNzQzNjllNTM5ZGQ1ZQ==
5
7
  SHA512:
6
- metadata.gz: 4c66bc3913b0dcedc174fd58a6699f7263c029b5c1aa99da25fb3d4aae1568c2f9eb8fb00d47343c415253087caef84cfdffe1ac104716905dfd2443340ba4dd
7
- data.tar.gz: 62d3afb72ee953eeba799b0584ffd8c6cea06d0b0c4ea6d6add7be675c4886a1ba2ef82ad17f84b9e53c71ddefb4ecb16bd6245e55b9217726219587247f4bbf
8
+ metadata.gz: !binary |-
9
+ MjM2NjBjMDQ4ZDkzOTc3MGYyNzg5MDcxZTEzNjNjM2IxODJmMzk0N2ZiMjFi
10
+ NTNlZTRmZjM1YzVkMzQ1NDNhMzIzOWQzZWNlYjA1ZjA2YzBiMmIzMTAyM2Ri
11
+ NjU4ZDE4NzZmOWM2MGU5ZDMxMTQ5NDhkNGI0ZWM4OGViOTc0MTE=
12
+ data.tar.gz: !binary |-
13
+ ZWY4YjNlMTZkMjQ5NzRmNGFiYjc2NGMzZmI0MzM5MWU1NjMwZTQzYTU2ODUw
14
+ MTYwNDM4ZDBlYzg4Y2QwM2FiZTBjODAwMTg2YTljM2I0MWY1MTZhNDQyNGVm
15
+ MGVkYTc0ZDJhYTI0YjJiNjllMDU3YTFjZGE1ZTcyMGQ1MThkOTQ=
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .rubocop.yml
@@ -4,24 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'firstgiving/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "firstgiving"
7
+ spec.name = 'firstgiving'
8
8
  spec.version = FirstGiving::VERSION
9
- spec.authors = ["Faizal Zakaria"]
10
- spec.email = ["phaibusiness@gmail.com"]
11
- spec.description = %q{FirstGiving Ruby API client}
12
- spec.summary = %q{FirstGiving API client}
13
- spec.homepage = "https://github.com/boosterllc/firstgiving_ruby"
14
- spec.license = "MIT"
9
+ spec.authors = ['Faizal Zakaria']
10
+ spec.email = ['phaibusiness@gmail.com']
11
+ spec.description = %q(FirstGiving Ruby API client)
12
+ spec.summary = %q(FirstGiving API client)
13
+ spec.homepage = 'https://github.com/boosterllc/firstgiving_ruby'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec"
24
- spec.add_development_dependency "json"
25
- spec.add_development_dependency "crack"
26
- spec.add_development_dependency "faraday"
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'json'
25
+ spec.add_development_dependency 'crack'
26
+ spec.add_development_dependency 'faraday'
27
27
  end
@@ -10,7 +10,6 @@ require 'firstgiving/search'
10
10
  # Search API
11
11
 
12
12
  module FirstGiving
13
-
14
13
  class Configuration
15
14
  attr_accessor :application_key, :security_token, :options
16
15
 
@@ -22,10 +21,10 @@ module FirstGiving
22
21
  end
23
22
 
24
23
  def set_defaults
25
- self.options[:verbose] ||= false
26
- self.options[:read_timeout] ||= 30
27
- self.options[:use_ssl] ||= false
28
- self.options[:use_staging] ||= true
24
+ options[:verbose] ||= false
25
+ options[:read_timeout] ||= 30
26
+ options[:use_ssl] ||= false
27
+ options[:use_staging] ||= true
29
28
  end
30
29
  end
31
30
 
@@ -48,7 +47,6 @@ module FirstGiving
48
47
  def self.donation
49
48
  @donation ||= Donation.new
50
49
  end
51
-
52
50
  end
53
51
 
54
52
  FG = FirstGiving
@@ -1,12 +1,10 @@
1
1
  require 'faraday'
2
2
 
3
3
  module FirstGiving
4
-
5
4
  module Base
6
-
7
- DONATION_SANDBOX_ENDPOINT = "http://usapisandbox.fgdev.net"
8
- DONATION_PRODUCTION_ENDPOINT = "https://api.firstgiving.com"
9
- SEARCH_ENDPOINT = "http://graphapi.firstgiving.com"
5
+ DONATION_SANDBOX_ENDPOINT = 'http://usapisandbox.fgdev.net'
6
+ DONATION_PRODUCTION_ENDPOINT = 'https://api.firstgiving.com'
7
+ SEARCH_ENDPOINT = 'http://graphapi.firstgiving.com'
10
8
 
11
9
  def headers_json
12
10
  {
@@ -23,12 +21,12 @@ module FirstGiving
23
21
  end
24
22
 
25
23
  def post_call(api_endpoint, action, params, headers)
26
- conn = Faraday.new(:url => api_endpoint) do |faraday|
24
+ conn = Faraday.new(url: api_endpoint) do |faraday|
27
25
  faraday.request :url_encoded
28
26
  faraday.adapter Faraday.default_adapter
29
27
  end
30
28
 
31
- response = conn.post do |req|
29
+ conn.post do |req|
32
30
  req.url action
33
31
  req.params = params
34
32
  req.headers = headers
@@ -36,12 +34,12 @@ module FirstGiving
36
34
  end
37
35
 
38
36
  def get_call(api_endpoint, action, params, headers)
39
- conn = Faraday.new(:url => api_endpoint) do |faraday|
37
+ conn = Faraday.new(url: api_endpoint) do |faraday|
40
38
  faraday.request :url_encoded # form-encode POST params
41
39
  faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
42
40
  end
43
41
 
44
- response = conn.get do |req|
42
+ conn.get do |req|
45
43
  req.url action
46
44
  req.params = params
47
45
  req.headers = headers
@@ -51,7 +49,5 @@ module FirstGiving
51
49
  def logging(msg)
52
50
  puts "[FG-LOG] #{msg}" if FirstGiving.configuration.options[:verbose]
53
51
  end
54
-
55
52
  end
56
53
  end
57
-
@@ -1,15 +1,13 @@
1
1
  require 'crack'
2
2
 
3
3
  module FirstGiving
4
-
5
4
  class Donation
6
-
7
5
  include Base
8
6
 
9
7
  module Actions
10
- CREDITCARD = "/donation/creditcard"
11
- RECURRING_CREDITCARD_PROFILE = "/donation/recurringcreditcardprofile"
12
- VERIFY = "/verify"
8
+ CREDITCARD = '/donation/creditcard'
9
+ RECURRING_CREDITCARD_PROFILE = '/donation/recurringcreditcardprofile'
10
+ VERIFY = '/verify'
13
11
  end
14
12
 
15
13
  def initialize
@@ -39,6 +37,4 @@ module FirstGiving
39
37
  Crack::XML.parse(body)
40
38
  end
41
39
  end
42
-
43
40
  end
44
-
@@ -2,14 +2,12 @@ require 'crack'
2
2
  # lookup API
3
3
 
4
4
  module FirstGiving
5
-
6
5
  class Lookup
7
-
8
6
  include Base
9
7
 
10
8
  module Actions
11
- TRANSACTION_LIST = "/transaction/list"
12
- TRANSACTION_DETAIL = "/transaction/detail"
9
+ TRANSACTION_LIST = '/transaction/list'
10
+ TRANSACTION_DETAIL = '/transaction/detail'
13
11
  end
14
12
 
15
13
  def initialize
@@ -38,5 +36,4 @@ module FirstGiving
38
36
  Crack::XML.parse(body)
39
37
  end
40
38
  end
41
-
42
39
  end
@@ -3,13 +3,11 @@ require 'json'
3
3
  # Search API
4
4
 
5
5
  module FirstGiving
6
-
7
6
  class Search
8
-
9
7
  include Base
10
8
 
11
9
  module Actions
12
- LIST_ORGANIZATION = "/v1/list/organization"
10
+ LIST_ORGANIZATION = '/v1/list/organization'
13
11
  end
14
12
 
15
13
  def initialize
@@ -17,7 +15,7 @@ module FirstGiving
17
15
  end
18
16
 
19
17
  def headers
20
- {'Accept' => 'application/json'}
18
+ { 'Accept' => 'application/json' }
21
19
  end
22
20
 
23
21
  def query(params)
@@ -30,5 +28,4 @@ module FirstGiving
30
28
  response['payload']
31
29
  end
32
30
  end
33
-
34
31
  end
@@ -1,3 +1,3 @@
1
1
  module FirstGiving
2
- VERSION = "1.0.0"
2
+ VERSION = '1.0.1'
3
3
  end
@@ -2,11 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe FirstGiving do
4
4
 
5
- APPLICATION_KEY = "ADD YOUR APP KEY HERE"
6
- SECURITY_TOKEN = "ADD YOUR SECURITY TOKEN HERE"
5
+ APPLICATION_KEY = ''
6
+ SECURITY_TOKEN = ''
7
7
 
8
8
  OPTIONS = {
9
- :use_staging => true
9
+ use_staging: true
10
10
  }
11
11
 
12
12
  FirstGiving.configure do |config|
@@ -15,73 +15,75 @@ describe FirstGiving do
15
15
  config.options = OPTIONS
16
16
  end
17
17
 
18
- @transacionId = "a-a8ca75adcda6874abd9c5b"
18
+ raise 'Set your APPLICATION_KEY and SECURITY_TOKEN' if APPLICATION_KEY.empty? || SECURITY_TOKEN.empty?
19
19
 
20
- describe "Test Donation API" do
20
+ @transaction_id = 'a-a8ca75adcda6874abd9c5b'
21
21
 
22
- it "should donate" do
22
+ describe 'Test Donation API' do
23
+
24
+ it 'should donate' do
23
25
  params = {
24
- :ccNumber => "4457010000000009",
25
- :ccType => "VI",
26
- :ccExpDateMonth => "01",
27
- :ccExpDateYear => "14",
28
- :billToAddressLine1 => "1 Main St.",
29
- :billToCity => "Burlington",
30
- :billToState => "MA",
31
- :billToZip => "01803",
32
- :remoteAddr => "120.138.91.2",
33
- :amount => "10.00",
34
- :currencyCode => "USD",
35
- :charityId => "1234",
36
- :description => "Test transaction",
37
- :ccCardValidationNum => "349",
38
- :billToFirstName => "Smith",
39
- :billToLastName => "John",
40
- :billToCountry => "US",
41
- :billToEmail => "test@example.com"
26
+ ccNumber: '4457010000000009',
27
+ ccType: 'VI',
28
+ ccExpDateMonth: '01',
29
+ ccExpDateYear: '2020',
30
+ billToAddressLine1: '1 Main St.',
31
+ billToCity: 'Burlington',
32
+ billToState: 'MA',
33
+ billToZip: '01803',
34
+ remoteAddr: '120.138.91.2',
35
+ amount: '10.00',
36
+ currencyCode: 'USD',
37
+ charityId: '1234',
38
+ description: 'Test transaction',
39
+ ccCardValidationNum: '349',
40
+ billToFirstName: 'Smith',
41
+ billToLastName: 'John',
42
+ billToCountry: 'US',
43
+ billToEmail: 'test@example.com'
42
44
  }
43
45
 
44
46
  response = FG.donation.creditcard(params)
45
47
  ## Response should success
46
48
  assert_acknowledgement(response)
47
49
  ## Response should contain transaction ID
48
- @transactionId = response["firstGivingDonationApi"]["firstGivingResponse"]["transactionId"]
49
- @transactionId.should_not be_nil
50
+ @transaction_id = response['firstGivingDonationApi']['firstGivingResponse']['transactionId']
51
+ @transaction_id.should_not be_nil
50
52
  end
51
53
 
52
- it "should verify" do
54
+ it 'should verify' do
53
55
  params = {
54
- :message => "value1",
55
- :signature => "value2"
56
+ message: 'value1',
57
+ signature: 'value2'
56
58
  }
57
59
 
58
60
  response = FG.donation.verify(params)
59
61
  ## Response should return the same message and signature
60
- response["firstGivingDonationApi"]["firstGivingResponse"]["signature"] == "value2"
61
- response["firstGivingDonationApi"]["firstGivingResponse"]["message"] == "value1"
62
+ response['firstGivingDonationApi']['firstGivingResponse']['signature'] == 'value2'
63
+ response['firstGivingDonationApi']['firstGivingResponse']['message'] == 'value1'
62
64
  end
63
65
 
64
- it "shoould recure the payment" do
66
+ it 'shoould recure the payment' do
65
67
  end
66
68
 
67
69
  end
68
70
 
69
- describe "Test Lookup API" do
71
+ describe 'Test Lookup API' do
70
72
 
71
- it "should return a list of transactions" do
73
+ it 'should return a list of transactions' do
72
74
  params = {
73
75
  page_size: 10,
74
- date_from: "1388707200",
75
- count: 100,
76
+ date_from: '1388707200',
77
+ count: 10,
76
78
  page: 1
77
79
  }
78
80
  resp = FG.lookup.list(params)
79
81
  assert_acknowledgement(resp)
80
82
  end
81
83
 
82
- it "should return a transaction detail" do
84
+ it 'should return a transaction detail' do
83
85
  params = {
84
- transactionId: "a-0070dde28ca48048a1fc24"
86
+ transactionId: 'a-0070dde28ca48048a1fc24'
85
87
  }
86
88
  resp = FG.lookup.detail(params)
87
89
  assert_acknowledgement(resp)
@@ -89,53 +91,53 @@ describe FirstGiving do
89
91
 
90
92
  end
91
93
 
92
- context "Test Search API" do
94
+ context 'Test Search API' do
93
95
 
94
- describe "retrieving a charity by EIN" do
95
- it "should return data for charities" do
96
+ describe 'retrieving a charity by EIN' do
97
+ it 'should return data for charities' do
96
98
  params = {
97
- q: "government_id:260046127"
99
+ q: 'government_id:260046127'
98
100
  }
99
101
 
100
102
  response = FG.search.query(params)
101
103
  response.should_not be_nil
102
- response[0]["government_id"].should eq "260046127"
104
+ response[0]['government_id'].should eq '260046127'
103
105
  end
104
106
  end
105
107
 
106
- describe "searching for records by organization name" do
107
- it "exact name matching and partial or name start" do
108
+ describe 'searching for records by organization name' do
109
+ it 'exact name matching and partial or name start' do
108
110
  params = {
109
- q: "organization_name:humane society"
111
+ q: 'organization_name:humane society'
110
112
  }
111
113
 
112
114
  response = FG.search.query(params)
113
115
  response.should_not be_nil
114
- response[0]["organization_name"].should include "HUMANE SOCIETY"
116
+ response[0]['organization_name'].should include 'HUMANE SOCIETY'
115
117
  end
116
118
 
117
- it "country constraints" do
119
+ it 'country constraints' do
118
120
  params = {
119
- q: "organization_name:bat AND country:US"
121
+ q: 'organization_name:bat AND country:US'
120
122
  }
121
123
 
122
124
  response = FG.search.query(params)
123
125
  response.should_not be_nil
124
- response[0]["organization_name"].should include "BAT"
125
- response[0]["country"].should eq "US"
126
+ response[0]['organization_name'].should include 'BAT'
127
+ response[0]['country'].should eq 'US'
126
128
  end
127
129
 
128
- it "pagination" do
130
+ it 'pagination' do
129
131
  params = {
130
- q: "organization_name:bat AND country:US",
131
- page_size: "10",
132
+ q: 'organization_name:bat AND country:US',
133
+ page_size: '10',
132
134
  page: 1
133
135
  }
134
136
 
135
137
  response = FG.search.query(params)
136
138
  response.should_not be_nil
137
- response[0]["organization_name"].should include "BAT"
138
- response[0]["country"].should eq "US"
139
+ response[0]['organization_name'].should include 'BAT'
140
+ response[0]['country'].should eq 'US'
139
141
  response.count.should eq 10
140
142
  end
141
143
  end
@@ -144,6 +146,6 @@ describe FirstGiving do
144
146
  private
145
147
 
146
148
  def assert_acknowledgement(response)
147
- response["firstGivingDonationApi"]["firstGivingResponse"]["acknowledgement"].should eq "Success"
149
+ response['firstGivingDonationApi']['firstGivingResponse']['acknowledgement'].should eq 'Success'
148
150
  end
149
151
  end
@@ -3,4 +3,3 @@ require 'firstgiving'
3
3
  require 'coveralls'
4
4
  require 'faraday'
5
5
  Coveralls.wear!
6
-
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.0
4
+ version: 1.0.1
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-01-17 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,70 +28,70 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '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
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: crack
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ! '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: faraday
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: FirstGiving Ruby API client
@@ -126,12 +126,12 @@ require_paths:
126
126
  - lib
127
127
  required_ruby_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ! '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - '>='
134
+ - - ! '>='
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []