myfinance-rails 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/myfinance/pessoa.rb +5 -3
- data/lib/myfinance/version.rb +1 -1
- data/lib/myfinance.rb +6 -1
- data/spec/features/account_spec.rb +1 -0
- data/spec/features/pessoas_spec.rb +6 -0
- 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: a0f59499d90cce22f325cc04a837d25136d8f8d3
|
4
|
+
data.tar.gz: 5a91d6b5df49116aa8a82e2aa3334b0771d77fad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7030f422c12323e13e256c8a537bd57cd846172dfcedfe69dc42ad3da55d9300e02baeb72b67da6c448af095c85419af65cd0125db3ffb619585d5bfd784a3e1
|
7
|
+
data.tar.gz: fb7b7c57de0f7a7d36f039f98709fc3bb7bb2c4d12bf9b84f730730bae54238ddb5e78bc5e6f85986c54653d298e3a806ec59ce777fa20cf89907a65b0128391
|
data/lib/myfinance/pessoa.rb
CHANGED
@@ -4,9 +4,11 @@ module Myfinance
|
|
4
4
|
@everyone ||= all_people
|
5
5
|
mid = nil
|
6
6
|
@everyone.each do | pessoa |
|
7
|
-
if
|
8
|
-
|
9
|
-
|
7
|
+
if @account_id == pessoa['account_id']
|
8
|
+
if pessoa['federation_subscription_number_only_numbers'] == cnpj_ou_nome or pessoa['federation_subscription_number'] == cnpj_ou_nome or pessoa['name'].casecmp(cnpj_ou_nome) == 0
|
9
|
+
mid = pessoa['id']
|
10
|
+
break
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
mid
|
data/lib/myfinance/version.rb
CHANGED
data/lib/myfinance.rb
CHANGED
@@ -25,13 +25,13 @@ module Myfinance
|
|
25
25
|
end
|
26
26
|
base_uri @endpoint
|
27
27
|
@token = token
|
28
|
-
@account_id = account_id
|
29
28
|
# testo com uma chamada simples
|
30
29
|
response = accounts
|
31
30
|
# Resposta deve ser um array de hashes
|
32
31
|
unless response.code == 200
|
33
32
|
raise "Erro ao inicializar a API do MyFinance: #{response.code} : #{response.parsed_response}"
|
34
33
|
end
|
34
|
+
@account_id = get_account_id(account_id, response)
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
@@ -84,5 +84,10 @@ module Myfinance
|
|
84
84
|
def self.add_account_id(options)
|
85
85
|
options[:headers]['ACCOUNT_ID'] = @account_id.to_s if @account_id
|
86
86
|
end
|
87
|
+
|
88
|
+
def self.get_account_id(account_id, accounts_response)
|
89
|
+
return account_id unless account_id.nil?
|
90
|
+
accounts_response.first["account"]["id"]
|
91
|
+
end
|
87
92
|
end
|
88
93
|
|
@@ -31,6 +31,7 @@ describe 'Account', type: :feature do
|
|
31
31
|
describe "not informed" do
|
32
32
|
before do
|
33
33
|
expect(Myfinance).to receive(:accounts).and_return response_double
|
34
|
+
expect(Myfinance).to receive(:get_account_id).and_return nil
|
34
35
|
Myfinance.setup "123456", false
|
35
36
|
end
|
36
37
|
it "get" do
|
@@ -66,4 +66,10 @@ describe 'Manipulando Pessoas', type: :feature do
|
|
66
66
|
id = Myfinance.pessoa_id('Ciclano Ciclano')
|
67
67
|
expect(id).to be_nil
|
68
68
|
end
|
69
|
+
|
70
|
+
it 'Se procurar por um cnpj cadastrado de outra conta, não deve voltar id' do
|
71
|
+
Myfinance.setup('2acecbb483842ebbfb2c638070bf019b70e757190166d277', false, 1)
|
72
|
+
id = Myfinance.pessoa_id('27206831000170')
|
73
|
+
expect(id).to be_nil
|
74
|
+
end
|
69
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myfinance-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Lopes Neto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|