bs2_api 0.4.0 → 1.0.3
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/CHANGELOG.md +15 -5
 - data/Gemfile.lock +4 -4
 - data/README.md +4 -4
 - data/lib/bs2_api/entities/customer.rb +14 -0
 - data/lib/bs2_api/entities/payment.rb +13 -13
 - data/lib/bs2_api/payment/base.rb +4 -4
 - data/lib/bs2_api/payment/confirmation.rb +1 -1
 - data/lib/bs2_api/util/bank_service.rb +3 -4
 - data/lib/bs2_api/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 1121a339962d5ccf01e2e82d2cac9c26326b0cb5f07bb58af18cd2aaf8502009
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5ca659be8a6422c8c620b4304769822bd78d64835a6ed6f8e2b4612f0e3cea07
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2ba02bb1b9d40ea4e78d087a4cf3e89fa698adce23b1c7d50eedc4fe05808a548f7cbcb15ea98a321515b0b7faeabaf10cdccb5a80b35295cc9926758c3b26a8
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 864734c20782307fe3d2ba4cb86dd78ee1de72f84681a3019b9a6c48b504eae9aef08aecbb66541515b80791d9abcbb39a594d0aefb6427d5c71cdd5916376bd
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,16 +1,26 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ## [0.3 
     | 
| 
      
 1 
     | 
    
         
            +
            ## [1.0.3] - 2021-07-23
         
     | 
| 
      
 2 
     | 
    
         
            +
            - First and Last name methods to customer
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            ## [1.0.1] - 2021-06-25
         
     | 
| 
      
 5 
     | 
    
         
            +
            - Adjust HTTP response code when create payments into BS2
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## [1.0.0] - 2021-06-18
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Changed payment.id to payment.payment_id
         
     | 
| 
      
 9 
     | 
    
         
            +
            - Changed payment.merchant_id to payment.end_to_end_id
         
     | 
| 
       2 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
            ## [0.4.0] - 2021-06-17
         
     | 
| 
      
 12 
     | 
    
         
            +
            - Configuration#valid? missing return true
         
     | 
| 
      
 13 
     | 
    
         
            +
            - Created Util::Response.parse_error
         
     | 
| 
      
 14 
     | 
    
         
            +
            - Bs2Api::Payment::Confirmation#success? was private, moved it to public
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            ## [0.3.1] - 2021-06-16
         
     | 
| 
       3 
17 
     | 
    
         
             
            - Method Hash#to_query conflicting with Rails
         
     | 
| 
       4 
18 
     | 
    
         | 
| 
       5 
19 
     | 
    
         
             
            ## [0.3.0] - 2021-06-16
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
20 
     | 
    
         
             
            - Confirmation, Adjust README.md
         
     | 
| 
       8 
21 
     | 
    
         | 
| 
       9 
22 
     | 
    
         
             
            ## [0.2.0] - 2021-06-15
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
23 
     | 
    
         
             
            - Entities, Auth, Create Pix Key Payment
         
     | 
| 
       12 
