transfeera-sdk 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ca4675fd569c13bf3c3e746370d3a52b2110495
4
- data.tar.gz: 4c85923c8c9b0f6620272c18429d9526c0081171
3
+ metadata.gz: 01a95be9de694997a98538d85244e003e31b823d
4
+ data.tar.gz: 97979f5b0c8f6c9459aa69498aa4ded029f4c0dc
5
5
  SHA512:
6
- metadata.gz: 63d339decac01fabbb3acd732c53f4d4bdb6f0dc15d8ce53070f53a87638bb664d6a9072357c4704369d72bb1f5ecb7e4f57f7202492acb5e7d4f6d59c1c3971
7
- data.tar.gz: bb8391c6f295455bb8228eaa3fe7ff0b6a2695f78193c7939aaedee3c520f490cb007ec634a7d41831576b805b443a5f78079ae4b72e7b9f90fd813ff5d8910c
6
+ metadata.gz: 4f1c8f6eb3928dab25709b5fc3def9e91b12ad9bf7e4a809758c3edef9303fc181b5edc489502049a5218e099a8feea3596106b92597e88022600f7a395a5c35
7
+ data.tar.gz: 50264492f7a2b45fc6e62f1f545b22d3946f5f4aee3f8c03a286a535ab8db338130efeb0174501fc664776ce4bdd1955cc8c93dfb4cb73bc8cd6ef1356a0c4c4
data/.rspec_status CHANGED
@@ -0,0 +1,3 @@
1
+ example_id | status | run_time |
2
+ ----------------------------------------- | ------ | --------------- |
3
+ ./spec/transfeera_sdk/bank_spec.rb[1:1:1] | passed | 0.00067 seconds |
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- transfeera-sdk (0.1.2)
4
+ transfeera-sdk (0.1.4)
5
5
  activesupport
6
6
  rest-client
7
7
 
@@ -64,7 +64,7 @@ GEM
64
64
  thread_safe (~> 0.1)
65
65
  unf (0.1.4)
66
66
  unf_ext
67
- unf_ext (0.0.7.4)
67
+ unf_ext (0.0.7.5)
68
68
  vcr (4.0.0)
69
69
  webmock (3.2.1)
70
70
  addressable (>= 2.3.6)
data/README.md CHANGED
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'transfeera'
12
+ gem 'transfeera-sdk'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -18,7 +18,7 @@ And then execute:
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install transfeera
21
+ $ gem install transfeera-sdk
22
22
 
23
23
  ## Usage
24
24
 
@@ -2,12 +2,43 @@ require 'transfeera_sdk/base'
2
2
 
3
3
  module TransfeeraSDK
4
4
  class Bank < TransfeeraSDK::Base
5
+ BANKS_LIST = [{ 'id' => 4, 'name' => 'Bradesco', 'code' => '237' },
6
+ { 'id' => 6, 'name' => 'Banco do Brasil', 'code' => '001' },
7
+ { 'id' => 3, 'name' => 'Caixa Econômica', 'code' => '104' },
8
+ { 'id' => 1, 'name' => 'Santander', 'code' => '033' },
9
+ { 'id' => 5, 'name' => 'Itaú', 'code' => '341' },
10
+ { 'id' => 26, 'name' => 'Banco Safra', 'code' => '422' },
11
+ { 'id' => 25, 'name' => 'Banco Inter', 'code' => '077' },
12
+ { 'id' => 24, 'name' => 'Banestes', 'code' => '021' },
13
+ { 'id' => 23, 'name' => 'Daycoval', 'code' => '707' },
14
+ { 'id' => 22, 'name' => 'Mercantil do Brasil', 'code' => '389' },
15
+ { 'id' => 21, 'name' => 'Agiplan', 'code' => '121' },
16
+ { 'id' => 20, 'name' => 'Banco do Nordeste', 'code' => '004' },
17
+ { 'id' => 19, 'name' => 'Unicred', 'code' => '136' },
18
+ { 'id' => 16, 'name' => 'Citibank', 'code' => '745' },
19
+ { 'id' => 15, 'name' => 'neon', 'code' => '735' },
20
+ { 'id' => 14, 'name' => 'Banco Sofisa', 'code' => '637' },
21
+ { 'id' => 13, 'name' => 'Nu Pagamentos S.A.', 'code' => '260' },
22
+ { 'id' => 12, 'name' => 'Original', 'code' => '212' },
23
+ { 'id' => 11, 'name' => 'Cooperativa Central de Crédito Urbano', 'code' => '085' },
24
+ { 'id' => 10, 'name' => 'Banco de Brasília - BRB', 'code' => '070' },
25
+ { 'id' => 9, 'name' => 'Banrisul', 'code' => '041' },
26
+ { 'id' => 8, 'name' => 'Sicredi', 'code' => '748' },
27
+ { 'id' => 7, 'name' => 'Sicoob', 'code' => '756' },
28
+ { 'id' => 27, 'name' => 'Banco Parana', 'code' => '254' },
29
+ { 'id' => 28, 'name' => 'Votorantin', 'code' => '655' }]
5
30
  def list
6
- send_request(:get, "/bank")
31
+ send_request(:get, '/bank')
7
32
  end
8
33
 
9
34
  def destination_bank_account
10
- send_request(:get, "destinationBankAccount")
35
+ send_request(:get, 'destinationBankAccount')
36
+ end
37
+
38
+ def bank_id_from_code(code)
39
+ BANKS_LIST.each { |bank| return bank['id'] if bank['code'] == code }
40
+
41
+ nil
11
42
  end
12
43
  end
13
44
  end
@@ -1,6 +1,7 @@
1
1
  require 'rest_client'
2
2
  require 'json'
3
3
  require 'addressable/uri'
4
+ require 'pry'
4
5
 
5
6
  module TransfeeraSDK
6
7
  class Base
@@ -1,8 +1,10 @@
1
1
  require 'transfeera_sdk/base'
2
+ require 'transfeera_sdk/bank'
2
3
 
3
4
  module TransfeeraSDK
4
5
  class Batch < TransfeeraSDK::Base
5
6
  def create!(opts = {})
7
+ update_bank_ids(opts)
6
8
  send_request(:post, "/batch", opts)
7
9
  end
8
10
 
@@ -25,5 +27,14 @@ module TransfeeraSDK
25
27
  def transfers(batch_id)
26
28
  send_request(:get, "/batch/#{batch_id}/transfer")
27
29
  end
30
+
31
+ private
32
+
33
+ def update_bank_ids(opts)
34
+ opts['transfers'].each do |transfer|
35
+ bank_code = transfer['destination_bank_account']['bank_id'].to_s.rjust(3, '0')
36
+ transfer['destination_bank_account']['bank_id'] = ::TransfeeraSDK::Bank.new.bank_id_from_code(bank_code)
37
+ end
38
+ end
28
39
  end
29
40
  end
@@ -1,3 +1,3 @@
1
1
  module TransfeeraSDK
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transfeera-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Oliveira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-06 00:00:00.000000000 Z
11
+ date: 2018-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  version: '0'
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.6.14
213
+ rubygems_version: 2.6.13
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: transfeera gem SDK.