Skip to content

Commit

Permalink
Merge CoinValue and TransactionValue into AppValue model
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev committed Oct 4, 2024
1 parent 133dd7f commit a837a87
Show file tree
Hide file tree
Showing 118 changed files with 803 additions and 868 deletions.
2 changes: 1 addition & 1 deletion UnstoppableWallet/TonConnectAPI/Generation/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "TonAPI",
platforms: [
.macOS(.v12), .iOS(.v13)
.macOS(.v12), .iOS(.v13),
],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-generator", .upToNextMinor(from: "0.3.0")),
Expand Down
9 changes: 4 additions & 5 deletions UnstoppableWallet/TonConnectAPI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import PackageDescription
let package = Package(
name: "TonConnectAPI",
platforms: [
.macOS(.v12), .iOS(.v13)
.macOS(.v12), .iOS(.v13),
],
products: [
.library(name: "TonConnectAPI", targets: ["TonConnectAPI"])
.library(name: "TonConnectAPI", targets: ["TonConnectAPI"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-openapi-runtime", .upToNextMinor(from: "0.3.0")),
Expand All @@ -20,10 +20,9 @@ let package = Package(
.product(
name: "OpenAPIRuntime",
package: "swift-openapi-runtime"
)
),
],
path: "Sources",
sources: ["TonConnectAPI"]
)
sources: ["TonConnectAPI"]),
]
)
19 changes: 11 additions & 8 deletions UnstoppableWallet/TonConnectAPI/Sources/TonConnectAPI/Client.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Generated by swift-openapi-generator, do not modify.
@_spi(Generated) import OpenAPIRuntime
#if os(Linux)
@preconcurrency import struct Foundation.URL
@preconcurrency import struct Foundation.Data
@preconcurrency import struct Foundation.Date
@preconcurrency import struct Foundation.Data
@preconcurrency import struct Foundation.Date
@preconcurrency import struct Foundation.URL
#else
import struct Foundation.URL
import struct Foundation.Data
import struct Foundation.Date
import struct Foundation.Data
import struct Foundation.Date
import struct Foundation.URL
#endif
import HTTPTypes

public struct Client: APIProtocol {
/// The underlying HTTP client.
private let client: UniversalClient
Expand All @@ -27,13 +28,14 @@ public struct Client: APIProtocol {
transport: any ClientTransport,
middlewares: [any ClientMiddleware] = []
) {
self.client = .init(
client = .init(
serverURL: serverURL,
configuration: configuration,
transport: transport,
middlewares: middlewares
)
}

private var converter: Converter { client.converter }
/// - Remark: HTTP `GET /events`.
/// - Remark: Generated from `#/paths//events/get(events)`.
Expand Down Expand Up @@ -84,6 +86,7 @@ public struct Client: APIProtocol {
}
)
}

/// - Remark: HTTP `POST /message`.
/// - Remark: Generated from `#/paths//message/post(message)`.
public func message(_ input: Operations.message.Input) async throws -> Operations.message.Output {
Expand Down Expand Up @@ -158,7 +161,7 @@ public struct Client: APIProtocol {
} else {
throw converter.makeUnexpectedContentTypeError(contentType: contentType)
}
return .`default`(statusCode: response.status.code, .init(body: body))
return .default(statusCode: response.status.code, .init(body: body))
}
}
)
Expand Down
47 changes: 37 additions & 10 deletions UnstoppableWallet/TonConnectAPI/Sources/TonConnectAPI/Types.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Generated by swift-openapi-generator, do not modify.
@_spi(Generated) import OpenAPIRuntime
#if os(Linux)
@preconcurrency import struct Foundation.URL
@preconcurrency import struct Foundation.Data
@preconcurrency import struct Foundation.Date
@preconcurrency import struct Foundation.Data
@preconcurrency import struct Foundation.Date
@preconcurrency import struct Foundation.URL
#else
import struct Foundation.URL
import struct Foundation.Data
import struct Foundation.Date
import struct Foundation.Data
import struct Foundation.Date
import struct Foundation.URL
#endif
/// A type that performs HTTP operations defined by the OpenAPI document.
public protocol APIProtocol: Sendable {
Expand All @@ -18,29 +18,32 @@ public protocol APIProtocol: Sendable {
/// - Remark: Generated from `#/paths//message/post(message)`.
func message(_ input: Operations.message.Input) async throws -> Operations.message.Output
}

/// Convenience overloads for operation inputs.
extension APIProtocol {
public extension APIProtocol {
/// - Remark: HTTP `GET /events`.
/// - Remark: Generated from `#/paths//events/get(events)`.
public func events(query: Operations.events.Input.Query, headers: Operations.events.Input.Headers = .init())
func events(query: Operations.events.Input.Query, headers: Operations.events.Input.Headers = .init())
async throws -> Operations.events.Output
{ try await events(Operations.events.Input(query: query, headers: headers)) }
/// - Remark: HTTP `POST /message`.
/// - Remark: Generated from `#/paths//message/post(message)`.
public func message(
func message(
query: Operations.message.Input.Query,
headers: Operations.message.Input.Headers = .init(),
body: Operations.message.Input.Body
) async throws -> Operations.message.Output {
try await message(Operations.message.Input(query: query, headers: headers, body: body))
}
}

/// Server URLs defined in the OpenAPI document.
public enum Servers {
public static func server1() throws -> Foundation.URL {
try Foundation.URL(validatingOpenAPIServerURL: "https://bridge.tonapi.io/bridge")
}
}

/// Types generated from the components section of the OpenAPI document.
public enum Components {
/// Types generated from the `#/components/schemas` section of the OpenAPI document.
Expand All @@ -52,6 +55,7 @@ public enum Components {
/// - Remark: Generated from `#/components/parameters/toParameter`.
public typealias toParameter = [Swift.String]
}

/// Types generated from the `#/components/requestBodies` section of the OpenAPI document.
public enum RequestBodies {}
/// Types generated from the `#/components/responses` section of the OpenAPI document.
Expand All @@ -74,11 +78,13 @@ public enum Components {
self.message = message
self.statusCode = statusCode
}

public enum CodingKeys: String, CodingKey {
case message
case statusCode
}
}

/// - Remark: Generated from `#/components/responses/Response/content/application\/json`.
case json(Components.Responses.Response.Body.jsonPayload)
/// The associated value of the enum case if `self` is `.json`.
Expand All @@ -93,6 +99,7 @@ public enum Components {
}
}
}

/// Received HTTP response body
public var body: Components.Responses.Response.Body
/// Creates a new `Response`.
Expand All @@ -102,9 +109,11 @@ public enum Components {
public init(body: Components.Responses.Response.Body) { self.body = body }
}
}