24 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
25 
     | 
    
         
             
            ## [0.1.0] - 2021-06-11
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
26 
     | 
    
         
             
            - Initial release
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                bs2_api (0. 
     | 
| 
      
 4 
     | 
    
         
            +
                bs2_api (1.0.2)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  activesupport
         
     | 
| 
       6 
6 
     | 
    
         
             
                  builder
         
     | 
| 
       7 
7 
     | 
    
         
             
                  bundler
         
     | 
| 
         @@ -11,7 +11,7 @@ PATH 
     | 
|
| 
       11 
11 
     | 
    
         
             
            GEM
         
     | 
| 
       12 
12 
     | 
    
         
             
              remote: https://rubygems.org/
         
     | 
| 
       13 
13 
     | 
    
         
             
              specs:
         
     | 
| 
       14 
     | 
    
         
            -
                activesupport (6.1. 
     | 
| 
      
 14 
     | 
    
         
            +
                activesupport (6.1.4)
         
     | 
| 
       15 
15 
     | 
    
         
             
                  concurrent-ruby (~> 1.0, >= 1.0.2)
         
     | 
| 
       16 
16 
     | 
    
         
             
                  i18n (>= 1.6, < 2)
         
     | 
| 
       17 
17 
     | 
    
         
             
                  minitest (>= 5.1)
         
     | 
| 
         @@ -38,7 +38,7 @@ GEM 
     | 
|
| 
       38 
38 
     | 
    
         
             
                method_source (1.0.0)
         
     | 
| 
       39 
39 
     | 
    
         
             
                mime-types (3.3.1)
         
     | 
| 
       40 
40 
     | 
    
         
             
                  mime-types-data (~> 3.2015)
         
     | 
| 
       41 
     | 
    
         
            -
                mime-types-data (3.2021. 
     | 
| 
      
 41 
     | 
    
         
            +
                mime-types-data (3.2021.0704)
         
     | 
| 
       42 
42 
     | 
    
         
             
                minitest (5.14.4)
         
     | 
| 
       43 
43 
     | 
    
         
             
                multi_xml (0.6.0)
         
     | 
| 
       44 
44 
     | 
    
         
             
                pry (0.13.1)
         
     | 
| 
         @@ -48,7 +48,7 @@ GEM 
     | 
|
| 
       48 
48 
     | 
    
         
             
                  byebug (~> 11.0)
         
     | 
| 
       49 
49 
     | 
    
         
             
                  pry (~> 0.13.0)
         
     | 
| 
       50 
50 
     | 
    
         
             
                public_suffix (4.0.6)
         
     | 
| 
       51 
     | 
    
         
            -
                rake (13.0. 
     | 
| 
      
 51 
     | 
    
         
            +
                rake (13.0.4)
         
     | 
| 
       52 
52 
     | 
    
         
             
                rexml (3.2.5)
         
     | 
| 
       53 
53 
     | 
    
         
             
                rspec (3.10.0)
         
     | 
| 
       54 
54 
     | 
    
         
             
                  rspec-core (~> 3.10.0)
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -66,10 +66,10 @@ pix_key = Bs2Api::Entities::PixKey.new( 
     | 
|
| 
       66 
66 
     | 
    
         
             
            # Veja abaixo (Classes de errors) quais erros que podem ser lançados
         
     | 
| 
       67 
67 
     | 
    
         
             
            pay_key = Bs2Api::Payment::Key.new(pix_key).call
         
     | 
| 
       68 
68 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
            pay_key.payment. 
     | 
| 
      
 69 
     | 
    
         
            +
            pay_key.payment.payment_idid
         
     | 
| 
       70 
70 
     | 
    
         
             
            => "96f0b3c4-4c76-4a7a-9933-9c9f86df7490" # pagamentoId gerado no BS2
         
     | 
| 
       71 
71 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
            pay_key.payment. 
     | 
| 
      
 72 
     | 
    
         
            +
            pay_key.payment.end_to_end_id
         
     | 
| 
       73 
73 
     | 
    
         
             
            => "E710278662021061618144401750781P" # endToEndId gerado no BS2
         
     | 
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
            ```
         
     | 
| 
         @@ -98,10 +98,10 @@ receiver_bank = Bs2Api::Entities::Bank.new( 
     | 
|
| 
       98 
98 
     | 
    
         | 
| 
       99 
99 
     | 
    
         
             
            pay_manual = Bs2Api::Payment::Manual.new(receiver_bank).call
         
     | 
| 
       100 
100 
     | 
    
         | 
| 
       101 
     | 
    
         
            -
            pay_manual.payment. 
     | 
| 
      
 101 
     | 
    
         
            +
            pay_manual.payment.payment_id
         
     | 
| 
       102 
102 
     | 
    
         
             
            => "96f0b3c4-4c76-4a7a-9933-9c9f86df7490" # UUID gerado no BS2
         
     | 
| 
       103 
103 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
            pay_manual.payment. 
     | 
| 
      
 104 
     | 
    
         
            +
            pay_manual.payment.end_to_end_id
         
     | 
| 
       105 
105 
     | 
    
         
             
            => "E710278662021061618144401750781P" # endToEndId gerado no BS2
         
     | 
| 
       106 
106 
     | 
    
         
             
            ```
         
     | 
| 
       107 
107 
     | 
    
         | 
| 
         @@ -46,6 +46,20 @@ module Bs2Api 
     | 
|
| 
       46 
46 
     | 
    
         
             
                  def business?
         
     | 
| 
       47 
47 
     | 
    
         
             
                    @type == TYPES[:business]
         
     | 
| 
       48 
48 
     | 
    
         
             
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  def first_name
         
     | 
| 
      
 51 
     | 
    
         
            +
                    split_name.first
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
                  
         
     | 
| 
      
 54 
     | 
    
         
            +
                  def last_name
         
     | 
| 
      
 55 
     | 
    
         
            +
                    return '' if split_name.size <= 1
         
     | 
| 
      
 56 
     | 
    
         
            +
                    split_name.last
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  private
         
     | 
| 
      
 60 
     | 
    
         
            +
                    def split_name
         
     | 
| 
      
 61 
     | 
    
         
            +
                      @split_name ||= @name.split(' ')
         
     | 
| 
      
 62 
     | 
    
         
            +
                    end
         
     | 
| 
       49 
63 
     | 
    
         
             
                end
         
     | 
| 
       50 
64 
     | 
    
         
             
              end
         
     | 
| 
       51 
65 
     | 
    
         
             
            end
         
     | 
| 
         @@ -3,22 +3,22 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module Bs2Api
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Entities
         
     | 
| 
       5 
5 
     | 
    
         
             
                class Payment
         
     | 
| 
       6 
     | 
    
         
            -
                  attr_accessor : 
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_accessor :payment_id, :end_to_end_id, :receiver, :payer
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  def initialize(args = {})
         
     | 
| 
       9 
     | 
    
         
            -
                    @ 
     | 
| 
       10 
     | 
    
         
            -
                    @ 
     | 
| 
       11 
     | 
    
         
            -
                    @receiver 
     | 
| 
       12 
     | 
    
         
            -
                    @payer 
     | 
| 
      
 9 
     | 
    
         
            +
                    @payment_id    = args.fetch(:payment_id, nil)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @end_to_end_id = args.fetch(:end_to_end_id, nil)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @receiver      = args.fetch(:receiver, nil)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @payer         = args.fetch(:payer, nil)
         
     | 
| 
       13 
13 
     | 
    
         
             
                  end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                  def to_hash
         
     | 
| 
       16 
16 
     | 
    
         
             
                    ActiveSupport::HashWithIndifferentAccess.new(
         
     | 
| 
       17 
17 
     | 
    
         
             
                      {
         
     | 
| 
       18 
     | 
    
         
            -
                        "pagamentoId": @ 
     | 
| 
       19 
     | 
    
         
            -
                        "endToEndId": 
     | 
| 
       20 
     | 
    
         
            -
                        "recebedor": 
     | 
| 
       21 
     | 
    
         
            -
                        "pagador": 
     | 
| 
      
 18 
     | 
    
         
            +
                        "pagamentoId": @payment_id,
         
     | 
| 
      
 19 
     | 
    
         
            +
                        "endToEndId":  @end_to_end_id,
         
     | 
| 
      
 20 
     | 
    
         
            +
                        "recebedor":   @receiver.to_hash,
         
     | 
| 
      
 21 
     | 
    
         
            +
                        "pagador":     @payer.to_hash
         
     | 
| 
       22 
22 
     | 
    
         
             
                      }
         
     | 
| 
       23 
23 
     | 
    
         
             
                    )
         
     | 
| 
       24 
24 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -27,10 +27,10 @@ module Bs2Api 
     | 
|
| 
       27 
27 
     | 
    
         
             
                    hash = ActiveSupport::HashWithIndifferentAccess.new(hash_payload)
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                    Bs2Api::Entities::Payment.new(
         
     | 
| 
       30 
     | 
    
         
            -
                       
     | 
| 
       31 
     | 
    
         
            -
                       
     | 
| 
       32 
     | 
    
         
            -
                      receiver: 
     | 
| 
       33 
     | 
    
         
            -
                      payer: 
     | 
| 
      
 30 
     | 
    
         
            +
                      payment_id:    hash["pagamentoId"],
         
     | 
| 
      
 31 
     | 
    
         
            +
                      end_to_end_id: hash["endToEndId"],
         
     | 
| 
      
 32 
     | 
    
         
            +
                      receiver:      Bs2Api::Entities::Bank.from_response(hash["recebedor"]),
         
     | 
| 
      
 33 
     | 
    
         
            +
                      payer:         Bs2Api::Entities::Bank.from_response(hash["pagador"])
         
     | 
| 
       34 
34 
     | 
    
         
             
                    )
         
     | 
| 
       35 
35 
     | 
    
         
             
                  end
         
     | 
| 
       36 
36 
     | 
    
         
             
                end
         
     | 
    
        data/lib/bs2_api/payment/base.rb
    CHANGED
    
    | 
         @@ -9,8 +9,8 @@ module Bs2Api 
     | 
|
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                  def call
         
     | 
| 
       11 
11 
     | 
    
         
             
                    response = post_request
         
     | 
| 
       12 
     | 
    
         
            -
                    raise Bs2Api::Errors::BadRequest, ::Util::Response.parse_error(response) unless response. 
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
                    raise Bs2Api::Errors::BadRequest, ::Util::Response.parse_error(response) unless response.ok?
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       14 
14 
     | 
    
         
             
                    @payment = Bs2Api::Entities::Payment.from_response(response)
         
     | 
| 
       15 
15 
     | 
    
         
             
                    self
         
     | 
| 
       16 
16 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -35,10 +35,10 @@ module Bs2Api 
     | 
|
| 
       35 
35 
     | 
    
         
             
                    def payload
         
     | 
| 
       36 
36 
     | 
    
         
             
                      raise NoMethodError, "Missing #{__method__} to #{self.class}"
         
     | 
| 
       37 
37 
     | 
    
         
             
                    end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       39 
39 
     | 
    
         
             
                    def url
         
     | 
| 
       40 
40 
     | 
    
         
             
                      raise NoMethodError, "Missing #{__method__} to #{self.class}"
         
     | 
| 
       41 
41 
     | 
    
         
             
                    end
         
     | 
| 
       42 
42 
     | 
    
         
             
                end
         
     | 
| 
       43 
43 
     | 
    
         
             
              end
         
     | 
| 
       44 
     | 
    
         
            -
            end
         
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/bs2_api/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: bs2_api
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Kim Pastro
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2021- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-07-23 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: builder
         
     |