microsoft_kiota_faraday 0.21.0 → 0.23.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a0c0c510b70a06940555374f95a4fa8390e439b8219f0c0e2c80305386ec6ae
|
|
4
|
+
data.tar.gz: ec465be8e91057f9f39e4fe91af9636facb5574ef1c10d130be24d119c650bda
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 36dd13115681ee764d725e0dc955dcc9c9d99d9aa99af434fb4b57a0f022ad999c3d070b4e8365b9c6bcd84a254e8ba9e8d95aefe54ccb58d25b1b5868fdcd61
|
|
7
|
+
data.tar.gz: 13782fcf9a3e7e0afe85b563d7fe3a59e2826267f1af84e0b04e908bc8d8301b02d8b4dc15505e4e8f57d67e7c0cd1b9008d05e5d886fd5e6bc35d48b77c8fc6
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require 'microsoft_kiota_abstractions'
|
|
4
4
|
require 'faraday'
|
|
5
5
|
require 'net/http'
|
|
6
|
+
require 'stringio'
|
|
6
7
|
require_relative 'kiota_client_factory'
|
|
7
8
|
require_relative 'middleware/response_handler_option'
|
|
8
9
|
|
|
@@ -44,10 +45,63 @@ module MicrosoftKiotaFaraday
|
|
|
44
45
|
@serialization_writer_factory
|
|
45
46
|
end
|
|
46
47
|
|
|
48
|
+
PRIMITIVE_READERS = {
|
|
49
|
+
'String' => :get_string_value,
|
|
50
|
+
'Float' => :get_float_value,
|
|
51
|
+
'Integer' => :get_number_value,
|
|
52
|
+
'Date' => :get_date_value,
|
|
53
|
+
'DateTime' => :get_date_time_value,
|
|
54
|
+
'Time' => :get_time_value,
|
|
55
|
+
'MicrosoftKiotaAbstractions::ISODuration' => :get_duration_value,
|
|
56
|
+
'UUIDTools::UUID' => :get_guid_value,
|
|
57
|
+
'boolean' => :get_boolean_value,
|
|
58
|
+
'Boolean' => :get_boolean_value
|
|
59
|
+
}.freeze
|
|
60
|
+
|
|
47
61
|
def send_async(request_info, factory, errors_mapping)
|
|
48
|
-
raise StandardError, 'request_info cannot be null' unless request_info
|
|
49
62
|
raise StandardError, 'factory cannot be null' unless factory
|
|
50
63
|
|
|
64
|
+
execute_async(request_info, errors_mapping) do |response|
|
|
65
|
+
get_root_parse_node(response)&.get_object_value(factory)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def send_collection_async(request_info, factory, errors_mapping)
|
|
70
|
+
raise StandardError, 'factory cannot be null' unless factory
|
|
71
|
+
|
|
72
|
+
execute_async(request_info, errors_mapping) do |response|
|
|
73
|
+
get_root_parse_node(response)&.get_collection_of_object_values(factory)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def send_collection_of_primitive_async(request_info, type, errors_mapping)
|
|
78
|
+
execute_async(request_info, errors_mapping) do |response|
|
|
79
|
+
root_node = get_root_parse_node(response)
|
|
80
|
+
next root_node&.get_collection_of_enum_values(type) if type.is_a?(Hash)
|
|
81
|
+
|
|
82
|
+
root_node&.get_collection_of_primitive_values(type)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def send_primitive_async(request_info, type, errors_mapping)
|
|
87
|
+
execute_async(request_info, errors_mapping) do |response|
|
|
88
|
+
next StringIO.new(response.body.to_s) if type == StringIO
|
|
89
|
+
next get_root_parse_node(response)&.get_enum_value(type) if type.is_a?(Hash)
|
|
90
|
+
|
|
91
|
+
reader = PRIMITIVE_READERS[type.to_s]
|
|
92
|
+
raise StandardError, "unexpected primitive response type #{type}" if reader.nil?
|
|
93
|
+
|
|
94
|
+
get_root_parse_node(response)&.public_send(reader)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def send_no_response_content_async(request_info, errors_mapping)
|
|
99
|
+
execute_async(request_info, errors_mapping) { nil }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def execute_async(request_info, errors_mapping)
|
|
103
|
+
raise StandardError, 'request_info cannot be null' unless request_info
|
|
104
|
+
|
|
51
105
|
Fiber.new do
|
|
52
106
|
set_base_url_for_request_information(request_info)
|
|
53
107
|
@authentication_provider.authenticate_request(request_info).resume
|
|
@@ -57,8 +111,7 @@ module MicrosoftKiotaFaraday
|
|
|
57
111
|
response_handler = get_response_handler(request_info)
|
|
58
112
|
response_handler&.call(response)&.resume
|
|
59
113
|
throw_if_failed_reponse(response, errors_mapping)
|
|
60
|
-
|
|
61
|
-
root_node.get_object_value(factory)
|
|
114
|
+
yield response
|
|
62
115
|
end
|
|
63
116
|
end
|
|
64
117
|
|
|
@@ -72,9 +125,10 @@ module MicrosoftKiotaFaraday
|
|
|
72
125
|
def get_root_parse_node(response)
|
|
73
126
|
raise StandardError, 'response cannot be null' unless response
|
|
74
127
|
|
|
128
|
+
return if response.body.nil? || response.body.empty?
|
|
129
|
+
|
|
75
130
|
response_content_type = get_response_content_type(response)
|
|
76
131
|
raise StandardError, 'no response content type found for deserialization' unless response_content_type
|
|
77
|
-
return if response.body.nil? || response.body.empty?
|
|
78
132
|
|
|
79
133
|
@parse_node_factory.get_parse_node(response_content_type, response.body)
|
|
80
134
|
end
|
|
@@ -108,24 +162,8 @@ module MicrosoftKiotaFaraday
|
|
|
108
162
|
def get_request_from_request_info(request_info)
|
|
109
163
|
set_base_url_for_request_information(request_info)
|
|
110
164
|
case request_info.http_method
|
|
111
|
-
when :GET
|
|
112
|
-
request = @client.build_request(
|
|
113
|
-
when :POST
|
|
114
|
-
request = @client.build_request(:post)
|
|
115
|
-
when :PATCH
|
|
116
|
-
request = @client.build_request(:patch)
|
|
117
|
-
when :DELETE
|
|
118
|
-
request = @client.build_request(:delete)
|
|
119
|
-
when :OPTIONS
|
|
120
|
-
request = @client.build_request(:options)
|
|
121
|
-
when :CONNECT
|
|
122
|
-
request = @client.build_request(:connect)
|
|
123
|
-
when :PUT
|
|
124
|
-
request = @client.build_request(:put)
|
|
125
|
-
when :TRACE
|
|
126
|
-
request = @client.build_request(:trace)
|
|
127
|
-
when :HEAD
|
|
128
|
-
request = @client.build_request(:head)
|
|
165
|
+
when :GET, :POST, :PATCH, :DELETE, :OPTIONS, :CONNECT, :PUT, :TRACE, :HEAD, :QUERY
|
|
166
|
+
request = @client.build_request(request_info.http_method.downcase)
|
|
129
167
|
else
|
|
130
168
|
raise StandardError, 'unsupported http method'
|
|
131
169
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.23.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Microsoft Corporation
|
|
@@ -35,14 +35,14 @@ dependencies:
|
|
|
35
35
|
requirements:
|
|
36
36
|
- - '='
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: 0.
|
|
38
|
+
version: 0.23.0
|
|
39
39
|
type: :runtime
|
|
40
40
|
prerelease: false
|
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
|
43
43
|
- - '='
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 0.
|
|
45
|
+
version: 0.23.0
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: rake
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|