myfinance 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +22 -0
- data/lib/myfinance/resources/financial_account.rb +17 -2
- data/lib/myfinance/version.rb +1 -1
- data/myfinance.gemspec +5 -4
- data/spec/lib/myfinance/resources/payable_account_spec.rb +21 -3
- data/spec/lib/myfinance/resources/receivable_account_spec.rb +21 -3
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a816590d9795f867bf791715ad87a56057513e6
|
4
|
+
data.tar.gz: 9ae9263ed7af1f079ca7483bd95a2351055cd8ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42164b2bd9722065052b6199cdde3d29adf4cc6a1e40f993491e8f9a4689c2f844768d40466c1ecb0c926f54a7cda35ecfdef1dd56e8a764fbebe50dcb70dfb1
|
7
|
+
data.tar.gz: 7cae9bd220cf606c5ba66bc48639ea58d35d5830c9d9803f3d604bdac957de9fd181d3b6738d8b283cc50606dc1bb19fed7cca91d32238cc51a69b7f1303ce0e
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
myfinance (0.
|
4
|
+
myfinance (0.2.0)
|
5
5
|
multi_json (~> 1.9.0)
|
6
6
|
typhoeus (~> 0.7.1)
|
7
7
|
virtus (~> 1.0.5)
|
@@ -62,7 +62,7 @@ GEM
|
|
62
62
|
simplecov-html (0.10.0)
|
63
63
|
slop (3.6.0)
|
64
64
|
thread_safe (0.3.5)
|
65
|
-
typhoeus (0.7.
|
65
|
+
typhoeus (0.7.3)
|
66
66
|
ethon (>= 0.7.4)
|
67
67
|
vcr (2.9.3)
|
68
68
|
virtus (1.0.5)
|
data/README.md
CHANGED
@@ -92,6 +92,17 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
|
|
92
92
|
<code>client.payable_accounts.create</code>
|
93
93
|
</td>
|
94
94
|
</tr>
|
95
|
+
<tr>
|
96
|
+
<td><code>PUT</code></td>
|
97
|
+
<td>
|
98
|
+
<a href="https://app.myfinance.com.br/docs/api/payable_accounts#put_update" target="_blank">
|
99
|
+
/entities/:entity_id/payable_accounts/:id
|
100
|
+
</a>
|
101
|
+
</td>
|
102
|
+
<td>
|
103
|
+
<code>client.payable_accounts.update</code>
|
104
|
+
</td>
|
105
|
+
</tr>
|
95
106
|
<tr>
|
96
107
|
<td><code>PUT</code></td>
|
97
108
|
<td>
|
@@ -146,6 +157,17 @@ client = Myfinance.client("YOUR_TOKEN_HERE")
|
|
146
157
|
<code>client.receivable_accounts.create</code>
|
147
158
|
</td>
|
148
159
|
</tr>
|
160
|
+
<tr>
|
161
|
+
<td><code>PUT</code></td>
|
162
|
+
<td>
|
163
|
+
<a href="https://app.myfinance.com.br/docs/api/receivable_accounts#put_update" target="_blank">
|
164
|
+
/entities/:entity_id/receivable_accounts/:id
|
165
|
+
</a>
|
166
|
+
</td>
|
167
|
+
<td>
|
168
|
+
<code>client.receivable_accounts.update</code>
|
169
|
+
</td>
|
170
|
+
</tr>
|
149
171
|
<tr>
|
150
172
|
<td><code>PUT</code></td>
|
151
173
|
<td>
|
@@ -21,6 +21,20 @@ module Myfinance
|
|
21
21
|
request_and_build_response(:post, endpoint_for(nil, entity_id, :create), params)
|
22
22
|
end
|
23
23
|
|
24
|
+
#
|
25
|
+
# Updates a payable/receivable account
|
26
|
+
#
|
27
|
+
# [API]
|
28
|
+
# Method: <tt>PUT /entities/:entity_id/payable_accounts/:id</tt>
|
29
|
+
# Method: <tt>PUT /entities/:entity_id/receivable_accounts/:id</tt>
|
30
|
+
#
|
31
|
+
# Documentation: https://app.myfinance.com.br/docs/api/payable_accounts#put_update
|
32
|
+
# Documentation: https://app.myfinance.com.br/docs/api/receivable_accounts#put_update
|
33
|
+
#
|
34
|
+
def update(id, entity_id, params = {})
|
35
|
+
request_and_build_response(:put, endpoint_for(id, entity_id, :update), params)
|
36
|
+
end
|
37
|
+
|
24
38
|
#
|
25
39
|
# Destroys a payable/receivable account
|
26
40
|
#
|
@@ -46,17 +60,18 @@ module Myfinance
|
|
46
60
|
end
|
47
61
|
|
48
62
|
def endpoint_for(id, entity_id, key)
|
49
|
-
|
63
|
+
parameterize_endpoint(id, entity_id, key)
|
50
64
|
end
|
51
65
|
|
52
66
|
def default_endpoints
|
53
67
|
{
|
54
68
|
create: "/entities/:entity_id/#{resource_key}s",
|
69
|
+
update: "/entities/:entity_id/#{resource_key}s/:id",
|
55
70
|
destroy: "/entities/:entity_id/#{resource_key}s/:id"
|
56
71
|
}
|
57
72
|
end
|
58
73
|
|
59
|
-
def
|
74
|
+
def parameterize_endpoint(id, entity_id, key)
|
60
75
|
endpoints[key.to_sym].gsub(':entity_id', entity_id.to_s).gsub(':id', id.to_s)
|
61
76
|
end
|
62
77
|
|
data/lib/myfinance/version.rb
CHANGED
data/myfinance.gemspec
CHANGED
@@ -4,10 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'myfinance/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
7
|
+
spec.name = "myfinance"
|
8
|
+
spec.version = Myfinance::VERSION
|
9
|
+
spec.authors = ["Eduardo Hertz", "Rafael B. Tauil", "Rodrigo Tassinari"]
|
10
|
+
spec.email = ["eduardohertz@gmail.com", "rafael@tauil.com.br", "rodrigo@pittlandia.net"]
|
11
|
+
spec.required_ruby_version = '>= 2.0.0'
|
11
12
|
|
12
13
|
spec.summary = %q{A Ruby client for the Myfinance REST API}
|
13
14
|
spec.description = %q{A Ruby client for the Myfinance REST API: https://app.myfinance.com.br/docs/api}
|
@@ -9,7 +9,7 @@ describe Myfinance::Resources::PayableAccount do
|
|
9
9
|
|
10
10
|
context "with success" do
|
11
11
|
it "creates a new object" do
|
12
|
-
expect(subject.id).to eq(
|
12
|
+
expect(subject.id).to eq(1235050)
|
13
13
|
expect(subject.due_date).to eq(Date.new(2015, 8, 15))
|
14
14
|
expect(subject.entity_id).to eq(entity_id)
|
15
15
|
expect(subject.status).to eq(1)
|
@@ -32,8 +32,8 @@ describe Myfinance::Resources::PayableAccount do
|
|
32
32
|
expect(subject.expected_deposit_account_id).to be_nil
|
33
33
|
expect(subject.recurrence_id).to be_nil
|
34
34
|
expect(subject.person_id).to be_nil
|
35
|
-
expect(subject.created_at).to eq(DateTime.parse("2015-08-
|
36
|
-
expect(subject.updated_at).to eq(DateTime.parse("2015-08-
|
35
|
+
expect(subject.created_at).to eq(DateTime.parse("2015-08-13T16:24:47-03:00"))
|
36
|
+
expect(subject.updated_at).to eq(DateTime.parse("2015-08-13T16:24:47-03:00"))
|
37
37
|
expect(subject.recurrent).to be_falsy
|
38
38
|
expect(subject.parcelled).to be_falsy
|
39
39
|
expect(subject.recurrence_period).to be_nil
|
@@ -126,6 +126,24 @@ describe Myfinance::Resources::PayableAccount do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
describe "#update", vcr: true do
|
130
|
+
subject { client.payable_accounts.update(1235050, entity_id, { amount: 100.00 }) }
|
131
|
+
|
132
|
+
context "when payable account exists" do
|
133
|
+
it "returns true" do
|
134
|
+
expect(subject).to be_truthy
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "when payable account does not exist" do
|
139
|
+
subject { client.payable_accounts.update(9999999, entity_id, { amount: 100.00 }) }
|
140
|
+
|
141
|
+
it "raises request error" do
|
142
|
+
expect { subject }.to raise_error(Myfinance::RequestError)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
129
147
|
describe "#destroy", vcr: true do
|
130
148
|
subject { client.payable_accounts.destroy(1215631, entity_id) }
|
131
149
|
|
@@ -9,7 +9,7 @@ describe Myfinance::Resources::ReceivableAccount do
|
|
9
9
|
|
10
10
|
context "with success" do
|
11
11
|
it "creates a new object" do
|
12
|
-
expect(subject.id).to eq(
|
12
|
+
expect(subject.id).to eq(1235051)
|
13
13
|
expect(subject.due_date).to eq(Date.new(2015, 8, 15))
|
14
14
|
expect(subject.entity_id).to eq(entity_id)
|
15
15
|
expect(subject.status).to eq(1)
|
@@ -32,8 +32,8 @@ describe Myfinance::Resources::ReceivableAccount do
|
|
32
32
|
expect(subject.expected_deposit_account_id).to be_nil
|
33
33
|
expect(subject.recurrence_id).to be_nil
|
34
34
|
expect(subject.person_id).to be_nil
|
35
|
-
expect(subject.created_at).to eq(DateTime.parse("2015-08-
|
36
|
-
expect(subject.updated_at).to eq(DateTime.parse("2015-08-
|
35
|
+
expect(subject.created_at).to eq(DateTime.parse("2015-08-13T16:29:06-03:00"))
|
36
|
+
expect(subject.updated_at).to eq(DateTime.parse("2015-08-13T16:29:06-03:00"))
|
37
37
|
expect(subject.recurrent).to be_falsy
|
38
38
|
expect(subject.parcelled).to be_falsy
|
39
39
|
expect(subject.recurrence_period).to be_nil
|
@@ -126,6 +126,24 @@ describe Myfinance::Resources::ReceivableAccount do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
describe "#update", vcr: true do
|
130
|
+
subject { client.receivable_accounts.update(1235051, entity_id, { amount: 100.00 }) }
|
131
|
+
|
132
|
+
context "when payable account exists" do
|
133
|
+
it "returns true" do
|
134
|
+
expect(subject).to be_truthy
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "when payable account does not exist" do
|
139
|
+
subject { client.receivable_accounts.update(9999999, entity_id, { amount: 100.00 }) }
|
140
|
+
|
141
|
+
it "raises request error" do
|
142
|
+
expect { subject }.to raise_error(Myfinance::RequestError)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
129
147
|
describe "#destroy", vcr: true do
|
130
148
|
subject { client.receivable_accounts.destroy(1215634, entity_id) }
|
131
149
|
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myfinance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Hertz
|
8
|
+
- Rafael B. Tauil
|
8
9
|
- Rodrigo Tassinari
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2015-08-
|
13
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: typhoeus
|
@@ -196,6 +197,7 @@ dependencies:
|
|
196
197
|
description: 'A Ruby client for the Myfinance REST API: https://app.myfinance.com.br/docs/api'
|
197
198
|
email:
|
198
199
|
- eduardohertz@gmail.com
|
200
|
+
- rafael@tauil.com.br
|
199
201
|
- rodrigo@pittlandia.net
|
200
202
|
executables:
|
201
203
|
- console
|
@@ -270,7 +272,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
270
272
|
requirements:
|
271
273
|
- - ">="
|
272
274
|
- !ruby/object:Gem::Version
|
273
|
-
version:
|
275
|
+
version: 2.0.0
|
274
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
275
277
|
requirements:
|
276
278
|
- - ">="
|