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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e00122261c7f101e2aa06cd712a97dffc16c9217efff07c83eab99cff74110fe
4
- data.tar.gz: fbbaae2c421c022b774601e94e10cc25cc2324770e7db7621c5bd6e173184e63
3
+ metadata.gz: 1121a339962d5ccf01e2e82d2cac9c26326b0cb5f07bb58af18cd2aaf8502009
4
+ data.tar.gz: 5ca659be8a6422c8c620b4304769822bd78d64835a6ed6f8e2b4612f0e3cea07
5
5
  SHA512:
6
- metadata.gz: 1c146dc459d908d337fd1920522d70498a985f5fac4a64f2daecc491b43436dbe462564a66d91467f90420edb0f2ed3390e88c9dd7af74d910d6cffe12ed7111
7
- data.tar.gz: f4a492028c841aca65b635d6a12ba2dd9500b656fd3eae6dd7df88d0480b3104c5640ae5eb3bc8647ff453b18a04018e3bdae85e6afa917932ec5c57c6771795
6
+ metadata.gz: 2ba02bb1b9d40ea4e78d087a4cf3e89fa698adce23b1c7d50eedc4fe05808a548f7cbcb15ea98a321515b0b7faeabaf10cdccb5a80b35295cc9926758c3b26a8
7
+ data.tar.gz: 864734c20782307fe3d2ba4cb86dd78ee1de72f84681a3019b9a6c48b504eae9aef08aecbb66541515b80791d9abcbb39a594d0aefb6427d5c71cdd5916376bd
data/CHANGELOG.md CHANGED
@@ -1,16 +1,26 @@
1
- ## [0.3.1] - 2021-06-16
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.3.4)
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.3.2)
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.0225)
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.3)
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.id
69
+ pay_key.payment.payment_idid
70
70
  => "96f0b3c4-4c76-4a7a-9933-9c9f86df7490" # pagamentoId gerado no BS2
71
71
 
72
- pay_key.payment.merchant_id
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.id
101
+ pay_manual.payment.payment_id
102
102
  => "96f0b3c4-4c76-4a7a-9933-9c9f86df7490" # UUID gerado no BS2
103
103
 
104
- pay_manual.payment.merchantId
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 :id, :merchant_id, :receiver, :payer
6
+ attr_accessor :payment_id, :end_to_end_id, :receiver, :payer
7
7
 
8
8
  def initialize(args = {})
9
- @id = args.fetch(:id, nil)
10
- @merchant_id = args.fetch(:merchant_id, nil)
11
- @receiver = args.fetch(:receiver, nil)
12
- @payer = args.fetch(:payer, nil)
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": @id,
19
- "endToEndId": @merchant_id,
20
- "recebedor": @receiver.to_hash,
21
- "pagador": @payer.to_hash
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
- id: hash["pagamentoId"],
31
- merchant_id: hash["endToEndId"],
32
- receiver: Bs2Api::Entities::Bank.from_response(hash["recebedor"]),
33
- payer: Bs2Api::Entities::Bank.from_response(hash["pagador"])
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
@@ -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.created?
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
@@ -31,7 +31,7 @@ module Bs2Api
31
31
  end
32
32
 
33
33
  def url
34
- "#{Bs2Api.endpoint}/pix/direto/forintegration/v1/pagamentos/#{@payment.id}/confirmacao"
34
+ "#{Bs2Api.endpoint}/pix/direto/forintegration/v1/pagamentos/#{@payment.payment_id}/confirmacao"
35
35
  end
36
36
  end
37
37
  end
@@ -12,10 +12,9 @@ module Bs2Api
12
12
  bank
13
13
  end
14
14
 
15
- private
16
- def bank_list
17
- @bank_list ||= YAML.load_file(File.join(__dir__, 'banks.yml'))
18
- end
15
+ def bank_list
16
+ @bank_list ||= YAML.load_file(File.join(__dir__, 'banks.yml'))
17
+ end
19
18
  end
20
19
  end
21
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bs2Api
4
- VERSION = "0.4.0"
4
+ VERSION = "1.0.3"
5
5
  end
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.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-06-17 00:00:00.000000000 Z
11
+ date: 2021-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder