authkeeper 0.1.10 → 0.1.11

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: 65f8ece85bc4e6ed31e1ed3ae5b142cd2b79b7cfe2e3fdd87009e1537a37a271
4
- data.tar.gz: e92f55f1bb92d4c2b910436650fc90aa13749f7f03d3ba3c4d0b1d6b7917d2e9
3
+ metadata.gz: 8105f35b2cee5f3c686c7300ebf3bb41b8c17872ea63fdbe59ba469716a7d370
4
+ data.tar.gz: c25b539dbca8a4ed37e00efb528ad877c4ca6abb81a49df16f4e9ff0b8142af7
5
5
  SHA512:
6
- metadata.gz: 8abc1c3a419e87aa6b1e3456ae22152824f9f823ef430fb7748108a2959dd78253331674e510ceef753e73107d59531bbe6a2633aad11c9b66fd43e32957bf21
7
- data.tar.gz: a0b54c38844b41e5def8c6ac8a153cbb99c711d25c5ba5044b7c074ebc2169814c3afdcd3b06ba3ce21383a169617bfb0f5cf31b0c006948a287774d51aa8e71
6
+ metadata.gz: 07b69c728a18d65e77c65d5b0a3613d6d676b88a96bab31c4d46d9017ad1350cb15e878b505962831e7d899ed08827cc85020fbc8177891611471ce5440a7600
7
+ data.tar.gz: 3e4e74fb0bf1f8b95e5121cfc8b525b0fe057abe2783045b64fd7be82782522a3566a66d288e0be769c2c77cea4f19a23923da0441856dc23e3e2b1fd12b0090
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module DiscordApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::User
7
7
 
8
8
  BASE_URL = 'https://discord.com/api/v10/'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module DiscordAuthApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::FetchAccessToken
7
7
 
8
8
  BASE_URL = 'https://discord.com/api/v10/'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module GithubApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::User
7
7
  include Requests::UserEmails
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module GithubAuthApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::FetchAccessToken
7
7
 
8
8
  BASE_URL = 'https://github.com'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module GitlabApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::User
7
7
 
8
8
  BASE_URL = 'https://gitlab.com'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module GitlabAuthApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::FetchAccessToken
7
7
 
8
8
  BASE_URL = 'https://gitlab.com'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module GoogleApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::User
7
7
 
8
8
  BASE_URL = 'https://www.googleapis.com'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module GoogleAuthApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::FetchAccessToken
7
7
 
8
8
  BASE_URL = 'https://www.googleapis.com/'
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/initializer'
4
+
5
+ module Authkeeper
6
+ module HttpService
7
+ class Client
8
+ extend Dry::Initializer[undefined: false]
9
+
10
+ option :url
11
+ option :connection, default: proc { build_connection }
12
+
13
+ def get(path:, params: nil, headers: nil)
14
+ if Rails.env.test? && connection.adapter != 'Faraday::Adapter::Test'
15
+ raise StandardError, 'please stub request in test env'
16
+ end
17
+
18
+ response = connection.get(path, params, headers)
19
+ {
20
+ success: response.success?,
21
+ body: response.body
22
+ }
23
+ end
24
+
25
+ # rubocop: disable Metrics/AbcSize
26
+ def post(path:, body: nil, headers: nil)
27
+ if Rails.env.test? && connection.adapter != 'Faraday::Adapter::Test'
28
+ raise StandardError, 'please stub request in test env'
29
+ end
30
+
31
+ response = connection.post(path, body, headers)
32
+ response.body if response.success?
33
+ end
34
+
35
+ def form_post(path:, body: {}, params: {}, headers: {})
36
+ if Rails.env.test? && connection.adapter != 'Faraday::Adapter::Test'
37
+ raise StandardError, 'please stub request in test env'
38
+ end
39
+
40
+ response = connection.post(path) do |request|
41
+ params.each do |param, value|
42
+ request.params[param] = value
43
+ end
44
+ headers.each do |header, value|
45
+ request.headers[header] = value
46
+ end
47
+ request.body = URI.encode_www_form(body)
48
+ end
49
+ response.body if response.success?
50
+ end
51
+ # rubocop: enable Metrics/AbcSize
52
+
53
+ private
54
+
55
+ def build_connection
56
+ Faraday.new(@url) do |conn|
57
+ conn.request :url_encoded
58
+ conn.response :json, content_type: /\bjson$/
59
+ conn.adapter Faraday.default_adapter
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module VkAuthApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::AccessToken
7
7
  include Requests::Info
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module YandexApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::Info
7
7
 
8
8
  BASE_URL = 'https://login.yandex.ru/'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Authkeeper
4
4
  module YandexAuthApi
5
- class Client < HttpService::Client
5
+ class Client < Authkeeper::HttpService::Client
6
6
  include Requests::AccessToken
7
7
 
8
8
  BASE_URL = 'https://oauth.yandex.ru/'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Authkeeper
4
- VERSION = '0.1.10'
4
+ VERSION = '0.1.11'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authkeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdanov Anton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-16 00:00:00.000000000 Z
11
+ date: 2025-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -55,6 +55,7 @@ files:
55
55
  - app/lib/authkeeper/google_api/requests/user.rb
56
56
  - app/lib/authkeeper/google_auth_api/client.rb
57
57
  - app/lib/authkeeper/google_auth_api/requests/fetch_access_token.rb
58
+ - app/lib/authkeeper/http_service/client.rb
58
59
  - app/lib/authkeeper/jwt_encoder.rb
59
60
  - app/lib/authkeeper/vk_auth_api/client.rb
60
61
  - app/lib/authkeeper/vk_auth_api/requests/access_token.rb