dwolla_v2 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74ea9b8ec53ca41799d04f1070f017272dd0a579
4
- data.tar.gz: 54317292cbddc52245eb3e9c8932491e3cfdfc17
3
+ metadata.gz: 9335201401d3381e9a1e7ffdc143ccd991a3fd67
4
+ data.tar.gz: bc65a7a240f407c133a4401c1a48f0a13ebd6f8a
5
5
  SHA512:
6
- metadata.gz: 27f8d6a9381f1617dbf5b39559951fb73247c8b139c9d43ea954c8b6fcc268faaa0cfede23f5700e980784e1f1b1abb87a28ad02fab967d846bb31d8ea6c521a
7
- data.tar.gz: ef5920834152e90fe2de68e055129f48eea061b1342530c5e750095a31b6e8754731115327941607ebd7fcf6af67730abbd81a46a4bd9c5c3e67d6a2a7a7779f
6
+ metadata.gz: ccafd26042ddaefbc9acdbf0abf38900103b8a15f3285ac3e77d0def25d2121d966df317bd18ff7384c7ee2e2e600789b8f3f5a8634180b0197c60595203610b
7
+ data.tar.gz: e50f913627d1935001da5e5676fa85ebc9cac4bc0046bfdf7721b298c3137fe764de41a724ce23902c7bc0e0ca1f593e0f1684e25ed34e7c12e267eef1406c7a
data/README.md CHANGED
@@ -165,5 +165,6 @@ The gem is available as open source under the terms of the [MIT License](https:/
165
165
 
166
166
  ## Changelog
167
167
 
168
+ - **0.3.0** - ISO8601 values in response body are converted to `Time` objects
168
169
  - **0.2.0** - Works with `attr_encrypted`
169
170
  - **0.1.1** - Handle 500 error with HTML response body when requesting a token
data/lib/dwolla_v2.rb CHANGED
@@ -16,6 +16,7 @@ require "dwolla_v2/error"
16
16
  require "dwolla_v2/util"
17
17
 
18
18
  require "dwolla_v2/middleware/symbolize_response_body"
19
+ require "dwolla_v2/middleware/parse_iso8601_response_body"
19
20
  require "dwolla_v2/middleware/handle_errors"
20
21
 
21
22
  # OAuth errors https://tools.ietf.org/html/rfc6749
@@ -0,0 +1,13 @@
1
+ module DwollaV2
2
+ class ParseIso8601ResponseBody
3
+ def initialize app
4
+ @app = app
5
+ end
6
+
7
+ def call request_env
8
+ @app.call(request_env).on_complete do |response_env|
9
+ response_env.body = Util.deep_parse_iso8601_values(response_env.body)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -52,6 +52,7 @@ module DwollaV2
52
52
  f.request :multipart
53
53
  f.request :json
54
54
  f.use HandleErrors
55
+ f.use ParseIso8601ResponseBody
55
56
  f.use SymbolizeResponseBody
56
57
  f.response :json, :content_type => /\bjson$/
57
58
  client.faraday.call(f) if client.faraday
@@ -10,6 +10,18 @@ module DwollaV2
10
10
  end
11
11
  end
12
12
 
13
+ def self.deep_parse_iso8601_values obj
14
+ if obj.is_a? Hash
15
+ Hash[obj.map{|k,v| [k, deep_parse_iso8601_values(v)] }]
16
+ elsif obj.is_a? Array
17
+ obj.map {|i| deep_parse_iso8601_values(i) }
18
+ elsif obj.is_a? String
19
+ Time.iso8601 obj rescue obj
20
+ else
21
+ obj
22
+ end
23
+ end
24
+
13
25
  def self.classify str
14
26
  str.split("_").map do |i|
15
27
  i.sub(/^(.)/) { $1.capitalize }
@@ -1,3 +1,3 @@
1
1
  module DwollaV2
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dwolla_v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Ausman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-22 00:00:00.000000000 Z
11
+ date: 2016-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -140,6 +140,7 @@ files:
140
140
  - lib/dwolla_v2/errors/unsupported_response_type_error.rb
141
141
  - lib/dwolla_v2/errors/validation_error.rb
142
142
  - lib/dwolla_v2/middleware/handle_errors.rb
143
+ - lib/dwolla_v2/middleware/parse_iso8601_response_body.rb
143
144
  - lib/dwolla_v2/middleware/symbolize_response_body.rb
144
145
  - lib/dwolla_v2/portal.rb
145
146
  - lib/dwolla_v2/response.rb