microsoft_kiota_faraday 0.9.0 → 0.10.0
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/CHANGELOG.md +6 -0
- data/lib/microsoft_kiota_faraday/kiota_client_factory.rb +3 -1
- data/lib/microsoft_kiota_faraday/middleware/user_agent_handler.rb +24 -0
- data/lib/microsoft_kiota_faraday/middleware/user_agent_option.rb +20 -0
- data/lib/microsoft_kiota_faraday/version.rb +1 -1
- data/lib/microsoft_kiota_faraday.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e514898a835bd6eb929491edc1abec7a52702122ac4a6d823c29383acfb7d9c6
|
4
|
+
data.tar.gz: da8a13c364989a1448c2dfe2585593a6bd675f9d88d9285ace41b01c026ce73a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65b2065a01457875ecc0a1ed1a5de4ee4cf1b8232e4afcef7adadf8d26edb9d594008000572e919f4414de76c2e2f93db7ade0685e41f472950c1a21251264d6
|
7
|
+
data.tar.gz: 1f4b4b82f786a214c5ae148f6fbec70d91e22070572622bbb02fe10dfe32801209e2e6aab3f2b50b55b2f6e4275106aa8537a34b5a82949ee1881a4fb3502a68
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
11
11
|
|
12
12
|
### Changed
|
13
13
|
|
14
|
+
## [0.10.0] - 2023-01-06
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- Added a user agent handler to add the product to the request header.
|
19
|
+
|
14
20
|
## [0.9.0] - 2022-12-30
|
15
21
|
|
16
22
|
### Added
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'net/https'
|
2
2
|
require 'faraday'
|
3
3
|
require_relative 'middleware/parameters_name_decoding_handler'
|
4
|
+
require_relative 'middleware/user_agent_handler'
|
4
5
|
module MicrosoftKiotaFaraday
|
5
6
|
class KiotaClientFactory
|
6
7
|
def self.get_default_middleware()
|
7
8
|
return [
|
8
|
-
MicrosoftKiotaFaraday::Middleware::ParametersNameDecodingHandler
|
9
|
+
MicrosoftKiotaFaraday::Middleware::ParametersNameDecodingHandler,
|
10
|
+
MicrosoftKiotaFaraday::Middleware::UserAgentHandler
|
9
11
|
]
|
10
12
|
end
|
11
13
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require_relative 'user_agent_option'
|
3
|
+
module MicrosoftKiotaFaraday
|
4
|
+
module Middleware
|
5
|
+
class UserAgentHandler < Faraday::Middleware
|
6
|
+
@@default_option = UserAgentOption.new
|
7
|
+
@@user_agent_key = "User-Agent"
|
8
|
+
def call(request_env)
|
9
|
+
request_option = request_env[:request][:context][@@default_option.get_key] unless request_env[:request].nil? || request_env[:request][:context].nil?
|
10
|
+
request_option = @@default_option if request_option.nil?
|
11
|
+
unless request_env[:request_headers].nil? || !request_option.enabled || request_option.product_name.nil? || request_option.product_name.empty? || request_option.product_version.nil? || request_option.product_version.empty? then
|
12
|
+
existing_value = request_env[:request_headers][@@user_agent_key]
|
13
|
+
additional_value = "#{request_option.product_name}/#{request_option.product_version}"
|
14
|
+
if !existing_value || existing_value.empty? then
|
15
|
+
request_env[:request_headers][@@user_agent_key] = additional_value
|
16
|
+
elsif !existing_value.include? additional_value then
|
17
|
+
request_env[:request_headers][@@user_agent_key] = "#{existing_value} #{additional_value}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
@app.call(request_env) unless @app.nil?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'microsoft_kiota_abstractions'
|
3
|
+
require_relative '../version.rb'
|
4
|
+
module MicrosoftKiotaFaraday
|
5
|
+
module Middleware
|
6
|
+
class UserAgentOption
|
7
|
+
include MicrosoftKiotaAbstractions::RequestOption
|
8
|
+
attr_accessor :enabled, :product_name, :product_version
|
9
|
+
def initialize()
|
10
|
+
@enabled = true
|
11
|
+
@product_name = "kiota-ruby"
|
12
|
+
@product_version = MicrosoftKiotaFaraday::VERSION
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_key()
|
16
|
+
"userAgent"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -4,6 +4,8 @@ require_relative 'microsoft_kiota_faraday/version'
|
|
4
4
|
require_relative 'microsoft_kiota_faraday/middleware/response_handler_option'
|
5
5
|
require_relative 'microsoft_kiota_faraday/middleware/parameters_name_decoding_option'
|
6
6
|
require_relative 'microsoft_kiota_faraday/middleware/parameters_name_decoding_handler'
|
7
|
+
require_relative 'microsoft_kiota_faraday/middleware/user_agent_option'
|
8
|
+
require_relative 'microsoft_kiota_faraday/middleware/user_agent_handler'
|
7
9
|
require_relative 'microsoft_kiota_faraday/kiota_client_factory'
|
8
10
|
require_relative 'microsoft_kiota_faraday/faraday_request_adapter'
|
9
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: microsoft_kiota_faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Microsoft Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: microsoft_kiota_abstractions
|
@@ -121,6 +121,8 @@ files:
|
|
121
121
|
- lib/microsoft_kiota_faraday/middleware/parameters_name_decoding_handler.rb
|
122
122
|
- lib/microsoft_kiota_faraday/middleware/parameters_name_decoding_option.rb
|
123
123
|
- lib/microsoft_kiota_faraday/middleware/response_handler_option.rb
|
124
|
+
- lib/microsoft_kiota_faraday/middleware/user_agent_handler.rb
|
125
|
+
- lib/microsoft_kiota_faraday/middleware/user_agent_option.rb
|
124
126
|
- lib/microsoft_kiota_faraday/version.rb
|
125
127
|
- microsoft_kiota_faraday.gemspec
|
126
128
|
homepage: https://microsoft.github.io/kiota/
|