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 +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +26 -8
- data/Rakefile +3 -1
- data/bin/console +1 -0
- data/bs2.gemspec +7 -5
- data/lib/bs2/version.rb +3 -1
- data/lib/bs2.rb +19 -14
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1925382d1b8d399385004e1000d3cf31ca535d3910965af31cb0d7aeaba1950
|
4
|
+
data.tar.gz: c70989f8ac3377f483ff9b2a1f8c7f01a3b77eea6d68f9a63da7cb19e6d34147
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f43d5162ff75d00362168fcbd18ba0717cd91200170ec3a4edd970ba4d783e75cacf38aede3ee57142dc953a17c89d23b7bc36f4218830643620d4a35faf8e60
|
7
|
+
data.tar.gz: a82f015d92ec44db65330d012d59c890341018dab175f60731676b20fbb72c11ca0e23d156853025f140aa7f91c5913fdca9fcf2cfe44ce02270a01da311c60f
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bs2 (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
|
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
|
-
|
18
|
-
|
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
|
-
|
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.
|
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.
|
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.
|
64
|
+
2.2.32
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/bs2.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
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 =
|
10
|
-
spec.description =
|
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
|
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
|
32
|
+
spec.add_dependency "faraday_middleware"
|
31
33
|
end
|
data/lib/bs2/version.rb
CHANGED
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
|
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(
|
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
|
-
|
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
|
110
|
-
password: BS2.configuration.password
|
111
|
-
}.map { |(key, value)| "#{key}=#{value}" }.join("&"), { 'Accept':
|
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(
|
115
|
-
@token_type = body.fetch(
|
116
|
-
@expires_in = Time.now + body.fetch(
|
117
|
-
@refresh_token = body.fetch(
|
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 ||
|
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.
|
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:
|
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.
|
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: []
|