Skip to content

Commit d57d457

Browse files
authored
Merge pull request #1 from tonkeeper/feature/add-custom-payload
Add custom_payload
2 parents c1d5a79 + 6d091d3 commit d57d457

File tree

3 files changed

+648
-2
lines changed

3 files changed

+648
-2
lines changed

Packages/ton-api/Sources/Generated/Client.swift

+107
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,57 @@ public struct Client: APIProtocol {
3636
)
3737
}
3838
private var converter: Converter { client.converter }
39+
/// Status
40+
///
41+
/// - Remark: HTTP `GET /v2/status`.
42+
/// - Remark: Generated from `#/paths//v2/status/get(status)`.
43+
public func status(_ input: Operations.status.Input) async throws -> Operations.status.Output {
44+
try await client.send(
45+
input: input,
46+
forOperation: Operations.status.id,
47+
serializer: { input in
48+
let path = try converter.renderedPath(template: "/v2/status", parameters: [])
49+
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .get)
50+
suppressMutabilityWarning(&request)
51+
converter.setAcceptHeader(in: &request.headerFields, contentTypes: input.headers.accept)
52+
return (request, nil)
53+
},
54+
deserializer: { response, responseBody in
55+
switch response.status.code {
56+
case 200:
57+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
58+
let body: Operations.status.Output.Ok.Body
59+
if try contentType == nil
60+
|| converter.isMatchingContentType(received: contentType, expectedRaw: "application/json")
61+
{
62+
body = try await converter.getResponseBodyAsJSON(
63+
Components.Schemas.ServiceStatus.self,
64+
from: responseBody,
65+
transforming: { value in .json(value) }
66+
)
67+
} else {
68+
throw converter.makeUnexpectedContentTypeError(contentType: contentType)
69+
}
70+
return .ok(.init(body: body))
71+
default:
72+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
73+
let body: Components.Responses._Error.Body
74+
if try contentType == nil
75+
|| converter.isMatchingContentType(received: contentType, expectedRaw: "application/json")
76+
{
77+
body = try await converter.getResponseBodyAsJSON(
78+
Components.Responses._Error.Body.jsonPayload.self,
79+
from: responseBody,
80+
transforming: { value in .json(value) }
81+
)
82+
} else {
83+
throw converter.makeUnexpectedContentTypeError(contentType: contentType)
84+
}
85+
return .`default`(statusCode: response.status.code, .init(body: body))
86+
}
87+
}
88+
)
89+
}
3990
/// Get blockchain block data
4091
///
4192
/// - Remark: HTTP `GET /v2/blockchain/blocks/{block_id}`.
@@ -3691,6 +3742,62 @@ public struct Client: APIProtocol {
36913742
}
36923743
)
36933744
}
3745+
/// Get jetton's custom payload and state init required for transfer
3746+
///
3747+
/// - Remark: HTTP `GET /v2/jettons/{jetton_id}/transfer/{account_id}/payload`.
3748+
/// - Remark: Generated from `#/paths//v2/jettons/{jetton_id}/transfer/{account_id}/payload/get(getJettonTransferPayload)`.
3749+
public func getJettonTransferPayload(_ input: Operations.getJettonTransferPayload.Input) async throws
3750+
-> Operations.getJettonTransferPayload.Output
3751+
{
3752+
try await client.send(
3753+
input: input,
3754+
forOperation: Operations.getJettonTransferPayload.id,
3755+
serializer: { input in
3756+
let path = try converter.renderedPath(
3757+
template: "/v2/jettons/{}/transfer/{}/payload",
3758+
parameters: [input.path.account_id, input.path.jetton_id]
3759+
)
3760+
var request: HTTPTypes.HTTPRequest = .init(soar_path: path, method: .get)
3761+
suppressMutabilityWarning(&request)
3762+
converter.setAcceptHeader(in: &request.headerFields, contentTypes: input.headers.accept)
3763+
return (request, nil)
3764+
},
3765+
deserializer: { response, responseBody in
3766+
switch response.status.code {
3767+
case 200:
3768+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
3769+
let body: Operations.getJettonTransferPayload.Output.Ok.Body
3770+
if try contentType == nil
3771+
|| converter.isMatchingContentType(received: contentType, expectedRaw: "application/json")
3772+
{
3773+
body = try await converter.getResponseBodyAsJSON(
3774+
Components.Schemas.JettonTransferPayload.self,
3775+
from: responseBody,
3776+
transforming: { value in .json(value) }
3777+
)
3778+
} else {
3779+
throw converter.makeUnexpectedContentTypeError(contentType: contentType)
3780+
}
3781+
return .ok(.init(body: body))
3782+
default:
3783+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
3784+
let body: Components.Responses._Error.Body
3785+
if try contentType == nil
3786+
|| converter.isMatchingContentType(received: contentType, expectedRaw: "application/json")
3787+
{
3788+
body = try await converter.getResponseBodyAsJSON(
3789+
Components.Responses._Error.Body.jsonPayload.self,
3790+
from: responseBody,
3791+
transforming: { value in .json(value) }
3792+
)
3793+
} else {
3794+
throw converter.makeUnexpectedContentTypeError(contentType: contentType)
3795+
}
3796+
return .`default`(statusCode: response.status.code, .init(body: body))
3797+
}
3798+
}
3799+
)
3800+
}
36943801
/// Get only jetton transfers in the event
36953802
///
36963803
/// - Remark: HTTP `GET /v2/events/{event_id}/jettons`.

0 commit comments

Comments
 (0)