Skip to content

Commit

Permalink
Merge pull request #55 from outfoxx/task/deps
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
kdubb authored Nov 15, 2024
2 parents 2f804f0 + 7c91019 commit 3a4d018
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 42 deletions.
28 changes: 14 additions & 14 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
{
"object": {
"pins": [
{
"package": "AsyncObjects",
"repositoryURL": "https://github.com/SwiftyLab/AsyncObjects.git",
"state": {
"branch": null,
"revision": "93aacfba87d738ac94fb50c2a6768c43ec9d42eb",
"version": "2.1.0"
}
},
{
"package": "BigInt",
"repositoryURL": "https://github.com/attaswift/BigInt.git",
Expand All @@ -33,8 +24,8 @@
"repositoryURL": "https://github.com/outfoxx/PotentCodables.git",
"state": {
"branch": null,
"revision": "583f1b04b89e36742255d05ef1d2e5961485811d",
"version": "3.2.0"
"revision": "660e33e84e00b9bf07bd41dd99ff800600e435e7",
"version": "3.5.0"
}
},
{
Expand All @@ -46,6 +37,15 @@
"version": "2.1.1"
}
},
{
"package": "Semaphore",
"repositoryURL": "https://github.com/groue/Semaphore.git",
"state": {
"branch": null,
"revision": "2543679282aa6f6c8ecf2138acd613ed20790bc2",
"version": "0.1.0"
}
},
{
"package": "swift-collections",
"repositoryURL": "https://github.com/apple/swift-collections.git",
Expand Down Expand Up @@ -74,12 +74,12 @@
}
},
{
"package": "URITemplate",
"package": "ScreamURITemplate",
"repositoryURL": "https://github.com/SwiftScream/URITemplate.git",
"state": {
"branch": null,
"revision": "c36e52f4c10fe3cb86f4ba723bb2e69308ab5bbe",
"version": "2.1.0"
"revision": "3a6acca43ac7aa3f58474e6c8f686809b3660d6a",
"version": "4.0.0"
}
}
]
Expand Down
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/outfoxx/PotentCodables.git", .upToNextMinor(from: "3.2.0")),
.package(url: "https://github.com/outfoxx/PotentCodables.git", .upToNextMinor(from: "3.5.0")),
.package(url: "https://github.com/sharplet/Regex.git", .upToNextMinor(from: "2.1.0")),
.package(url: "https://github.com/SwiftScream/URITemplate.git", .upToNextMinor(from: "2.1.0")),
.package(url: "https://github.com/SwiftyLab/AsyncObjects.git", .upToNextMinor(from: "2.1.0"))
.package(url: "https://github.com/SwiftScream/URITemplate.git", .upToNextMinor(from: "4.0.0")),
.package(url: "https://github.com/groue/Semaphore.git", .upToNextMinor(from: "0.1.0"))
],
targets: [
.target(
name: "Sunday",
dependencies: [
"Regex",
"PotentCodables",
"URITemplate",
"AsyncObjects"
.product(name: "ScreamURITemplate", package: "uritemplate"),
.product(name: "Semaphore", package: "semaphore")
]
),
.target(
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sunday/NetworkRequestAdapters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import AsyncObjects
import Foundation
import Semaphore


/// Composing request adapter that applies another request adapter
Expand Down Expand Up @@ -110,7 +110,7 @@ open class RefreshingHeaderTokenAuthorizingAdapter: NetworkRequestAdapter {
}

public func adapt(requestFactory: NetworkRequestFactory, urlRequest: URLRequest) async throws -> URLRequest {
try await lock.wait()
await lock.wait()
defer { lock.signal() }

if shouldRefresh {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sunday/URI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import Foundation
import URITemplate
import ScreamURITemplate

public struct URI: Equatable, Hashable {

Expand Down
59 changes: 40 additions & 19 deletions Sources/Sunday/URITemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import Foundation
import URITemplate
import ScreamURITemplate

public extension URI {

Expand Down Expand Up @@ -89,32 +89,53 @@ public extension URI {

for variableName in impl.variableNames {

switch parameters[variableName] {
let value = switch parameters[variableName] {
case let value as VariableValue:
variables[variableName] = value
value
case .some(.some(let value)):
guard let converted = encoders.firstSupported(value: value) else {
if let pathValue = value as? PathEncodable {
variables[variableName] = pathValue.pathDescription
continue
}
else if let losslessValue = value as? LosslessStringConvertible {
variables[variableName] = losslessValue.description
continue
}
else if let rawRepValue = value as? any RawRepresentable {
variables[variableName] = String(describing: rawRepValue.rawValue)
continue
}
throw Error.unsupportedParameterType(name: variableName, type: type(of: value))
}
variables[variableName] = converted
value
case nil:
throw Error.missingParameterValue(name: variableName)
default:
throw Error.unsupportedParameterType(name: variableName, type: type(of: parameters[variableName]))
}

guard let converted = encoders.firstSupported(value: value) else {
if let dictValue = value as? [String: StringVariableValue] {
variables[variableName] = dictValue
continue
}
else if let arrayValue = value as? [StringVariableValue] {
variables[variableName] = arrayValue
continue
}
else if let kvPairsValue = value as? KeyValuePairs<String, StringVariableValue> {
variables[variableName] = kvPairsValue
continue
}
else if let stringValue = value as? StringVariableValue {
variables[variableName] = stringValue
continue
}
else if let varValue = value as? VariableValue {
variables[variableName] = varValue
continue
}
else if let pathValue = value as? PathEncodable {
variables[variableName] = pathValue.pathDescription
continue
}
else if let losslessValue = value as? LosslessStringConvertible {
variables[variableName] = losslessValue.description
continue
}
else if let rawRepValue = value as? any RawRepresentable {
variables[variableName] = String(describing: rawRepValue.rawValue)
continue
}
throw Error.unsupportedParameterType(name: variableName, type: type(of: value))
}
variables[variableName] = converted
}

let processedUrl = try impl.process(variables: variables)
Expand Down
2 changes: 1 addition & 1 deletion Tests/SundayTests/URITemplatesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

@testable import Sunday
import URITemplate
import ScreamURITemplate
import XCTest


Expand Down

0 comments on commit 3a4d018

Please sign in to comment.