1
1
//
2
- // URLEncoding+ExplodedParameters.swift
3
- // client-common-ios
2
+ // CommonClient+ExplodedParameters.swift
4
3
//
5
- // Created by Mirko Tomic on 16. 6. 2025..
4
+ // Generated by openapi-generator
5
+ // https://openapi-generator.tech
6
6
//
7
7
8
+
8
9
import Foundation
10
+ import Backbase
9
11
10
12
/// ArrayParam wrapper for controlling OpenAPI array parameter encoding
11
13
public struct ArrayParam {
@@ -28,6 +30,7 @@ public struct ArrayParam {
28
30
}
29
31
}
30
32
33
+ // MARK: - URLEncoding Extension with exploded arguments support
31
34
public extension URLEncoding {
32
35
/// Creates a URL request by encoding parameters with exploded array support
33
36
/// and applying them onto an existing request url.
@@ -95,3 +98,39 @@ public extension Array {
95
98
ArrayParam(self, exploded: false )
96
99
}
97
100
}
101
+
102
+ // MARK: - RequestBuilder Extension with Custom Encoding
103
+ public extension RequestBuilder {
104
+
105
+ /// createURLRequest with exploded support
106
+ /// - Parameters:
107
+ /// - requestUrl: request URL
108
+ /// - method: method
109
+ /// - queryParameters: query parameters
110
+ /// - bodyParameters: body parameters
111
+ /// - bodyType: BodyType
112
+ /// - headers: an object of type [String: String]
113
+ /// - Returns: URLRequest with exploded parameter support
114
+ static func createURLRequestWithExplodedSupport(requestUrl: URL,
115
+ method: String,
116
+ queryParameters: [String: Any]?,
117
+ bodyParameters: [String: Any]?,
118
+ bodyType: BodyType,
119
+ headers: [String: String] = [:]) throws -> URLRequest {
120
+ var modifiedRequest = try URLEncoding.encodeWithExplodedSupport(.init(url: requestUrl), with: queryParameters)
121
+ modifiedRequest.httpMethod = method
122
+ headers.forEach { modifiedRequest.setValue($0.value, forHTTPHeaderField: $0.key) }
123
+ Backbase.authClient().tokens().forEach { modifiedRequest.setValue($0.value, forHTTPHeaderField: $0.key) }
124
+
125
+ switch bodyType {
126
+ case .none:
127
+ break
128
+ case .json:
129
+ modifiedRequest = JSONDataEncoding.encode(modifiedRequest, with: bodyParameters)
130
+ case .multipartForm:
131
+ modifiedRequest = try FileUploadEncoding.encode(modifiedRequest, with: bodyParameters)
132
+ }
133
+
134
+ return modifiedRequest
135
+ }
136
+ }
0 commit comments