bs2 0.2.0 → 0.3.1

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: fc1fec8361a5732235cdb719ec75fb26e3c5a95bc3bd464d71832a0340019974
4
- data.tar.gz: 41916656e628d6fe2bc8e261aa5829ea91a91a95ce1bf01c81de2670dd31e02d
3
+ metadata.gz: c1925382d1b8d399385004e1000d3cf31ca535d3910965af31cb0d7aeaba1950
4
+ data.tar.gz: c70989f8ac3377f483ff9b2a1f8c7f01a3b77eea6d68f9a63da7cb19e6d34147
5
5
  SHA512:
6
- metadata.gz: 0062d5435e28bfd71bc27b21e87467c5eba724b1859ffa80fd09513ce778ecba0aa201cbd72e0cc61b0095caefda6bee15504228525edcb59688c4b3303e6653
7
- data.tar.gz: d5f3a982d1d4b037ac71baea54a8b6bcc732a3a26aea3faa6b07df830ba5c2011afd16cceee2b7906aadb23901f0ef9701d55637db90b214efe2aa127d751c6c
6
+ metadata.gz: f43d5162ff75d00362168fcbd18ba0717cd91200170ec3a4edd970ba4d783e75cacf38aede3ee57142dc953a17c89d23b7bc36f4218830643620d4a35faf8e60
7
+ data.tar.gz: a82f015d92ec44db65330d012d59c890341018dab175f60731676b20fbb72c11ca0e23d156853025f140aa7f91c5913fdca9fcf2cfe44ce02270a01da311c60f
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in bs2.gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bs2 (0.2.0)
4
+ bs2 (0.3.0)
5
5
  faraday_middleware
6
6
 
7
7
  GEM
@@ -12,20 +12,38 @@ GEM
12
12
  byebug (11.1.3)
13
13
  crack (0.4.5)
14
14
  rexml
15
- faraday (1.3.0)
15
+ faraday (1.10.3)
16
+ faraday-em_http (~> 1.0)
17
+ faraday-em_synchrony (~> 1.0)
18
+ faraday-excon (~> 1.1)
19
+ faraday-httpclient (~> 1.0)
20
+ faraday-multipart (~> 1.0)
16
21
  faraday-net_http (~> 1.0)
17
- multipart-post (>= 1.2, < 3)
18
- ruby2_keywords
22
+ faraday-net_http_persistent (~> 1.0)
23
+ faraday-patron (~> 1.0)
24
+ faraday-rack (~> 1.0)
25
+ faraday-retry (~> 1.0)
26
+ ruby2_keywords (>= 0.0.4)
27
+ faraday-em_http (1.0.0)
28
+ faraday-em_synchrony (1.0.0)
29
+ faraday-excon (1.1.0)
30
+ faraday-httpclient (1.0.1)
31
+ faraday-multipart (1.0.4)
32
+ multipart-post (~> 2)
19
33
  faraday-net_http (1.0.1)
20
- faraday_middleware (1.0.0)
34
+ faraday-net_http_persistent (1.2.0)
35
+ faraday-patron (1.0.0)
36
+ faraday-rack (1.0.0)
37
+ faraday-retry (1.0.3)
38
+ faraday_middleware (1.2.0)
21
39
  faraday (~> 1.0)
22
40
  hashdiff (1.0.1)
23
41
  minitest (5.14.4)
24
- multipart-post (2.1.1)
42
+ multipart-post (2.3.0)
25
43
  public_suffix (4.0.6)
26
44
  rake (12.3.3)
27
45
  rexml (3.2.4)
28
- ruby2_keywords (0.0.4)
46
+ ruby2_keywords (0.0.5)
29
47
  webmock (3.11.2)
30
48
  addressable (>= 2.3.6)
31
49
  crack (>= 0.3.2)
@@ -43,4 +61,4 @@ DEPENDENCIES
43
61
  webmock
44
62
 
45
63
  BUNDLED WITH
46
- 2.2.4
64
+ 2.2.32
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rake/testtask"
3
5
 
@@ -7,4 +9,4 @@ Rake::TestTask.new(:test) do |t|
7
9
  t.test_files = FileList["test/**/*_test.rb"]
8
10
  end
9
11
 
10
- task :default => :test
12
+ task default: :test
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "bundler/setup"
4
5
  require "bs2"
data/bs2.gemspec CHANGED
@@ -1,4 +1,6 @@
1
- require_relative 'lib/bs2/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/bs2/version"
2
4
 
3
5
  Gem::Specification.new do |spec|
4
6
  spec.name = "bs2"
@@ -6,8 +8,8 @@ Gem::Specification.new do |spec|
6
8
  spec.authors = ["Emerson Almeida"]
7
9
  spec.email = ["emersona@megafono.host"]
8
10
 
9
- spec.summary = %q{BS2 Ruby SDK}
10
- spec.description = %q{Gem to integration your ruby app with BS2}
11
+ spec.summary = "BS2 Ruby SDK"
12
+ spec.description = "Gem to integration your ruby app with BS2"
11
13
  spec.homepage = "https://github.com/megafono/bs2-ruby"
