dwolla_swagger 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/dwolla_swagger.gemspec +32 -0
  3. data/lib/dwolla_swagger/api/accounts_api.rb +54 -0
  4. data/lib/dwolla_swagger/api/customers_api.rb +223 -0
  5. data/lib/dwolla_swagger/api/documents_api.rb +54 -0
  6. data/lib/dwolla_swagger/api/events_api.rb +98 -0
  7. data/lib/dwolla_swagger/api/fundingsources_api.rb +231 -0
  8. data/lib/dwolla_swagger/api/transfers_api.rb +143 -0
  9. data/lib/dwolla_swagger/api/webhooks_api.rb +190 -0
  10. data/lib/dwolla_swagger/api/webhooksubscriptions_api.rb +179 -0
  11. data/lib/dwolla_swagger/models/account_info.rb +62 -0
  12. data/lib/dwolla_swagger/models/amount.rb +44 -0
  13. data/lib/dwolla_swagger/models/application_event.rb +86 -0
  14. data/lib/dwolla_swagger/models/base_object.rb +84 -0
  15. data/lib/dwolla_swagger/models/create_customer.rb +132 -0
  16. data/lib/dwolla_swagger/models/create_funding_source_request.rb +60 -0
  17. data/lib/dwolla_swagger/models/create_webhook.rb +44 -0
  18. data/lib/dwolla_swagger/models/customer.rb +102 -0
  19. data/lib/dwolla_swagger/models/customer_list_response.rb +54 -0
  20. data/lib/dwolla_swagger/models/document.rb +78 -0
  21. data/lib/dwolla_swagger/models/document_list_response.rb +54 -0
  22. data/lib/dwolla_swagger/models/event_list_response.rb +54 -0
  23. data/lib/dwolla_swagger/models/funding_source.rb +96 -0
  24. data/lib/dwolla_swagger/models/funding_source_list_response.rb +46 -0
  25. data/lib/dwolla_swagger/models/hal_link.rb +44 -0
  26. data/lib/dwolla_swagger/models/money.rb +44 -0
  27. data/lib/dwolla_swagger/models/transfer.rb +86 -0
  28. data/lib/dwolla_swagger/models/transfer_list_response.rb +54 -0
  29. data/lib/dwolla_swagger/models/transfer_request_body.rb +54 -0
  30. data/lib/dwolla_swagger/models/unit__.rb +28 -0
  31. data/lib/dwolla_swagger/models/webhook.rb +96 -0
  32. data/lib/dwolla_swagger/models/webhook_attempt.rb +52 -0
  33. data/lib/dwolla_swagger/models/webhook_event_list_response.rb +54 -0
  34. data/lib/dwolla_swagger/models/webhook_header.rb +44 -0
  35. data/lib/dwolla_swagger/models/webhook_http_request.rb +62 -0
  36. data/lib/dwolla_swagger/models/webhook_http_response.rb +62 -0
  37. data/lib/dwolla_swagger/models/webhook_list_response.rb +54 -0
  38. data/lib/dwolla_swagger/models/webhook_retry.rb +70 -0
  39. data/lib/dwolla_swagger/models/webhook_retry_request_list_response.rb +54 -0
  40. data/lib/dwolla_swagger/models/webhook_subscription.rb +70 -0
  41. data/lib/dwolla_swagger/monkey.rb +90 -0
  42. data/lib/dwolla_swagger/swagger/configuration.rb +29 -0
  43. data/lib/dwolla_swagger/swagger/request.rb +264 -0
  44. data/lib/dwolla_swagger/swagger/response.rb +70 -0
  45. data/lib/dwolla_swagger/swagger/version.rb +5 -0
  46. data/lib/dwolla_swagger/swagger.rb +78 -0
  47. data/lib/dwolla_swagger.rb +54 -0
  48. metadata +294 -0
