fake_dwolla 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5bd4f743f034479b258eb531695f47e70fbf3893
4
+ data.tar.gz: 3df997df88cda4f0afd921f8999b1512644ef696
5
+ SHA512:
6
+ metadata.gz: be2aeb87c7be022713efb7d1cc934b31f90217051676207f2b3ad4ab5afbf3222d8b41e483998c0463e4732861fffe8d6993f0d0194938591807eaa51f8750b5
7
+ data.tar.gz: afeaab5dd8a3b1194461e5fcad6557f48222933b7a241398b7711f718d0d3f143dee8f3c49daf10139f3758ff6890013f60323bffb59b09eb48ffd5feb235458
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # A Dwolla Fake
2
+
3
+ ## Reference
4
+
5
+ [fake_stripe](https://github.com/thoughtbot/fake_stripe)
6
+
7
+ ## Installation
8
+
9
+ ### Gemfile
10
+
11
+ ```ruby
12
+ # Gemfile
13
+ group :test do
14
+ gem 'fake_dwolla'
15
+ end
16
+ ```
17
+
18
+
19
+ ### Rspec
20
+
21
+ Require the library in your spec support:
22
+
23
+ ```ruby
24
+ # spec/support/fake_dwolla.rb
25
+ require 'fake_dwolla'
26
+
27
+ RSpec.configure do |config|
28
+ config.before(:each) do
29
+ FakeDwolla.stub_dwolla
30
+ end
31
+ end
32
+ ```
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,11 @@
1
+ require 'fake_dwolla/configuration'
2
+ require 'fake_dwolla/initializers/webmock'
3
+ require 'fake_dwolla/stub_app'
4
+
5
+ module FakeDwolla
6
+ extend Configuration
7
+
8
+ def self.stub_dwolla
9
+ stub_request(:any, /api-uat.dwolla.com/).to_rack(FakeDwolla::StubApp)
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module FakeDwolla
2
+ module Configuration
3
+ attr_writer :fixture_path
4
+
5
+ DEFAULT_FIXTURE_PATH = File.join(File.dirname(__FILE__), 'fixtures/')
6
+
7
+ def fixture_path
8
+ @fixture_path or DEFAULT_FIXTURE_PATH
9
+ end
10
+
11
+ def configure
12
+ yield self
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ {
2
+ "date":"Mon, 03 Oct 2016 07:42:49 GMT",
3
+ "content-length":"0",
4
+ "connection":"close",
5
+ "set-cookie":"__cfduid=da7e36f58b4370394a069a3ec81c93b8c1475480567; expires=Tue, 03-Oct-17 07:42:47 GMT; path=/; domain=.dwolla.com; HttpOnly",
6
+ "location":"https://api-uat.dwolla.com/customers/44164922-5323-4087-9dc9-648794e9513f",
7
+ "x-content-type-options":"nosniff",
8
+ "x-request-id":"0d9e9448-eccd-4b39-8871-0d4288f0ad74",
9
+ "x-xss-protection":"1; mode=block",
10
+ "server":"cloudflare-nginx",
11
+ "cf-ray":"2ebec26d691f45b4-TPE"
12
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "token":"uS2ScHjliercuo7r2nRXTfYEl85r5KuBmMNeUGECGiEbmp0Y2T"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "location":"https://api.dwolla.com/transfers/74c9129b-d14a-e511-80da-0aa34a9b2388"
3
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "_links":{
3
+ "self":{
4
+ "href":"https://api-uat.dwolla.com/funding-sources/1e25c4ab-e791-4526-9d26-7765d8d62e8b",
5
+ "type":"funding-source"
6
+ }
7
+ },
8
+ "id":"1e25c4ab-e791-4526-9d26-7765d8d62e8b",
9
+ "status":"verified",
10
+ "type":"bank",
11
+ "name":"Your Account #1 - CHECKING",
12
+ "created":"2016-10-04T06:04:59.000Z",
13
+ "removed":true,
14
+ "channels":[
15
+ "ach"
16
+ ]
17
+ }
@@ -0,0 +1,74 @@
1
+ {
2
+ "_links":{
3
+ "self":{
4
+ "href":"https://api-uat.dwolla.com/customers/47bebab7-874b-47bd-9f69-392dce732ca7/funding-sources",
5
+ "type":"funding-source"
6
+ },
7
+ "customer":{
8
+ "href":"https://api-uat.dwolla.com/customers/47bebab7-874b-47bd-9f69-392dce732ca7",
9
+ "type":"customer"
10
+ }
11
+ },
12
+ "_embedded":{
13
+ "funding-sources":[
14
+ {
15
+ "_links":{
16
+ "self":{
17
+ "href":"https://api-uat.dwolla.com/funding-sources/a3a498b0-c5ea-4154-8925-b705ff5ae92d",
18
+ "type":"funding-source"
19
+ },
20
+ "customer":{
21
+ "href":"https://api-uat.dwolla.com/customers/47bebab7-874b-47bd-9f69-392dce732ca7",
22
+ "type":"customer"
23
+ },
24
+ "balance":{
25
+ "href":"https://api-uat.dwolla.com/funding-sources/a3a498b0-c5ea-4154-8925-b705ff5ae92d/balance",
26
+ "type":"balance"
27
+ },
28
+ "on-demand-authorization":{
29
+ "href":"https://api-uat.dwolla.com/on-demand-authorizations/f1ddf7da-9e78-e611-80e7-0aa34a9b2388",
30
+ "type":"on-demand-authorization"
31
+ }
32
+ },
33
+ "id":"a3a498b0-c5ea-4154-8925-b705ff5ae92d",
34
+ "status":"verified",
35
+ "type":"bank",
36
+ "name":"Your Account #1 - CHECKING",
37
+ "created":"2016-09-12T04:10:36.000Z",
38
+ "removed":false,
39
+ "channels":[
40
+ "ach"
41
+ ]
42
+ },
43
+ {
44
+ "_links":{
45
+ "self":{
46
+ "href":"https://api-uat.dwolla.com/funding-sources/830a3ec6-cd01-49c5-85e4-3cb2560150f3",
47
+ "type":"funding-source"
48
+ },
49
+ "customer":{
50
+ "href":"https://api-uat.dwolla.com/customers/47bebab7-874b-47bd-9f69-392dce732ca7",
51
+ "type":"customer"
52
+ },
53
+ "with-available-balance":{
54
+ "href":"https://api-uat.dwolla.com/funding-sources/830a3ec6-cd01-49c5-85e4-3cb2560150f3",
55
+ "type":"funding-source"
56
+ },
57
+ "balance":{
58
+ "href":"https://api-uat.dwolla.com/funding-sources/830a3ec6-cd01-49c5-85e4-3cb2560150f3/balance",
59
+ "type":"balance"
60
+ }
61
+ },
62
+ "id":"830a3ec6-cd01-49c5-85e4-3cb2560150f3",
63
+ "status":"verified",
64
+ "type":"balance",
65
+ "name":"Balance",
66
+ "created":"2016-06-30T07:47:53.000Z",
67
+ "removed":false,
68
+ "channels":[
69
+
70
+ ]
71
+ }
72
+ ]
73
+ }
74
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "_links":{
3
+ "self":{
4
+ "href":"https://api-uat.dwolla.com/funding-sources/830a3ec6-cd01-49c5-85e4-3cb2560150f3/balance",
5
+ "type":"application/vnd.dwolla.v1.hal+json",
6
+ "resource-type":"balance"
7
+ },
8
+ "funding-source":{
9
+ "href":"https://api-uat.dwolla.com/funding-sources/830a3ec6-cd01-49c5-85e4-3cb2560150f3",
10
+ "type":"application/vnd.dwolla.v1.hal+json",
11
+ "resource-type":"funding-source"
12
+ }
13
+ },
14
+ "balance":{
15
+ "value":"4.45",
16
+ "currency":"USD"
17
+ },
18
+ "lastUpdated":"2016-11-08T09:40:44.599Z"
19
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "_links":{
3
+ "source":{
4
+ "href":"https://api-uat.dwolla.com/customers/cb3cb50e-7908-4ee8-9f98-608d9669eed7",
5
+ "type":"application/vnd.dwolla.v1.hal+json",
6
+ "resource-type":"customer"
7
+ },
8
+ "funding-transfer":{
9
+ "href":"https://api-uat.dwolla.com/transfers/fd51bc97-7d97-e611-80e9-0aa34a9b2388",
10
+ "type":"application/vnd.dwolla.v1.hal+json",
11
+ "resource-type":"transfer"
12
+ },
13
+ "destination-funding-source":{
14
+ "href":"https://api-uat.dwolla.com/funding-sources/7c721aaa-2811-43be-b420-bfde2d8ab5c7",
15
+ "type":"application/vnd.dwolla.v1.hal+json",
16
+ "resource-type":"funding-source"
17
+ },
18
+ "self":{
19
+ "href":"https://api-uat.dwolla.com/transfers/fe51bc97-7d97-e611-80e9-0aa34a9b2388",
20
+ "type":"application/vnd.dwolla.v1.hal+json",
21
+ "resource-type":"transfer"
22
+ },
23
+ "source-funding-source":{
24
+ "href":"https://api-uat.dwolla.com/funding-sources/6e5e56b1-9ea5-441c-a650-39886bd479c7",
25
+ "type":"application/vnd.dwolla.v1.hal+json",
26
+ "resource-type":"funding-source"
27
+ },
28
+ "destination":{
29
+ "href":"https://api-uat.dwolla.com/customers/03c640b3-7f42-4b42-80d1-70722deb8f39",
30
+ "type":"application/vnd.dwolla.v1.hal+json",
31
+ "resource-type":"customer"
32
+ }
33
+ },
34
+ "id":"fe51bc97-7d97-e611-80e9-0aa34a9b2388",
35
+ "status":"processed",
36
+ "amount":{
37
+ "value":"10.00",
38
+ "currency":"usd"
39
+ },
40
+ "created":"2016-10-21T11:00:36.317Z"
41
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "_links":{
3
+ "self":{
4
+ "href":"https://api-uat.dwolla.com/customers/47bebab7-874b-47bd-9f69-392dce732ca7",
5
+ "type":"customer"
6
+ },
7
+ "receive":{
8
+ "href":"https://api-uat.dwolla.com/transfers",
9
+ "type":"transfer"
10
+ },
11
+ "edit":{
12
+ "href":"https://api-uat.dwolla.com/customers/47bebab7-874b-47bd-9f69-392dce732ca7",
13
+ "type":"customer"
14
+ },
15
+ "funding-sources":{
16
+ "href":"https://api-uat.dwolla.com/customers/47bebab7-874b-47bd-9f69-392dce732ca7/funding-sources",
17
+ "type":"funding-source"
18
+ },
19
+ "transfers":{
20
+ "href":"https://api-uat.dwolla.com/customers/47bebab7-874b-47bd-9f69-392dce732ca7/transfers",
21
+ "type":"transfer"
22
+ },
23
+ "send":{
24
+ "href":"https://api-uat.dwolla.com/transfers",
25
+ "type":"transfer"
26
+ }
27
+ },
28
+ "id":"47bebab7-874b-47bd-9f69-392dce732ca7",
29
+ "firstName":"hawaii",
30
+ "lastName":"ho",
31
+ "email":"hawaii_ho@dinngo.co",
32
+ "type":"personal",
33
+ "status":"verified",
34
+ "created":"2016-06-30T07:47:52.173Z",
35
+ "address1":"hahaha ave",
36
+ "city":"San Jose",
37
+ "state":"CA",
38
+ "postalCode":"95127"
39
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "_links":{
3
+ "source":{
4
+ "href":"https://api-uat.dwolla.com/customers/a9a7da31-bed7-47c2-b2a6-d62e8f0ab923",
5
+ "type":"application/vnd.dwolla.v1.hal+json",
6
+ "resource-type":"customer"
7
+ },
8
+ "destination-funding-source":{
9
+ "href":"https://api-uat.dwolla.com/funding-sources/5dbbce95-8180-4742-b2cf-2df73c07ffa6",
10
+ "type":"application/vnd.dwolla.v1.hal+json",
11
+ "resource-type":"funding-source"
12
+ },
13
+ "self":{
14
+ "href":"https://api-uat.dwolla.com/transfers/4b9028cb-9196-e611-80e9-0aa34a9b2388",
15
+ "type":"application/vnd.dwolla.v1.hal+json",
16
+ "resource-type":"transfer"
17
+ },
18
+ "source-funding-source":{
19
+ "href":"https://api-uat.dwolla.com/funding-sources/4e1f2504-a303-4bdc-bfd8-3988237f10fb",
20
+ "type":"application/vnd.dwolla.v1.hal+json",
21
+ "resource-type":"funding-source"
22
+ },
23
+ "destination":{
24
+ "href":"https://api-uat.dwolla.com/customers/ae9f8158-6ca9-420a-aae0-a142a56dce49",
25
+ "type":"application/vnd.dwolla.v1.hal+json",
26
+ "resource-type":"customer"
27
+ }
28
+ },
29
+ "id":"4b9028cb-9196-e611-80e9-0aa34a9b2388",
30
+ "status":"processed",
31
+ "amount":{
32
+ "value":"11.50",
33
+ "currency":"usd"
34
+ },
35
+ "created":"2016-10-20T06:52:41.180Z"
36
+ }
@@ -0,0 +1,4 @@
1
+ require "webmock/rspec"
2
+ include WebMock::API
3
+ WebMock.enable!
4
+ WebMock.disable_net_connect!(allow_localhost: true)
@@ -0,0 +1,72 @@
1
+ require 'sinatra/base'
2
+
3
+ module FakeDwolla
4
+ class StubApp < Sinatra::Base
5
+
6
+ # Customers
7
+ post '/customers' do
8
+ json_headers 200, fixture('create_customer')
9
+ end
10
+
11
+ get '/customers/:customer_id' do
12
+ json_response 200, fixture('retrieve_customer')
13
+ end
14
+
15
+ # Documents
16
+ post '/customers/:customer_id/documents' do
17
+ json_response 200, fixture('create_document')
18
+ end
19
+
20
+ # Instant account verification
21
+ post '/customers/:customer_id/iav-token' do
22
+ json_response 200, fixture('create_iav_token')
23
+ end
24
+
25
+ # Funding Sources
26
+ get '/customers/:customer_id/funding-sources' do
27
+ json_response 200, fixture('list_funding_source')
28
+ end
29
+
30
+ get '/funding-sources/:funding_sources_id/balance' do
31
+ json_response 200, fixture('retrieve_balance')
32
+ end
33
+
34
+ post '/funding-sources/:funding_sources_id' do
35
+ json_response 200, fixture('delete_funding_source')
36
+ end
37
+
38
+ # Transfers
39
+ get '/transfers/:transfer_id' do
40
+ if params[:transfer_id] == "bank_transaction"
41
+ json_response 200, fixture('retrieve_bank_transfer')
42
+ else
43
+ json_response 200, fixture('retrieve_transfer')
44
+ end
45
+ end
46
+
47
+ post '/transfers' do
48
+ json_headers 200, fixture('create_transfer')
49
+ end
50
+
51
+ private
52
+
53
+ def fixture(file_name)
54
+ file_path = File.join(FakeDwolla.fixture_path, "#{file_name}.json")
55
+ File.open(file_path, 'rb').read
56
+ end
57
+
58
+ def json_response(response_code, file)
59
+ content_type :json
60
+ status response_code
61
+ file
62
+ end
63
+
64
+ def json_headers(response_code, file)
65
+ [
66
+ response_code,
67
+ JSON.load(file),
68
+ []
69
+ ]
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,3 @@
1
+ module FakeDwolla
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fake_dwolla
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: webmock
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dwolla_v2
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: An implementation of the Dwolla ACH processing service to run during
112
+ your integration tests.
113
+ email:
114
+ - wangjoe1105@gmail.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - MIT-LICENSE
120
+ - README.md
121
+ - Rakefile
122
+ - lib/fake_dwolla.rb
123
+ - lib/fake_dwolla/configuration.rb
124
+ - lib/fake_dwolla/fixtures/create_customer.json
125
+ - lib/fake_dwolla/fixtures/create_document.json
126
+ - lib/fake_dwolla/fixtures/create_iav_token.json
127
+ - lib/fake_dwolla/fixtures/create_transfer.json
128
+ - lib/fake_dwolla/fixtures/delete_funding_source.json
129
+ - lib/fake_dwolla/fixtures/list_funding_source.json
130
+ - lib/fake_dwolla/fixtures/retrieve_balance.json
131
+ - lib/fake_dwolla/fixtures/retrieve_bank_transfer.json
132
+ - lib/fake_dwolla/fixtures/retrieve_customer.json
133
+ - lib/fake_dwolla/fixtures/retrieve_transfer.json
134
+ - lib/fake_dwolla/initializers/webmock.rb
135
+ - lib/fake_dwolla/stub_app.rb
136
+ - lib/fake_dwolla/version.rb
137
+ homepage: https://github.com/joe11051105
138
+ licenses: []
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.4.5.1
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: A fake Dwolla server.
160
+ test_files: []