Skip to content

Commit

Permalink
Version updated to 2.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRakiburKhan committed Jun 8, 2022
1 parent fe1ce36 commit 84c9a98
Show file tree
Hide file tree
Showing 4 changed files with 380 additions and 66 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Version 2.2.1 (Latest)
Version 2.2.2
- Updated Quick Help guide for methods
- Added polymorfic methods for direct data manipulation.
- `RKAPIHelper` methods not accessible issue solved.

Version 2.2.1

- Added `RKAPIHelper` which has helper functions to build `URL`
- `buildURL(scheme: String, baseURL: String, portNo: Int?, path: String?, queries: [URLQueryItem]?)` returns an `URL?`
Expand Down
22 changes: 18 additions & 4 deletions Sources/RKAPIService/RKAPIHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
//

import Foundation

struct RKAPIHelper {
/**
RKAPIHelper provides some useful methods to help process data for network communication.
*/
public struct RKAPIHelper {
/**
Builds an url from given component
Expand All @@ -20,7 +22,7 @@ struct RKAPIHelper {
- path: An `Optional<String>` aka `String?`. Default value is *`Nil`*
- queries: An array of `Optional<URLQueryItem>` aka `[URLQueryItem]?`. Default value is *`Nil`*
*/
static func buildURL(scheme: String = "https", baseURL: String, portNo: Int? = nil, path: String? = nil, queries: [URLQueryItem]? = nil)-> URL? {
public static func buildURL(scheme: String = "https", baseURL: String, portNo: Int? = nil, path: String? = nil, queries: [URLQueryItem]? = nil)-> URL? {
var url: URL? {
var components = URLComponents()
components.scheme = scheme
Expand Down Expand Up @@ -57,7 +59,19 @@ struct RKAPIHelper {
- string: An `String`
- fillter: A `CharacterSet`. Default value is `CharacterSet.urlQueryAllowed`
*/
@inlinable static func buildURL(string: String, filter: CharacterSet = .urlQueryAllowed) -> URL? {
@inlinable public static func buildURL(string: String, filter: CharacterSet = .urlQueryAllowed) -> URL? {
return URL(string: string.addingPercentEncoding(withAllowedCharacters: filter) ?? "")
}

/**
Encodes any data to `Data?` for uploding as `URLRequest` body
- Parameters:
- data: Receives generic type `T` which confirms to `Encodable`
- Returns: Returns an `Optional<Data>` aka `Data?`
*/
public static func generateRequestBody<T: Encodable>(_ data: T) -> Data? {
return try? JSONEncoder().encode(data)
}
}
Loading

0 comments on commit 84c9a98

Please sign in to comment.