dwolla_v2 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +37 -9
- data/lib/dwolla_v2/response.rb +11 -7
- data/lib/dwolla_v2/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 347bf32bfbb4db49d6341c3db975cf696a97f492
|
4
|
+
data.tar.gz: 38d265059cb4ddac927d141096bd145a76cf2c60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 053be0c20b5da0da5c421dcb8979ca1aefcc4a6620c8383e2251b0e458042b222c5c76682051d08706fe2a9f9d8e043d8702bcd8781fc6a89397b9982bc532db
|
7
|
+
data.tar.gz: 43695d6c3e63d61003cac1ba3b72735ebc9f7e53b7926b4cec186f01d4e5b0d34e466091a0405cb340a846511f788493d9bf7cbd779d8b9c18cfe6900e89c9be
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Dwolla V2 Ruby client. For the V1 Ruby client see [Dwolla/dwolla-ruby](https://g
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem 'dwolla_v2', '~> 0.
|
14
|
+
gem 'dwolla_v2', '~> 0.4'
|
15
15
|
```
|
16
16
|
|
17
17
|
And then execute:
|
@@ -64,7 +64,8 @@ class YourAuthController < ApplicationController
|
|
64
64
|
|
65
65
|
def auth
|
66
66
|
$dwolla.auths.new redirect_uri: "https://yoursite.com/callback",
|
67
|
-
scope: "ManageCustomers|Funding"
|
67
|
+
scope: "ManageCustomers|Funding",
|
68
|
+
state: session[:state] ||= SecureRandom.hex(8)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
```
|
@@ -97,21 +98,47 @@ In parallel:
|
|
97
98
|
|
98
99
|
```ruby
|
99
100
|
foo, bar = nil
|
100
|
-
|
101
101
|
token.in_parallel do
|
102
|
-
foo = token.get "/foo"
|
103
|
-
bar = token.get "/bar"
|
102
|
+
foo = token.get "/foo"
|
103
|
+
bar = token.get "/bar"
|
104
104
|
end
|
105
|
+
puts foo # only ready after `in_parallel` block has executed
|
106
|
+
puts bar # only ready after `in_parallel` block has executed
|
107
|
+
```
|
108
|
+
|
109
|
+
#### Responses
|
110
|
+
|
111
|
+
Requests return a `DwollaV2::Response`.
|
105
112
|
|
106
|
-
|
107
|
-
|
113
|
+
**Response status**:
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
res = token.post "/customers", customer_params
|
117
|
+
res.status # => 201
|
108
118
|
```
|
109
119
|
|
110
|
-
|
120
|
+
**Response headers**:
|
111
121
|
|
112
122
|
```ruby
|
113
123
|
customer = token.post "/customers", customer_params
|
114
|
-
customer
|
124
|
+
customer.headers[:location] # => "https://api.dwolla.com/customers/aa76ca27-1920-4a0a-9bbe-a22085c0010e"
|
125
|
+
```
|
126
|
+
|
127
|
+
**Response body**:
|
128
|
+
|
129
|
+
[Enumerable methods](http://ruby-doc.org/core-2.3.0/Enumerable.html), `#==`, and `#[]` are
|
130
|
+
forwarded to a response's body. For example:
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
customer = token.get "/customers/aa76ca27-1920-4a0a-9bbe-a22085c0010e"
|
134
|
+
|
135
|
+
customer.collect {|k,v| k } # => [:_links, :id, ...]
|
136
|
+
customer.body.collect {|k,v| k } # => [:_links, :id, ...]
|
137
|
+
|
138
|
+
customer == customer.body # => true
|
139
|
+
|
140
|
+
customer[:name] # => John Doe
|
141
|
+
customer.body[:name] # => John Doe
|
115
142
|
```
|
116
143
|
|
117
144
|
#### Errors
|
@@ -165,6 +192,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
165
192
|
|
166
193
|
## Changelog
|
167
194
|
|
195
|
+
- **0.4.0** - Refactor and document how `DwollaV2::Response` works
|
168
196
|
- **0.3.1** - better `DwollaV2::Error` error messages
|
169
197
|
- **0.3.0** - ISO8601 values in response body are converted to `Time` objects
|
170
198
|
- **0.2.0** - Works with `attr_encrypted`
|
data/lib/dwolla_v2/response.rb
CHANGED
@@ -2,19 +2,23 @@ module DwollaV2
|
|
2
2
|
class Response
|
3
3
|
extend Forwardable
|
4
4
|
|
5
|
-
|
5
|
+
# http://ruby-doc.org/core-2.3.0/Enumerable.html
|
6
|
+
ENUMERABLE = \
|
7
|
+
[:all?, :any?, :chunk, :chunk_while, :collect, :collect_concat, :count, :cycle,
|
8
|
+
:detect, :drop, :drop_while, :each_cons, :each_entry, :each_slice, :each_with_index,
|
9
|
+
:each_with_object, :entries, :find, :find_all, :find_index, :first, :flat_map, :grep,
|
10
|
+
:grep_v, :group_by, :include?, :inject, :lazy, :map, :max, :max_by, :member?, :min,
|
11
|
+
:min_by, :minmax, :minmax_by, :none?, :one?, :partition, :reduce, :reject,
|
12
|
+
:reverse_each, :select, :slice_after, :slice_before, :slice_when, :sort, :sort_by,
|
13
|
+
:take, :take_while, :to_a, :to_h, :zip]
|
6
14
|
|
7
|
-
delegate
|
8
|
-
delegate [
|
15
|
+
delegate [:status, :headers, :body] => :@response
|
16
|
+
delegate [*ENUMERABLE, :==, :[]] => :response_body
|
9
17
|
|
10
18
|
def initialize response
|
11
19
|
@response = response
|
12
20
|
end
|
13
21
|
|
14
|
-
def method_missing method, *args, &block
|
15
|
-
response_body.send method, *args, &block
|
16
|
-
end
|
17
|
-
|
18
22
|
private
|
19
23
|
|
20
24
|
def response_body
|
data/lib/dwolla_v2/version.rb
CHANGED
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.
|
4
|
+
version: 0.4.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-03-
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|