-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e0fa0f
commit e6b4d75
Showing
10 changed files
with
230 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// NetNetNet.swift | ||
// NetNetNet | ||
// | ||
// Created by Carlos Cáceres González on 20/10/24. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
public struct NetConfig { | ||
// Basic configuration | ||
var scheme: String | ||
var host: String | ||
// OAuth Configuration | ||
var clientId: String | ||
var clientSecret: String | ||
var oauthEndpoint: String | ||
|
||
public init(scheme: String = "https", | ||
host: String, | ||
clientId: String = "", | ||
clientSecret: String = "", | ||
oauthEndpoint: String = "") { | ||
self.scheme = scheme | ||
self.host = host | ||
self.clientId = clientId | ||
self.clientSecret = clientSecret | ||
self.oauthEndpoint = oauthEndpoint | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// MocksEndpoint.swift | ||
// NetNetNet | ||
// | ||
// Created by Carlos Cáceres González on 6/11/24. | ||
// | ||
|
||
import Foundation | ||
@testable import NetNetNet | ||
|
||
|
||
final class EndpointBuilder { | ||
private var path: String = "" | ||
private var encoding: BodyEncoding = .json | ||
private var method: HTTPMethods = .get | ||
private var withAuth: Bool = false | ||
private var retries: Int = 0 | ||
private var queryItems: [URLQueryItem]? | ||
private var headers: [String : String]? | ||
|
||
func path(_ param: String) -> Self { | ||
path = param | ||
return self | ||
} | ||
|
||
func encoding(_ param: BodyEncoding) -> Self { | ||
encoding = param | ||
return self | ||
} | ||
|
||
func method(_ param: HTTPMethods) -> Self { | ||
method = param | ||
return self | ||
} | ||
|
||
func withAuth(_ param: Bool) -> Self { | ||
withAuth = param | ||
return self | ||
} | ||
|
||
func retries(_ param: Int) -> Self { | ||
retries = param | ||
return self | ||
} | ||
|
||
func queryItems(_ param: [URLQueryItem]?) -> Self { | ||
queryItems = param | ||
return self | ||
} | ||
|
||
func headers(_ param: [String : String]?) -> Self { | ||
headers = param | ||
return self | ||
} | ||
|
||
func build() -> Endpoint { | ||
.init(path: path, | ||
encoding: encoding, | ||
method: method, | ||
withAuth: withAuth, | ||
retries: retries, | ||
queryItems: queryItems, | ||
headers: headers) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// NetConfigBuilder.swift | ||
// NetNetNet | ||
// | ||
// Created by Carlos Cáceres González on 6/11/24. | ||
// | ||
|
||
@testable import NetNetNet | ||
|
||
final class NetConfigBuilder { | ||
private var scheme: String = "https" | ||
private var host: String = "somehost.com" | ||
private var clientId: String = "" | ||
private var clientSecret: String = "" | ||
private var oauthEndpoint: String = "" | ||
|
||
func scheme(_ param: String) -> Self { | ||
scheme = param | ||
return self | ||
} | ||
|
||
func host(_ param: String) -> Self { | ||
host = param | ||
return self | ||
} | ||
|
||
func clientId(_ param: String) -> Self { | ||
clientId = param | ||
return self | ||
} | ||
|
||
func clientSecret(_ param: String) -> Self { | ||
clientSecret = param | ||
return self | ||
} | ||
|
||
func oauthEndpoint(_ param: String) -> Self { | ||
oauthEndpoint = param | ||
return self | ||
} | ||
|
||
func build() -> NetConfig { | ||
.init(scheme: scheme, | ||
host: host, | ||
clientId: clientId, | ||
clientSecret: clientSecret, | ||
oauthEndpoint: oauthEndpoint) | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.