inter_api 1.0.2 → 1.0.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
  SHA256:
3
- metadata.gz: 36661dd5aa68653e29608d07616fd26e0726640409f2188efaf99b8e3a44dcf4
4
- data.tar.gz: 94eb00f18a9a1191014047249ca1050ce720dde93f0836965ab078abb6800ad5
3
+ metadata.gz: 4c3042c874a5bb6e237e50f28313606d6787ef9932c8349037572b0ef1c03626
4
+ data.tar.gz: 58cebe033804f8283ab775a2d5124f55fc519e67d5ba9683dd818874ff4fcb9e
5
5
  SHA512:
6
- metadata.gz: 6a46510c801ffcba0d75ef5ca8bbea8d9b7d492b76957516a528dd8032b93d6440ebb8a6ee59ad629654991d7c14c0a0aecfb109148b6dbe76d67bbeedc10fd8
7
- data.tar.gz: c2edb6b9c990e8161d0d4e52137da8585cd615ed1e69ba92d89e25a66f9c7ee1aea94a9cea0c1cbaea0366533bd45c7bb2b972e65003f70e8638bfb2f075ec0e
6
+ metadata.gz: 2de68302e396fbe38715b0785d361152eed465d9ebaf966b49b8b6692acaee9460e0c83e50ee02530021aa28e4495ea1e0810b1f2a101334d9d24b54443b7cde
7
+ data.tar.gz: 189544647729a28b271cc9c1d2db598b5940b5867c3bacf160b30bd560e0ac48849ee8ac3f5dd17690015ca55224576b7419b278f4a5dbce3c3875960820edd9
data/README.md CHANGED
@@ -1,19 +1,72 @@
1
1
  # InterApi
2
2
 
3
- ## Installation
3
+ Wrapper de integração com a API v2 do Banco Inter.
4
4
 
5
- Add inter_api to your Gemfile:
5
+ ### Funcionalidades:
6
+ - Autenticação
7
+ - Pagamento Pix: get, create, update, refund
8
+
9
+ ## Instalação
10
+
11
+ Adicionar inter_api no Gemfile:
6
12
 
7
13
  ```ruby
8
14
  gem 'inter_api'
9
15
  ```
16
+ ou
17
+ ```shell
18
+ bundle add inter_api
19
+ ```
10
20
 
11
- Bundle your dependencies and run the installation generator:
21
+ Instalar a gem:
12
22
 
13
23
  ```shell
14
24
  bin/rails generate inter_api:install
15
25
  ```
16
26
 
17
- ## License
27
+ ## Uso
28
+
29
+ ### Exemplo
30
+ #### Criar Pagamento PIX
31
+ ```ruby
32
+ # Instanciar o API client
33
+ api_client = InterApi::Client.new(crt: "./certificado_api_inter.crt", key: "./chave_api_inter.key", client_id: "123456", client_secret: "abcde", chave_pix: "1011121314", conta_corrente: "9876", scopes: "cobv.write cobv.read cob.write cob.read pix.write pix.read")
34
+ # Ao instanciar o objeto, cria um access_token e/ou valida a partir da data de expiração
35
+
36
+ # Criar um pagamento
37
+ payment = api_client.create_payment(amount: 50.00, payer_tax_id: "123.123.123-01", payer_name: "João da Silva", expiration: 3600, solicitacao_pagador: "Compra de produto", info_adicionais: [ nome: "Produto", valor: "Produto 1"])
38
+ # retorna um objeto <InterApi::Payment>
39
+ puts payment.txid # "123123"
40
+ puts payment.status # "ATIVA"
41
+
42
+ # Obter um pagamento a partir do id
43
+ payment = api_client.get_payment(payment.txid)
44
+ # retorna um objeto <InterApi::Payment>
45
+ puts payment.txid # "123123"
46
+ puts payment.status # "ATIVA"
47
+
48
+ # Atualizar um pagamento
49
+ body = { status: "REMOVIDA_PELO_USUARIO_RECEBEDOR" }
50
+ api_client.update(payment.txid, body)
51
+ # retorna o objeto <InterApi::Payment> atualizado
52
+ puts payment.status # "REMOVIDA_PELO_USUARIO_RECEBEDOR"
53
+
54
+ ```
55
+
56
+ #### Métodos do Pagamento
57
+ ```ruby
58
+ payment.valid? # true ou false
59
+
60
+ payment.paid? # true ou false
61
+
62
+ payment.qr_code # retorna o source do SVG
63
+
64
+ payment.reload! # retorna payment atualizado
65
+
66
+ payment.invalidate! # invalida e retorna o payment atualizado
18
67
 
19
- Copyright (c) 2023 ulysses-bull, released under the New BSD License.
68
+ # Reebolso de pagamento
69
+ reembolso = payment.refund(amount: 50.00, refund_nature: "ORIGINAL", description: "Reembolso")
70
+ # retorna o JSON da resposta
71
+ reembolso["status"] # "EM_PROCESSAMENTO"
72
+ ```
@@ -1,5 +1,5 @@
1
1
  module InterApi
2
- class Client < Ac::Base
2
+ class ClientProduction < Ac::Base
3
3
  BASE_URL = "https://cdpj.partners.bancointer.com.br/"
4
4
  MAX_RETIES = 2
5
5
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InterApi
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.4"
5
5
  end
data/lib/inter_api.rb CHANGED
@@ -7,11 +7,24 @@ require "rqrcode"
7
7
  require "ac"
8
8
 
9
9
  require_relative "inter_api/version"
10
- require "inter_api/client"
10
+ require "inter_api/client_production"
11
11
  require "inter_api/payment"
12
12
  require "inter_api/payment_error"
13
13
 
14
14
  module InterApi
15
15
  class Error < StandardError; end
16
- # Your code goes here...
16
+
17
+ class ClientTeste < ClientProduction
18
+ BASE_URL = "https://cdpj-sandbox.partners.uatinter.co/"
19
+ end
20
+
21
+ class Client
22
+ def self.new **args
23
+ if args.delete(:test_mode)
24
+ ClientTeste.new(**args)
25
+ else
26
+ ClientProduction.new(**args)
27
+ end
28
+ end
29
+ end
17
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inter_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
- - ulysses
7
+ - Todas Essas Coisas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-03 00:00:00.000000000 Z
11
+ date: 2024-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ac
@@ -80,18 +80,18 @@ files:
80
80
  - README.md
81
81
  - Rakefile
82
82
  - lib/inter_api.rb
83
- - lib/inter_api/client.rb
83
+ - lib/inter_api/client_production.rb
84
84
  - lib/inter_api/payment.rb
85
85
  - lib/inter_api/payment_error.rb
86
86
  - lib/inter_api/version.rb
87
87
  - sig/inter_api.rbs
88
- homepage: https://github.com/ulysses-bull/inter_api
88
+ homepage: https://github.com/todasessascoisas/inter_api
89
89
  licenses:
90
90
  - MIT
91
91
  metadata:
92
- homepage_uri: https://github.com/ulysses-bull/inter_api
93
- source_code_uri: https://github.com/ulysses-bull/inter_api
94
- changelog_uri: https://github.com/ulysses-bull/inter_api
92
+ homepage_uri: https://github.com/todasessascoisas/inter_api
93
+ source_code_uri: https://github.com/todasessascoisas/inter_api
94
+ changelog_uri: https://github.com/todasessascoisas/inter_api
95
95
  post_install_message:
96
96
  rdoc_options: []
97
97
  require_paths:
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubygems_version: 3.5.10
110
+ rubygems_version: 3.5.16
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: ''