-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6: Add POST nodes by address request, add Encoder
- Loading branch information
1 parent
0b98c3b
commit bb93a3b
Showing
10 changed files
with
158 additions
and
6 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...NCommunityCoreiOS/SOLARAPI/Providers/NodesProvider/Models/PostNodesByAddressRequest.swift
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,27 @@ | ||
// | ||
// PostNodesByAddressRequest.swift | ||
// SOLARAPI | ||
// | ||
// Created by Viktoriia Kostyleva on 30.09.2022. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct PostNodesByAddressRequest: Codable { | ||
let addresses: [String] | ||
let page: Int? | ||
|
||
public init(addresses: [String], page: Int?) { | ||
self.addresses = addresses | ||
self.page = page | ||
} | ||
} | ||
|
||
// MARK: - Codable implementation | ||
|
||
public extension PostNodesByAddressRequest { | ||
enum CodingKeys: String, CodingKey { | ||
case addresses = "blockchain_addresses" | ||
case page | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
SolardVPNCommunityCoreiOS/SOLARdVPNCommunityCoreiOS/Common/Utilities/Encoder.swift
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,34 @@ | ||
// | ||
// Encoder.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 03.10.2022. | ||
// | ||
|
||
import Foundation | ||
|
||
enum EncoderError: LocalizedError { | ||
case failToEncode | ||
|
||
var errorDescription: String? { | ||
switch self { | ||
case .failToEncode: | ||
return "Fail to encode" | ||
} | ||
} | ||
} | ||
|
||
enum Encoder { | ||
static func encode( | ||
model: Codable, | ||
continuation: CheckedContinuation<String, Error> | ||
) { | ||
do { | ||
let result = try JSONEncoder().encode(model) | ||
let string = String(decoding: result, as: UTF8.self) | ||
continuation.resume(returning: string) | ||
} catch { | ||
continuation.resume(throwing: EncoderError.failToEncode) | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...oreiOS/SOLARdVPNCommunityCoreiOS/Root/RouteCollections/Nodes/NodesByAddressPostBody.swift
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,13 @@ | ||
// | ||
// NodesByAddressPostBody.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 30.09.2022. | ||
// | ||
|
||
import Vapor | ||
|
||
struct NodesByAddressPostBody: Content { | ||
let blockchain_addresses: [String] | ||
let page: Int? | ||
} |
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