@@ -0,0 +1,70 @@
1
+ module DwollaSwagger
2
+ module Swagger
3
+ class Response
4
+ require 'json'
5
+
6
+ attr_accessor :raw
7
+
8
+ def initialize(raw)
9
+ self.raw = raw
10
+
11
+ case self.code
12
+ when 500..510 then raise(ServerError, self.error_message)
13
+ when 299..426 then raise(ClientError, self.error_message)
14
+ end
15
+ end
16
+
17
+ def code
18
+ raw.code
19
+ end
20
+
21
+ # Account for error messages that take different forms...
22
+ def error_message
23
+ body['message']
24
+ rescue
25
+ body
26
+ end
27
+
28
+ # If body is JSON, parse it
29
+ # Otherwise return raw string
30
+ def body
31
+ JSON.parse(raw.body, :symbolize_names => true)
32
+ rescue
33
+ raw.body
34
+ end
35
+
36
+ # `headers_hash` is a Typhoeus-specific extension of Hash,
37
+ # so simplify it back into a regular old Hash.
38
+ def headers
39
+ h = {}
40
+ raw.headers_hash.each {|k,v| h[k] = v }
41
+ h
42
+ end
43
+
44
+ # Extract the response format from the header hash
45
+ # e.g. {'Content-Type' => 'application/json'}
46
+ def format
47
+ headers['Content-Type'].split("/").last.downcase
48
+ end
49
+
50
+ def json?
51
+ format == 'json'
52
+ end
53
+
54
+ def xml?
55
+ format == 'xml'
56
+ end
57
+
58
+ def pretty_body
59
+ return unless body.present?
60
+ case format
61
+ when 'json' then JSON.pretty_generate(body).gsub(/\n/, '<br/>')
62
+ end
63
+ end
64
+
65
+ def pretty_headers
66
+ JSON.pretty_generate(headers).gsub(/\n/, '<br/>')
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,5 @@
1
+ module DwollaSwagger
2
+ module Swagger
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,78 @@
1
+ require 'logger'
2
+ require 'json'
3
+
4
+ module DwollaSwagger
5
+ module Swagger
6
+ class << self
7
+ attr_accessor :logger
8
+
9
+ # A Swagger configuration object. Must act like a hash and return sensible
10
+ # values for all Swagger configuration options. See Swagger::Configuration.
11
+ attr_accessor :configuration
12
+
13
+ attr_accessor :resources
14
+
15
+ # Call this method to modify defaults in your initializers.
16
+ #
17
+ # @example
18
+ # Swagger.configure do |config|
19
+ # config.api_key['api_key'] = '1234567890abcdef' # api key authentication
20
+ # config.username = 'wordlover' # http basic authentication
21
+ # config.password = 'i<3words' # http basic authentication
22
+ # config.format = 'json' # optional, defaults to 'json'
23
+ # end
24
+ #
25
+ def configure
26
+ yield(configuration) if block_given?
27
+
28
+ # Configure logger. Default to use Rails
29
+ self.logger ||= configuration.logger || (defined?(Rails) ? Rails.logger : Logger.new(STDOUT))
30
+
31
+ # remove :// from scheme
32
+ configuration.scheme.sub!(/:\/\//, '')
33
+
34
+ # remove http(s):// and anything after a slash
35
+ configuration.host.sub!(/https?:\/\//, '')
36
+ configuration.host = configuration.host.split('/').first
37
+
38
+ # Add leading and trailing slashes to base_path
39
+ configuration.base_path = "/#{configuration.base_path}".gsub(/\/+/, '/')
40
+ configuration.base_path = "" if configuration.base_path == "/"
41
+ end
42
+
43
+ def authenticated?
44
+ Swagger.configuration.auth_token.present?
45
+ end
46
+
47
+ def de_authenticate
48
+ Swagger.configuration.auth_token = nil
49
+ end
50
+
51
+ def authenticate
52
+ return if Swagger.authenticated?
53
+
54
+ if Swagger.configuration.username.blank? || Swagger.configuration.password.blank?
55
+ raise ClientError, "Username and password are required to authenticate."
56
+ end
57
+
58
+ request = Swagger::Request.new(
59
+ :get,
60
+ "account/authenticate/{username}",
61
+ :params => {
62
+ :username => Swagger.configuration.username,
63
+ :password => Swagger.configuration.password
64
+ }
65
+ )
66
+
67
+ response_body = request.response.body
68
+ Swagger.configuration.auth_token = response_body['token']
69
+ end
70
+ end
71
+ end
72
+
73
+ class ServerError < StandardError
74
+ end
75
+
76
+ class ClientError < StandardError
77
+ end
78
+ end
@@ -0,0 +1,54 @@
1
+ # Swagger common files
2
+ require 'dwolla_swagger/monkey'
3
+ require 'dwolla_swagger/swagger'
4
+ require 'dwolla_swagger/swagger/configuration'
5
+ require 'dwolla_swagger/swagger/request'
6
+ require 'dwolla_swagger/swagger/response'
7
+ require 'dwolla_swagger/swagger/version'
8
+
9
+ # Models
10
+ require 'dwolla_swagger/models/base_object'
11
+ require 'dwolla_swagger/models/webhook_http_request'
12
+ require 'dwolla_swagger/models/webhook_event_list_response'
13
+ require 'dwolla_swagger/models/account_info'
14
+ require 'dwolla_swagger/models/hal_link'
15
+ require 'dwolla_swagger/models/document_list_response'
16
+ require 'dwolla_swagger/models/customer_list_response'
17
+ require 'dwolla_swagger/models/transfer_list_response'
18
+ require 'dwolla_swagger/models/application_event'
19
+ require 'dwolla_swagger/models/transfer_request_body'
20
+ require 'dwolla_swagger/models/webhook_retry'
21
+ require 'dwolla_swagger/models/webhook_subscription'
22
+ require 'dwolla_swagger/models/funding_source_list_response'
23
+ require 'dwolla_swagger/models/create_customer'
24
+ require 'dwolla_swagger/models/unit__'
25
+ require 'dwolla_swagger/models/customer'
26
+ require 'dwolla_swagger/models/document'
27
+ require 'dwolla_swagger/models/webhook_list_response'
28
+ require 'dwolla_swagger/models/amount'
29
+ require 'dwolla_swagger/models/webhook_header'
30
+ require 'dwolla_swagger/models/webhook_attempt'
31
+ require 'dwolla_swagger/models/money'
32
+ require 'dwolla_swagger/models/webhook'
33
+ require 'dwolla_swagger/models/funding_source'
34
+ require 'dwolla_swagger/models/transfer'
35
+ require 'dwolla_swagger/models/event_list_response'
36
+ require 'dwolla_swagger/models/create_funding_source_request'
37
+ require 'dwolla_swagger/models/webhook_retry_request_list_response'
38
+ require 'dwolla_swagger/models/create_webhook'
39
+ require 'dwolla_swagger/models/webhook_http_response'
40
+
41
+ # APIs
42
+ require 'dwolla_swagger/api/webhooksubscriptions_api'
43
+ require 'dwolla_swagger/api/fundingsources_api'
44
+ require 'dwolla_swagger/api/customers_api'
45
+ require 'dwolla_swagger/api/events_api'
46
+ require 'dwolla_swagger/api/documents_api'
47
+ require 'dwolla_swagger/api/transfers_api'
48
+ require 'dwolla_swagger/api/webhooks_api'
49
+ require 'dwolla_swagger/api/accounts_api'
50
+
51
+ module DwollaSwagger
52
+ # Initialize the default configuration
53
+ Swagger.configuration ||= Swagger::Configuration.new
54
+ end
metadata ADDED
@@ -0,0 +1,294 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dwolla_swagger
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Zeke Sikelianos
8
+ - Tony Tam
9
+ - David Stancu
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-09-28 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: typhoeus
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.2'
22
+ - - '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 0.2.1
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: '0.2'
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: 0.2.1
35
+ - !ruby/object:Gem::Dependency
36
+ name: addressable
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '2.2'
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: 2.2.4
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ~>
50
+ - !ruby/object:Gem::Version
51
+ version: '2.2'
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.2.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.4'
62
+ - - '>='
63
+ - !ruby/object:Gem::Version
64
+ version: 1.4.6
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: '1.4'
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: 1.4.6
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ version: '3.2'
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: 3.2.0
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ version: '3.2'
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: 3.2.0
95
+ - !ruby/object:Gem::Dependency
96
+ name: vcr
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '2.9'
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: 2.9.3
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: '2.9'
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: 2.9.3
115
+ - !ruby/object:Gem::Dependency
116
+ name: webmock
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ~>
120
+ - !ruby/object:Gem::Version
121
+ version: '1.6'
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.6.2
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: '1.6'
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: 1.6.2
135
+ - !ruby/object:Gem::Dependency
136
+ name: autotest
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '4.4'
142
+ - - '>='
143
+ - !ruby/object:Gem::Version
144
+ version: 4.4.6
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ~>
150
+ - !ruby/object:Gem::Version
151
+ version: '4.4'
152
+ - - '>='
153
+ - !ruby/object:Gem::Version
154
+ version: 4.4.6
155
+ - !ruby/object:Gem::Dependency
156
+ name: autotest-rails-pure
157
+ requirement: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ~>
160
+ - !ruby/object:Gem::Version
161
+ version: '4.1'
162
+ - - '>='
163
+ - !ruby/object:Gem::Version
164
+ version: 4.1.2
165
+ type: :development
166
+ prerelease: false
167
+ version_requirements: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ~>
170
+ - !ruby/object:Gem::Version
171
+ version: '4.1'
172
+ - - '>='
173
+ - !ruby/object:Gem::Version
174
+ version: 4.1.2
175
+ - !ruby/object:Gem::Dependency
176
+ name: autotest-growl
177
+ requirement: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ version: '0.2'
182
+ - - '>='
183
+ - !ruby/object:Gem::Version
184
+ version: 0.2.16
185
+ type: :development
186
+ prerelease: false
187
+ version_requirements: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ~>
190
+ - !ruby/object:Gem::Version
191
+ version: '0.2'
192
+ - - '>='
193
+ - !ruby/object:Gem::Version
194
+ version: 0.2.16
195
+ - !ruby/object:Gem::Dependency
196
+ name: autotest-fsevent
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ~>
200
+ - !ruby/object:Gem::Version
201
+ version: '0.2'
202
+ - - '>='
203
+ - !ruby/object:Gem::Version
204
+ version: 0.2.10
205
+ type: :development
206
+ prerelease: false
207
+ version_requirements: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - ~>
210
+ - !ruby/object:Gem::Version
211
+ version: '0.2'
212
+ - - '>='
213
+ - !ruby/object:Gem::Version
214
+ version: 0.2.10
215
+ description: Dwolla API V2 Swagger SDK wrapper.
216
+ email:
217
+ - zeke@wordnik.com
218
+ - fehguy@gmail.com
219
+ - dstancu@nyu.edu
220
+ executables: []
221
+ extensions: []
222
+ extra_rdoc_files: []
223
+ files:
224
+ - dwolla_swagger.gemspec
225
+ - lib/dwolla_swagger.rb
226
+ - lib/dwolla_swagger/api/accounts_api.rb
227
+ - lib/dwolla_swagger/api/customers_api.rb
228
+ - lib/dwolla_swagger/api/documents_api.rb
229
+ - lib/dwolla_swagger/api/events_api.rb
230
+ - lib/dwolla_swagger/api/fundingsources_api.rb
231
+ - lib/dwolla_swagger/api/transfers_api.rb
232
+ - lib/dwolla_swagger/api/webhooks_api.rb
233
+ - lib/dwolla_swagger/api/webhooksubscriptions_api.rb
234
+ - lib/dwolla_swagger/models/account_info.rb
235
+ - lib/dwolla_swagger/models/amount.rb
236
+ - lib/dwolla_swagger/models/application_event.rb
237
+ - lib/dwolla_swagger/models/base_object.rb
238
+ - lib/dwolla_swagger/models/create_customer.rb
239
+ - lib/dwolla_swagger/models/create_funding_source_request.rb
240
+ - lib/dwolla_swagger/models/create_webhook.rb
241
+ - lib/dwolla_swagger/models/customer.rb
242
+ - lib/dwolla_swagger/models/customer_list_response.rb
243
+ - lib/dwolla_swagger/models/document.rb
244
+ - lib/dwolla_swagger/models/document_list_response.rb
245
+ - lib/dwolla_swagger/models/event_list_response.rb
246
+ - lib/dwolla_swagger/models/funding_source.rb
247
+ - lib/dwolla_swagger/models/funding_source_list_response.rb
248
+ - lib/dwolla_swagger/models/hal_link.rb
249
+ - lib/dwolla_swagger/models/money.rb
250
+ - lib/dwolla_swagger/models/transfer.rb
251
+ - lib/dwolla_swagger/models/transfer_list_response.rb
252
+ - lib/dwolla_swagger/models/transfer_request_body.rb
253
+ - lib/dwolla_swagger/models/unit__.rb
254
+ - lib/dwolla_swagger/models/webhook.rb
255
+ - lib/dwolla_swagger/models/webhook_attempt.rb
256
+ - lib/dwolla_swagger/models/webhook_event_list_response.rb
257
+ - lib/dwolla_swagger/models/webhook_header.rb
258
+ - lib/dwolla_swagger/models/webhook_http_request.rb
259
+ - lib/dwolla_swagger/models/webhook_http_response.rb
260
+ - lib/dwolla_swagger/models/webhook_list_response.rb
261
+ - lib/dwolla_swagger/models/webhook_retry.rb
262
+ - lib/dwolla_swagger/models/webhook_retry_request_list_response.rb
263
+ - lib/dwolla_swagger/models/webhook_subscription.rb
264
+ - lib/dwolla_swagger/monkey.rb
265
+ - lib/dwolla_swagger/swagger.rb
266
+ - lib/dwolla_swagger/swagger/configuration.rb
267
+ - lib/dwolla_swagger/swagger/request.rb
268
+ - lib/dwolla_swagger/swagger/response.rb
269
+ - lib/dwolla_swagger/swagger/version.rb
270
+ homepage: http://developers.dwolla.com
271
+ licenses:
272
+ - Apache-2.0
273
+ metadata: {}
274
+ post_install_message:
275
+ rdoc_options: []
276
+ require_paths:
277
+ - lib
278
+ required_ruby_version: !ruby/object:Gem::Requirement
279
+ requirements:
280
+ - - '>='
281
+ - !ruby/object:Gem::Version
282
+ version: '0'
283
+ required_rubygems_version: !ruby/object:Gem::Requirement
284
+ requirements:
285
+ - - '>='
286
+ - !ruby/object:Gem::Version
287
+ version: '0'
288
+ requirements: []
289
+ rubyforge_project:
290
+ rubygems_version: 2.0.14
291
+ signing_key:
292
+ specification_version: 4
293
+ summary: Dwolla API V2 SDK
294
+ test_files: []