|
|
|
|
@ -241,7 +241,7 @@ public class Services { |
|
|
|
|
/// - method: the HTTP method to execute |
|
|
|
|
/// - requiresToken: An optional boolean to indicate if the token is required |
|
|
|
|
/// - identifier: an optional StoreIdentifier that allows to filter GET requests with the StoreIdentifier values |
|
|
|
|
fileprivate func _baseRequest( |
|
|
|
|
public func _baseRequest( |
|
|
|
|
servicePath: String, method: HTTPMethod, requiresToken: Bool? = nil, |
|
|
|
|
identifier: String? = nil, getArguments: [String : String]? = nil |
|
|
|
|
) throws -> URLRequest { |
|
|
|
|
@ -499,6 +499,26 @@ public class Services { |
|
|
|
|
return try await self._runRequest(getRequest) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Executes a POST request on the generated DRF services corresponding to T |
|
|
|
|
public func rawPost<T: Storable>(_ instance: T) async throws -> T { |
|
|
|
|
var postRequest = try self._postRequest(type: T.self) |
|
|
|
|
postRequest.httpBody = try JSON.encoder.encode(instance) |
|
|
|
|
return try await self._runRequest(postRequest) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Executes a PUT request on the generated DRF services corresponding to T |
|
|
|
|
public func rawPut<T: Storable>(_ instance: T) async throws -> T { |
|
|
|
|
var postRequest = try self._putRequest(type: T.self, id: instance.stringId) |
|
|
|
|
postRequest.httpBody = try JSON.encoder.encode(instance) |
|
|
|
|
return try await self._runRequest(postRequest) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Executes a DELETE request on the generated DRF services corresponding to T |
|
|
|
|
public func rawDelete<T: Storable>(_ instance: T) async throws -> T { |
|
|
|
|
let deleteRequest = try self._deleteRequest(type: T.self, id: instance.stringId) |
|
|
|
|
return try await self._runRequest(deleteRequest) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Executes a POST request |
|
|
|
|
|
|
|
|
|
public func post<T: Storable>(_ instance: T) async throws -> T { |
|
|
|
|
|