bigid_auth 0.1.0 → 0.2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2de69a3a8e79498bdbbd8f42581b050cefd23994aecc8eba211b96769ee7f713
4
- data.tar.gz: 4874fbf692c691a47837623e08872f91a534125063bf110a5047faed6527f28c
3
+ metadata.gz: 5962bef2f1558cbd897e8ce4ea968230473e47c35ff581349b087ae288fb53f3
4
+ data.tar.gz: e1e6eb4d4a7abec028ad4620518e9bf364cb0768556eb016b446d7986f71503c
5
5
  SHA512:
6
- metadata.gz: f84e0666522ac76565b3a5dfe1f36d5eec5f5962a30f8072ff0d737e73cff5bbe180124938b05c4adb22218acaeb3bb4b400805d6f97182008a4fe2f25341424
7
- data.tar.gz: e1ce0d03e9ff4e70154410c0340af8c83018a699676ce9addc97ee62f2ba9f94d57406cd6459b49bdd192d91a9a07a41ba7290263156a9dcb52ed0c9a3d88029
6
+ metadata.gz: 67aba12265e0a5eba03e746f1e0d74955e31ea29a250c80c6c333aa433e10e5348f8dbba23d00b104839d9606ccffd2c3b2a4bbdd46600a146d15d4ccf684707
7
+ data.tar.gz: f3883a65bc894ff5017ad9332c244fcb1d49ff3562d388d27e480baa091365a5a67ea81dd382855677fa90c9a620237bf6ccf577fab62abd4e415fdc291d7b13
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.2.1.1-20220209 - Danilo Carolino
4
+
5
+ * bump flash_integration version to v0.1.2
6
+
7
+ ## v0.2.1-20220202 - Danilo Carolino
8
+
9
+ * [QC-79](https://qflash.atlassian.net/jira/software/projects/QC/boards/31?selectedIssue=QC-79)
10
+ Reduzir uso de pipelines em projetos Ruby [Dependabot]
11
+ * Bump Ruby version to v3.1.0
12
+
13
+ ## v0.2.0
14
+
15
+ * Use the gem "flash_integration" to retrieve a connection
16
+
17
+ ## v0.1.1
18
+
19
+ * Fix a problem with the locale initialization in Rails projects
20
+
3
21
  ## v0.1.0
4
22
 
5
23
  * Initial release of Bigid Auth
data/README.md CHANGED
@@ -2,7 +2,7 @@ BigId Auth's Library for Ruby
2
2
  ==============
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/bigid_auth.svg)](https://badge.fury.io/rb/bigid_auth)
5
- [![Build Status](https://travis-ci.com/Quasar-Flash/bigid-auth-ruby.svg?branch=master)](https://travis-ci.com/Quasar-Flash/bigid-auth-ruby)
5
+ [![bigid_auth](https://github.com/Quasar-Flash/bigid_auth/actions/workflows/ruby.yml/badge.svg)](https://github.com/Quasar-Flash/bigid_auth/actions/workflows/ruby.yml)
6
6
 
7
7
  Dev Requirements
8
8
  -----------------
@@ -13,76 +13,97 @@ Dev Requirements
13
13
  Global Installation
14
14
  -----------------
15
15
 
16
- gem install bigid_auth
16
+ ```ruby
17
+ gem install bigid_auth
18
+ ```
17
19
 
18
20
  Installation for Rails
19
21
  -----------------
20
22
 
21
- # Add to the Gemfile
22
- gem 'bigid_auth', '~> 0.1.0'
23
-
24
- Setting the BigID credentials
25
- -----------------
26
-
27
- # Set the env variables
28
- ENV['BIGID_USERNAME'] = 'your_username'
29
- ENV['BIGID_PASSWORD'] = 'your_password'
23
+ ```ruby
24
+ # Add to the Gemfile
25
+ gem "bigid_auth", "~> 0.2.0"
26
+ ```
30
27
 
31
28
  Setting the BigID credentials - Rails Project
32
29
  -----------------
33
30
 
34
31
  Create the config/initializers/bigid.rb file and define:
35
32
 
36
- # Set the env variables
37
- Bigid.configure do |config|
38
- config.username = 'your_username'
39
- config.password = 'your_password'
40
- end
33
+ ```ruby
34
+ # Set the env variables
35
+ Bigid.configure do |config|
36
+ config.username = "email@example.com"
37
+ config.password = "xxxxxxxxx"
38
+ end
39
+ ```
41
40
 
42
41
  Applying an authentication
43
42
  -----------------
44
43
 
45
- require 'bigid_auth'
44
+ ```ruby
45
+ require "bigid_auth"
46
46
 
47
- auth = Bigid::Auth::Authentication.new
48
- auth.login
47
+ Bigid::Auth::Authentication.new.login
48
+ ```
49
49
 
50
50
  Result Example
51
51
  -----------------
52
52
 
53
- #<Bigid::Auth::Integration::Response:0x0000564181d2bef0
54
- @request=#<Bigid::Auth::Integration::Request:0x0000564181d76a18
55
- @method=:post,
56
- @url="https://accesstoken.bigdatacorp.com.br/Generate",
57
- @params={},
58
- @headers={:"Content-Type"=>"application/json", :Accept=>"application/json"},
59
- @body="{\"login\":\"username\",\"password\":\"crtvreru\",\"expires\":60000}",
60
- @time=2021-04-18 18:55:24.678349974 UTC>,
61
- @status=200,
62
- @body="{\"expiration\":\"Mon, 21 Feb 2028 18:55:24 GMT\",\"message\":\"Token Generated\",\"success\":true,\"token\":\"xxxxxxxxxxxx\",\"tokenID\":\"0000000000\"}\n", @time=2021-04-18 18:55:24.995163484 UTC>
53
+ ```ruby
54
+ <Flash::Integration::Response:xxxx
55
+ @request=<Flash::Integration::Request:xxx
56
+ @method = :post,
57
+ @url = "https://accesstoken.bigdatacorp.com.br/Generate",
58
+ @params = {},
59
+ @headers = {
60
+ :"Content-Type" => "application/json",
61
+ :Accept => "application/json"
62
+ },
63
+ @body = "{\"login\":\"email@email.com\",\"password\":\"xxxxxx\",\"expires\":60000}",
64
+ @time = 2021-07-21 22:49:57.869382432 UTC>,
65
+ @status = 200,
66
+ @headers = {
67
+ "content-type" => "application/json",
68
+ "content-length" => "361",
69
+ "connection" => "keep-alive",
70
+ "date" => "Wed, 21 Jul 2021 22:49:58 GMT"
71
+ },
72
+ @body="{\"expiration\":\"Thu, 25 May 2028 22:49:58 GMT\",\"message\":\"Token Generated\",\"success\":true,\"token\":\"xxx\",\"tokenID\":\"xxx\"}\n",
73
+ @time=2021-07-21 22:49:58.248277077 UTC>
74
+
75
+ ```
63
76
 
64
77
  Problems?
65
78
  -----------------
66
79
 
67
- **Please do not directly email any committers with questions or problems.** A community is best served when discussions are held in public.
80
+ **Please do not directly email any committers with questions or problems.** A
81
+ community is best served when discussions are held in public.
68
82
 
69
- Searching the [issues](https://github.com/Quasar-Flash/bigid-auth-ruby/issues) for your problem is also a good idea.
83
+ Searching the [issues](https://github.com/Quasar-Flash/bigid_auth/issues)
84
+ for your problem is also a good idea.
70
85
 
71
86
  Contributing
72
87
  -----------------
73
88
 
74
- - Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet;
75
- - Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it;
89
+ - Check out the latest master to make sure the feature hasn't been implemented
90
+ or the bug hasn't been fixed yet;
91
+ - Check out the issue tracker to make sure someone already hasn't requested it
92
+ and/or contributed it;
76
93
  - Fork the project;
77
94
  - Start a feature/bugfix branch;
78
95
  - Commit and push until you are happy with your contribution;
79
- - Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.;
80
- - Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
96
+ - Make sure to add tests for it. This is important so I don't break it in a
97
+ future version unintentionally.;
98
+ - Please try not to mess with the Rakefile, version, or history. If you want to
99
+ have your own version, or is otherwise necessary, that is fine, but please
100
+ isolate to its own commit so I can cherry-pick around it.
81
101
 
82
102
  License
83
103
  -----------------
84
104
 
85
- Please see [LICENSE](https://github.com/Quasar-Flash/bigid-auth-ruby/blob/master/LICENSE.txt) for licensing details.
105
+ Please see [LICENSE](https://github.com/Quasar-Flash/bigid_auth/blob/master/LICENSE.txt)
106
+ for licensing details.
86
107
 
87
108
  Authors
88
109
  -----------------
data/Rakefile CHANGED
@@ -45,4 +45,4 @@ rescue LoadError
45
45
  # no rspec available
46
46
  end
47
47
 
48
- task default: %i[rubocop ]
48
+ task default: %i[rubocop spec]
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Bigid
4
4
  module Auth
5
- class Connection < Bigid::Auth::Integration::Connection
5
+ class Connection < Flash::Integration::Connection
6
6
  def initialize(request_class: Faraday, base_url: Bigid::Auth::AUTH_ENDPOINT)
7
7
  super(request_class: request_class, base_url: base_url)
8
8
  end
@@ -9,6 +9,6 @@ module Bigid
9
9
  # Major - Incremented for incompatible changes with previous release (or big enough new features)
10
10
  # Minor - Incremented for new backwards-compatible features + deprecations
11
11
  # Patch - Incremented for backwards-compatible bug fixes
12
- VERSION = "0.1.0"
12
+ VERSION = "0.2.1.1"
13
13
  end
14
14
  end
data/lib/bigid_auth.rb CHANGED
@@ -1,16 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "faraday"
3
+ require "flash_integration"
4
4
  require "i18n"
5
5
  require "json"
6
6
 
7
7
  require "bigid/auth/version"
8
8
 
9
- require "bigid/auth/integration/multipart_flat"
10
- require "bigid/auth/integration/response"
11
- require "bigid/auth/integration/request"
12
- require "bigid/auth/integration/connection"
13
-
14
9
  require "bigid/auth/connection"
15
10
  require "bigid/auth/authentication"
16
11
  require "bigid/auth/authenticated_resource"
@@ -22,6 +17,9 @@ require "bigid/auth/bad_request_error"
22
17
  require "bigid/auth/invalid_credentials_error"
23
18
  require "bigid/auth/server_error"
24
19
 
20
+ I18n.load_path += Dir[File.join(__dir__, "locales", "**/*.yml")]
21
+ I18n.reload! if I18n.backend.initialized?
22
+
25
23
  module Bigid
26
24
  BASE_URL = "https://bigid.bigdatacorp.com.br"
27
25
 
@@ -54,9 +52,5 @@ module Bigid
54
52
  module Auth
55
53
  AUTH_ENDPOINT = "https://accesstoken.bigdatacorp.com.br"
56
54
  TOKEN_EXPIRATION = 60_000
57
-
58
- I18n.load_path << Dir["#{File.expand_path('config/locales')}/*.yml"]
59
- I18n.config.available_locales = :en, :'pt-BR'
60
- I18n.default_locale = :en
61
55
  end
62
56
  end
@@ -0,0 +1,8 @@
1
+ en:
2
+ errors:
3
+ bigid:
4
+ auth:
5
+ authentication_error: An error ocurred during the authentication
6
+ bad_request_error: The request body or format is invalid
7
+ invalid_credentials_error: The credentials informed are invalid
8
+ server_error: An internal server error ocurred
@@ -0,0 +1,8 @@
1
+ 'pt-BR':
2
+ errors:
3
+ bigid:
4
+ auth:
5
+ authentication_error: Ocorreu um erro durante a autenticação
6
+ bad_request_error: O corpo ou formato da requisição é inválido
7
+ invalid_credentials_error: As credenciais informadas são inválidas
8
+ server_error: Ocorreu um erro inesperado no servidor
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "spec_helper"
4
- require "bigid_auth"
5
4
 
6
5
  RSpec.describe Bigid::Auth do
7
6
  describe "AUTH_ENDPOINT" do
@@ -18,15 +17,15 @@ RSpec.describe Bigid::Auth do
18
17
 
19
18
  describe ".configure" do
20
19
  before do
21
- described_class.configuration = nil
20
+ Bigid.configuration = nil
22
21
  ENV.clear
23
22
  end
24
23
 
25
- subject { described_class.configuration }
24
+ subject { Bigid.configuration }
26
25
 
27
26
  context "when configuration is defined" do
28
27
  before do
29
- described_class.configure do |config|
28
+ Bigid.configure do |config|
30
29
  config.username = "username_value"
31
30
  config.password = "password_value"
32
31
  end
@@ -65,7 +64,7 @@ RSpec.describe Bigid::Auth do
65
64
  ENV["BIGID_USERNAME"] = "username_value"
66
65
  ENV["BIGID_PASSWORD"] = "password_value"
67
66
 
68
- described_class.configure do |config|
67
+ Bigid.configure do |config|
69
68
  config.username = "username_value2"
70
69
  config.password = "password_value2"
71
70
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "simplecov"
4
+
5
+ SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter]
6
+ SimpleCov.minimum_coverage 70.0
7
+
8
+ SimpleCov.start do
9
+ add_filter "/spec/"
10
+ minimum_coverage 70
11
+ minimum_coverage_by_file 40
12
+ end
13
+
3
14
  require "rubygems"
4
15
  require "bundler"
16
+ require "bigid_auth"
17
+ require "pry"
5
18
 
6
19
  begin
7
20
  Bundler.setup(:default, :development, :test)
@@ -12,14 +25,13 @@ rescue Bundler::BundlerError => e
12
25
  exit e.status_code
13
26
  end
14
27
 
15
- require "simplecov"
16
-
17
- SimpleCov.start do
18
- add_filter "spec"
19
- end
20
-
21
28
  RSpec.configure do |config|
22
- # some (optional) config here
29
+ # Enable flags like --only-failures and --next-failure
30
+ config.example_status_persistence_file_path = ".rspec_status"
31
+
32
+ config.expect_with :rspec do |c|
33
+ c.syntax = :expect
34
+ end
23
35
  end
24
36
 
25
37
  # minitest/mock # Uncomment me to use minitest mocks
metadata CHANGED
@@ -1,75 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigid_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilo Carolino
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-18 00:00:00.000000000 Z
11
+ date: 2022-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: faraday
14
+ name: flash_integration
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.4.0
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: '1.0'
19
+ version: 0.1.2
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 1.4.0
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: '1.0'
26
+ version: 0.1.2
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: i18n
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: 1.8.0
40
31
  - - ">="
41
32
  - !ruby/object:Gem::Version
42
- version: '1.0'
33
+ version: '1.8'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '1.10'
43
37
  type: :runtime
44
38
  prerelease: false
45
39
  version_requirements: !ruby/object:Gem::Requirement
46
40
  requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: 1.8.0
50
41
  - - ">="
51
42
  - !ruby/object:Gem::Version
52
- version: '1.0'
43
+ version: '1.8'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.10'
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: json
55
49
  requirement: !ruby/object:Gem::Requirement
56
50
  requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: 2.5.0
60
51
  - - ">="
61
52
  - !ruby/object:Gem::Version
62
- version: '2.0'
53
+ version: '2.5'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '2.7'
63
57
  type: :runtime
64
58
  prerelease: false
65
59
  version_requirements: !ruby/object:Gem::Requirement
66
60
  requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: 2.5.0
70
61
  - - ">="
71
62
  - !ruby/object:Gem::Version
72
- version: '2.0'
63
+ version: '2.5'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '2.7'
73
67
  - !ruby/object:Gem::Dependency
74
68
  name: bundler
75
69
  requirement: !ruby/object:Gem::Requirement
@@ -90,14 +84,14 @@ dependencies:
90
84
  requirements:
91
85
  - - "~>"
92
86
  - !ruby/object:Gem::Version
93
- version: 6.1.0
87
+ version: 6.2.0
94
88
  type: :development
95
89
  prerelease: false
96
90
  version_requirements: !ruby/object:Gem::Requirement
97
91
  requirements:
98
92
  - - "~>"
99
93
  - !ruby/object:Gem::Version
100
- version: 6.1.0
94
+ version: 6.2.0
101
95
  - !ruby/object:Gem::Dependency
102
96
  name: gemsurance
103
97
  requirement: !ruby/object:Gem::Requirement
@@ -118,14 +112,14 @@ dependencies:
118
112
  requirements:
119
113
  - - "~>"
120
114
  - !ruby/object:Gem::Version
121
- version: 0.14.0
115
+ version: 0.14.1
122
116
  type: :development
123
117
  prerelease: false
124
118
  version_requirements: !ruby/object:Gem::Requirement
125
119
  requirements:
126
120
  - - "~>"
127
121
  - !ruby/object:Gem::Version
128
- version: 0.14.0
122
+ version: 0.14.1
129
123
  - !ruby/object:Gem::Dependency
130
124
  name: rake
131
125
  requirement: !ruby/object:Gem::Requirement
@@ -152,70 +146,70 @@ dependencies:
152
146
  requirements:
153
147
  - - "~>"
154
148
  - !ruby/object:Gem::Version
155
- version: 3.10.0
149
+ version: '3.11'
156
150
  type: :development
157
151
  prerelease: false
158
152
  version_requirements: !ruby/object:Gem::Requirement
159
153
  requirements:
160
154
  - - "~>"
161
155
  - !ruby/object:Gem::Version
162
- version: 3.10.0
156
+ version: '3.11'
163
157
  - !ruby/object:Gem::Dependency
164
158
  name: rubocop
165
159
  requirement: !ruby/object:Gem::Requirement
166
160
  requirements:
167
161
  - - "~>"
168
162
  - !ruby/object:Gem::Version
169
- version: 1.12.0
163
+ version: 1.25.0
170
164
  type: :development
171
165
  prerelease: false
172
166
  version_requirements: !ruby/object:Gem::Requirement
173
167
  requirements:
174
168
  - - "~>"
175
169
  - !ruby/object:Gem::Version
176
- version: 1.12.0
170
+ version: 1.25.0
177
171
  - !ruby/object:Gem::Dependency
178
172
  name: rubocop-packaging
179
173
  requirement: !ruby/object:Gem::Requirement
180
174
  requirements:
181
175
  - - "~>"
182
176
  - !ruby/object:Gem::Version
183
- version: 0.5.0
177
+ version: 0.5.1
184
178
  type: :development
185
179
  prerelease: false
186
180
  version_requirements: !ruby/object:Gem::Requirement
187
181
  requirements:
188
182
  - - "~>"
189
183
  - !ruby/object:Gem::Version
190
- version: 0.5.0
184
+ version: 0.5.1
191
185
  - !ruby/object:Gem::Dependency
192
186
  name: rubocop-performance
193
187
  requirement: !ruby/object:Gem::Requirement
194
188
  requirements:
195
189
  - - "~>"
196
190
  - !ruby/object:Gem::Version
197
- version: 1.10.0
191
+ version: 1.13.2
198
192
  type: :development
199
193
  prerelease: false
200
194
  version_requirements: !ruby/object:Gem::Requirement
201
195
  requirements:
202
196
  - - "~>"
203
197
  - !ruby/object:Gem::Version
204
- version: 1.10.0
198
+ version: 1.13.2
205
199
  - !ruby/object:Gem::Dependency
206
200
  name: simplecov
207
201
  requirement: !ruby/object:Gem::Requirement
208
202
  requirements:
209
203
  - - "~>"
210
204
  - !ruby/object:Gem::Version
211
- version: 0.21.0
205
+ version: 0.21.2
212
206
  type: :development
213
207
  prerelease: false
214
208
  version_requirements: !ruby/object:Gem::Requirement
215
209
  requirements:
216
210
  - - "~>"
217
211
  - !ruby/object:Gem::Version
218
- version: 0.21.0
212
+ version: 0.21.2
219
213
  description: A library to use BigData Corps auth features
220
214
  email:
221
215
  - danilo.carolino@qflash.com.br
@@ -234,21 +228,22 @@ files:
234
228
  - lib/bigid/auth/bad_request_error.rb
235
229
  - lib/bigid/auth/base_error.rb
236
230
  - lib/bigid/auth/connection.rb
237
- - lib/bigid/auth/integration/connection.rb
238
- - lib/bigid/auth/integration/multipart_flat.rb
239
- - lib/bigid/auth/integration/request.rb
240
- - lib/bigid/auth/integration/response.rb
241
231
  - lib/bigid/auth/invalid_credentials_error.rb
242
232
  - lib/bigid/auth/server_error.rb
243
233
  - lib/bigid/auth/version.rb
244
234
  - lib/bigid_auth.rb
235
+ - lib/locales/en.yml
236
+ - lib/locales/pt-BR.yml
245
237
  - spec/bigid_auth_spec.rb
246
238
  - spec/spec_helper.rb
247
- homepage: https://github.com/Quasar-Flash/bigid-auth-ruby
239
+ homepage: https://github.com/Quasar-Flash/bigid_auth
248
240
  licenses:
249
241
  - MIT
250
- metadata: {}
251
- post_install_message:
242
+ metadata:
243
+ changelog_uri: https://github.com/Quasar-Flash/bigid_auth/blob/master/CHANGELOG.md
244
+ source_code_uri: https://github.com/Quasar-Flash/bigid_auth
245
+ bug_tracker_uri: https://github.com/Quasar-Flash/bigid_auth/issues
246
+ post_install_message:
252
247
  rdoc_options: []
253
248
  require_paths:
254
249
  - lib
@@ -256,15 +251,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
256
251
  requirements:
257
252
  - - ">="
258
253
  - !ruby/object:Gem::Version
259
- version: '0'
254
+ version: '2.7'
260
255
  required_rubygems_version: !ruby/object:Gem::Requirement
261
256
  requirements:
262
257
  - - ">="
263
258
  - !ruby/object:Gem::Version
264
259
  version: '0'
265
260
  requirements: []
266
- rubygems_version: 3.1.4
267
- signing_key:
261
+ rubygems_version: 3.3.3
262
+ signing_key:
268
263
  specification_version: 4
269
264
  summary: Bigid Auth Library
270
265
  test_files:
@@ -1,120 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bigid
4
- module Auth
5
- module Integration
6
- class Connection
7
- attr_reader :base_url
8
-
9
- def initialize(base_url:, request_class: Faraday)
10
- @request_class = request_class
11
- @base_url = base_url
12
- end
13
-
14
- def get(url: "", params: {}, headers: {})
15
- send_request(
16
- method: :get,
17
- url: url,
18
- params: params,
19
- headers: headers
20
- )
21
- end
22
-
23
- def post(url: "", params: {}, headers: {}, body: {}, multipart: false)
24
- send_request(
25
- method: :post,
26
- url: url,
27
- params: params,
28
- headers: headers,
29
- body: body,
30
- multipart: multipart
31
- )
32
- end
33
-
34
- def put(url: "", params: {}, headers: {}, body: {})
35
- send_request(
36
- method: :put,
37
- url: url,
38
- params: params,
39
- headers: headers,
40
- body: body
41
- )
42
- end
43
-
44
- def patch(url: "", params: {}, headers: {}, body: {})
45
- send_request(
46
- method: :patch,
47
- url: url,
48
- params: params,
49
- headers: headers,
50
- body: body
51
- )
52
- end
53
-
54
- def delete(url: "", params: {}, headers: {}, body: {})
55
- send_request(
56
- method: :delete,
57
- url: url,
58
- params: params,
59
- headers: headers,
60
- body: body
61
- )
62
- end
63
-
64
- def default_headers
65
- {}
66
- end
67
-
68
- private
69
- def send_request(method:, url:, params:, headers:, body: nil, multipart: false)
70
- connection = multipart ? multipart_connection : @request_class.new(url: @base_url)
71
-
72
- merged_headers = default_headers.merge(headers)
73
-
74
- request = build_request(
75
- method, connection.build_url(url).to_s, params, merged_headers, body
76
- )
77
-
78
- result =
79
- connection.send(method) do |request|
80
- request.url(url)
81
- request.params = params
82
- request.headers = merged_headers
83
- request.body = body if body
84
- end
85
-
86
- build_response(request, result.status, result.headers, result.body)
87
- end
88
-
89
- def multipart_connection
90
- @request_class.new(url: @base_url) do |conn|
91
- conn.use Bigid::Auth::Integration::MultipartFlat
92
- conn.request :url_encoded
93
- conn.adapter @request_class.default_adapter
94
- end
95
- end
96
-
97
- def build_request(method, url, params, headers, body)
98
- Bigid::Auth::Integration::Request.new(
99
- method: method,
100
- url: url,
101
- params: params,
102
- headers: headers,
103
- body: body,
104
- time: Time.now.utc
105
- )
106
- end
107
-
108
- def build_response(request, status, headers, body)
109
- Bigid::Auth::Integration::Response.new(
110
- request: request,
111
- status: status,
112
- headers: headers,
113
- body: body,
114
- time: Time.now.utc
115
- )
116
- end
117
- end
118
- end
119
- end
120
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bigid
4
- module Auth
5
- module Integration
6
- class MultipartFlat < Faraday::Request::Multipart
7
- self.mime_type = "multipart/form-data"
8
- DEFAULT_BOUNDARY_PREFIX = "-----------RubyMultipartPost" unless defined? DEFAULT_BOUNDARY_PREFIX
9
-
10
- def process_params(params, prefix = nil, pieces = nil, &block)
11
- params.inject(pieces || []) do |all, (key, value)|
12
- key = prefix.to_s if prefix
13
-
14
- case value
15
- when Array
16
- values = value.inject([]) { |a, v| a << [nil, v] }
17
- process_params(values, key, all, &block)
18
- when Hash
19
- process_params(value, key, all, &block)
20
- else
21
- all << block.call(key, value)
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bigid
4
- module Auth
5
- module Integration
6
- class Request
7
- attr_reader :method, :url, :params, :headers, :body, :time
8
-
9
- def initialize(attributes)
10
- @method = attributes.fetch(:method)
11
- @url = attributes.fetch(:url)
12
- @params = attributes[:params] || {}
13
- @headers = attributes[:headers] || {}
14
- @body = attributes[:body] || {}
15
- @time = attributes[:time] || Time.current
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Bigid
4
- module Auth
5
- module Integration
6
- class Response
7
- attr_reader :request, :status, :headers, :body, :time
8
-
9
- def initialize(attributes)
10
- @request = attributes.fetch(:request)
11
- @status = attributes.fetch(:status)
12
- @headers = attributes[:headers] || {}
13
- @body = attributes[:body] || {}
14
- @time = attributes[:time] || Time.current
15
- end
16
-
17
- def success?
18
- @status.between?(200, 299)
19
- end
20
-
21
- def error?
22
- !success?
23
- end
24
- end
25
- end
26
- end
27
- end