@@ -20,8 +20,8 @@ public struct RxRestClientOptions {
2020 public var headers = [ " Content-Type " : " application/json " ]
2121 public var maxConcurrentOperationCount = 2
2222 public var logger : RxRestClientLogger ?
23- public var urlEncoding : ParameterEncoding = URLEncoding . default
24- public var jsonEncoding : ParameterEncoding = JSONEncoding . default
23+ public var queryEncoding : ParameterEncoding = URLEncoding . default
24+ public var bodyEncoding : ParameterEncoding = JSONEncoding . default
2525 public var jsonDecoder : JSONDecoder = JSONDecoder ( )
2626 public var jsonEncoder : JSONEncoder = JSONEncoder ( )
2727 public var sessionManager : SessionManager ?
@@ -99,7 +99,7 @@ open class RxRestClient {
9999 /// - object: dictinary representing body of request
100100 /// - Returns: An observable of a the response state
101101 public func post< T: ResponseState > ( url: URL , object: [ String : Any ] ) -> Observable < T > {
102- return run ( request ( . post, url, object: object) )
102+ return run ( request ( . post, url, object: object, encoding : options . bodyEncoding ) )
103103 }
104104
105105 /// Do POST Request
@@ -159,7 +159,7 @@ open class RxRestClient {
159159 /// - object: dictinary representing body of request
160160 /// - Returns: An observable of a the response state
161161 public func put< T: ResponseState > ( url: URL , object: [ String : Any ] ) -> Observable < T > {
162- return run ( request ( . put, url, object: object) )
162+ return run ( request ( . put, url, object: object, encoding : options . bodyEncoding ) )
163163 }
164164
165165 /// Do PUT Request
@@ -219,7 +219,7 @@ open class RxRestClient {
219219 /// - object: dictinary representing body of request
220220 /// - Returns: An observable of a the response state
221221 public func patch< T: ResponseState > ( url: URL , object: [ String : Any ] ) -> Observable < T > {
222- return run ( request ( . patch, url, object: object) )
222+ return run ( request ( . patch, url, object: object, encoding : options . bodyEncoding ) )
223223 }
224224
225225 /// Do PATCH Request
@@ -256,30 +256,7 @@ open class RxRestClient {
256256 /// - object: dictinary representing body of request, default value is empty
257257 /// - Returns: An observable of a the response state
258258 public func delete< T: ResponseState > ( url: URL , object: [ String : Any ] = [ : ] ) -> Observable < T > {
259- return run ( request ( . delete, url, object: object) )
260- }
261-
262- /// Do DELETE Request
263- ///
264- /// - Parameters:
265- /// - endpoint: Relative path of endpoint which will be appended to baseUrl
266- /// - array: array representing body of request, default value is empty
267- /// - Returns: An observable of a the response state
268- public func delete< T: ResponseState > ( _ endpoint: String , array: [ Any ] ) -> Observable < T > {
269- guard let url = buildURL ( endpoint) else {
270- return Observable . error ( RxRestClientError . urlBuildFailed)
271- }
272- return delete ( url: url, array: array)
273- }
274-
275- /// Do DELETE Request
276- ///
277- /// - Parameters:
278- /// - url: absalute url
279- /// - array: array representing body of request, default value is empty
280- /// - Returns: An observable of a the response state
281- public func delete< T: ResponseState > ( url: URL , array: [ Any ] ) -> Observable < T > {
282- return run ( request ( . delete, url, array: array) )
259+ return run ( request ( . delete, url, object: object, encoding: options. queryEncoding) )
283260 }
284261
285262 /// Do DELETE Request
@@ -316,7 +293,7 @@ open class RxRestClient {
316293 /// - query: dictinary representing query of request, default value is empty
317294 /// - Returns: An observable of a the response state
318295 public func get< T: ResponseState > ( url: URL , query: [ String : Any ] = [ : ] ) -> Observable < T > {
319- return run ( request ( . get, url, object: query, encoding: options. urlEncoding ) )
296+ return run ( request ( . get, url, object: query, encoding: options. queryEncoding ) )
320297 }
321298
322299 /// Do GET Request
@@ -432,12 +409,12 @@ open class RxRestClient {
432409 /// - object: A dictionary containing all necessary options
433410 /// - encoding: The kind of encoding used to process parameters
434411 /// - Returns: An observable of a the created DataRequest
435- public func request( _ method: HTTPMethod , _ url: URLConvertible , object: [ String : Any ] , encoding: ParameterEncoding ? = nil ) -> Observable < DataRequest > {
412+ public func request( _ method: HTTPMethod , _ url: URLConvertible , object: [ String : Any ] , encoding: ParameterEncoding ) -> Observable < DataRequest > {
436413 return getSessionManager ( ) . rx. request (
437414 method,
438415 url,
439416 parameters: object,
440- encoding: encoding ?? options . jsonEncoding ,
417+ encoding: encoding,
441418 headers: options. headers
442419 )
443420 }
0 commit comments