12
14
  spec.license = "MIT"
13
15
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
@@ -20,12 +22,12 @@ Gem::Specification.new do |spec|
20
22
 
21
23
  # Specify which files should be added to the gem when it is released.
22
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
24
26
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
27
  end
26
28
  spec.bindir = "exe"
27
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
30
  spec.require_paths = ["lib"]
29
31
 
30
- spec.add_dependency 'faraday_middleware'
32
+ spec.add_dependency "faraday_middleware"
31
33
  end
data/lib/bs2/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BS2
2
- VERSION = "0.2.0"
4
+ VERSION = "0.3.1"
3
5
  end
data/lib/bs2.rb CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bs2/version"
2
4
  require "base64"
3
- require 'forwardable'
5
+ require "forwardable"
4
6
  require "bundler/setup"
5
7
  require "logger"
6
8
  require "faraday_middleware"
@@ -13,7 +15,7 @@ module BS2
13
15
 
14
16
  class << self
15
17
  extend Forwardable
16
- def_delegators :connection, :create_billet, :generate_pdf, :cancel_billet, :fetch_billet
18
+ def_delegators :connection, :create_billet, :create_billet_v2 :generate_pdf, :cancel_billet, :fetch_billet
17
19
 
18
20
  # Configuration
19
21
  def configuration
@@ -30,8 +32,7 @@ module BS2
30
32
  end
31
33
 
32
34
  private
33
-
34
- attr_writer :configuration, :connection
35
+ attr_writer :configuration, :connection
35
36
  end
36
37
 
37
38
 
@@ -49,7 +50,7 @@ module BS2
49
50
  conn.response :logger, BS2.configuration.logger, { headers: true, bodies: json }
50
51
  conn.adapter Faraday.default_adapter
51
52
 
52
- conn.authorization('Bearer', @access_token)
53
+ conn.authorization("Bearer", @access_token)
53
54
  end
54
55
  end
55
56
 
@@ -83,6 +84,10 @@ module BS2
83
84
  resp.body
84
85
  end
85
86
 
87
+ def create_billet_v2(data)
88
+ create_connector.post("/pj/forintegration/cobranca/v2/boletos/simplificado", data)
89
+ end
90
+
86
91
  def create_billet(data)
87
92
  connector = create_connector
88
93
 
@@ -99,22 +104,22 @@ module BS2
99
104
  conn.basic_auth(BS2.configuration.api_key, BS2.configuration.api_secret)
100
105
  conn.response :json
101
106
  conn.adapter Faraday.default_adapter
102
- # conn.response :logger, BS2.configuration.logger, { headers: true, bodies: true }
107
+ conn.response :logger, BS2.configuration.logger, { headers: true, bodies: true }
103
108
  end
104
109
 
105
110
  # TODO: test connection errors
106
111
  response = connection.post("/auth/oauth/v2/token", {
107
112
  grant_type: "password",
108
113
  scope: "forintegration",
109
- username: BS2.configuration.username || "d",
110
- password: BS2.configuration.password || "e"
111
- }.map { |(key, value)| "#{key}=#{value}" }.join("&"), { 'Accept': 'application/json' })
114
+ username: BS2.configuration.username,
115
+ password: BS2.configuration.password
116
+ }.map { |(key, value)| "#{key}=#{value}" }.join("&"), { 'Accept': "application/json" })
112
117
 
113
118
  body = response.body
114
- @access_token = body.fetch('access_token')
115
- @token_type = body.fetch('token_type')
116
- @expires_in = Time.now + body.fetch('expires_in').to_i
117
- @refresh_token = body.fetch('refresh_token')
119
+ @access_token = body.fetch("access_token")
120
+ @token_type = body.fetch("token_type")
121
+ @expires_in = Time.now + body.fetch("expires_in").to_i
122
+ @refresh_token = body.fetch("refresh_token")
118
123
 
119
124
  true
120
125
  end
@@ -124,7 +129,7 @@ module BS2
124
129
  attr_accessor :api_key, :api_secret, :username, :password, :env, :logger
125
130
 
126
131
  def env
127
- @env || 'sandbox'
132
+ @env || "sandbox"
128
133
  end
129
134
 
130
135
  def endpoint
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bs2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emerson Almeida
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-27 00:00:00.000000000 Z
11
+ date: 2023-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday_middleware
@@ -53,7 +53,7 @@ metadata:
53
53
  homepage_uri: https://github.com/megafono/bs2-ruby
54
54
  source_code_uri: https://github.com/megafono/bs2-ruby
55
55
  changelog_uri: https://github.com/megafono/bs2-ruby/files/CHANGELOG.md
56
- post_install_message:
56
+ post_install_message:
57
57
  rdoc_options: []
58
58
  require_paths:
59
59
  - lib
@@ -68,8 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  requirements: []
71
- rubygems_version: 3.0.3
72
- signing_key:
71
+ rubygems_version: 3.2.32
72
+ signing_key:
73
73
  specification_version: 4
74
74
  summary: BS2 Ruby SDK
75
75
  test_files: []