/// Types generated from the `#/components/headers` section of the OpenAPI document.
public enum Headers {}
}

/// API operations, with input and output types, generated from `#/paths` in the OpenAPI document.
public enum Operations {
/// - Remark: HTTP `GET /events`.
Expand All @@ -128,6 +137,7 @@ public enum Operations {
self.last_event_id = last_event_id
}
}

public var query: Operations.events.Input.Query
/// - Remark: Generated from `#/paths/events/GET/header`.
public struct Headers: Sendable, Hashable {
Expand All @@ -141,6 +151,7 @@ public enum Operations {
.defaultValues()
) { self.accept = accept }
}

public var headers: Operations.events.Input.Headers
/// Creates a new `Input`.
///
Expand All @@ -152,6 +163,7 @@ public enum Operations {
self.headers = headers
}
}

@frozen public enum Output: Sendable, Hashable {
public struct Ok: Sendable, Hashable {
/// - Remark: Generated from `#/paths/events/GET/responses/200/content`.
Expand All @@ -170,6 +182,7 @@ public enum Operations {
}
}
}

/// Received HTTP response body
public var body: Operations.events.Output.Ok.Body
/// Creates a new `Ok`.
Expand All @@ -178,6 +191,7 @@ public enum Operations {
/// - body: Received HTTP response body
public init(body: Operations.events.Output.Ok.Body) { self.body = body }
}

/// OK
///
/// - Remark: Generated from `#/paths//events/get(events)/responses/200`.
Expand All @@ -196,11 +210,13 @@ public enum Operations {
}
}
}

/// Undocumented response.
///
/// A response with a code that is not documented in the OpenAPI document.
case undocumented(statusCode: Swift.Int, OpenAPIRuntime.UndocumentedPayload)
}

@frozen public enum AcceptableContentType: AcceptableProtocol {
case text_event_hyphen_stream
case other(Swift.String)
Expand All @@ -210,15 +226,18 @@ public enum Operations {
default: self = .other(rawValue)
}
}

public var rawValue: Swift.String {
switch self {
case let .other(string): return string
case .text_event_hyphen_stream: return "text/event-stream"
}
}

public static var allCases: [Self] { [.text_event_hyphen_stream] }
}
}

/// - Remark: HTTP `POST /message`.
/// - Remark: Generated from `#/paths//message/post(message)`.
public enum message {
Expand All @@ -244,6 +263,7 @@ public enum Operations {
self.ttl = ttl
}
}

public var query: Operations.message.Input.Query
/// - Remark: Generated from `#/paths/message/POST/header`.
public struct Headers: Sendable, Hashable {
Expand All @@ -257,12 +277,14 @@ public enum Operations {
.defaultValues()
) { self.accept = accept }
}

public var headers: Operations.message.Input.Headers
/// - Remark: Generated from `#/paths/message/POST/requestBody`.
@frozen public enum Body: Sendable, Hashable {
/// - Remark: Generated from `#/paths/message/POST/requestBody/content/text\/plain`.
case plainText(OpenAPIRuntime.HTTPBody)
}

public var body: Operations.message.Input.Body
/// Creates a new `Input`.
///
Expand All @@ -280,6 +302,7 @@ public enum Operations {
self.body = body
}
}

@frozen public enum Output: Sendable, Hashable {
/// OK
///
Expand All @@ -299,6 +322,7 @@ public enum Operations {
}
}
}

/// OK
///
/// - Remark: Generated from `#/paths//message/post(message)/responses/default`.
Expand All @@ -312,12 +336,13 @@ public enum Operations {
public var `default`: Components.Responses.Response {
get throws {
switch self {
case let .`default`(_, response): return response
case let .default(_, response): return response
default: try throwUnexpectedResponseStatus(expectedStatus: "default", response: self)
}
}
}
}

@frozen public enum AcceptableContentType: AcceptableProtocol {
case json
case other(Swift.String)
Expand All @@ -327,12 +352,14 @@ public enum Operations {
default: self = .other(rawValue)
}
}

public var rawValue: Swift.String {
switch self {
case let .other(string): return string
case .json: return "application/json"
}
}

public static var allCases: [Self] { [.json] }
}
}
Expand Down
Loading

0 comments on commit a837a87

Please sign in to comment.