Add transaction endpoint

pull/2/head
Michael Scoff 7 years ago
parent 4f04894d5e
commit 8f1a18c654
  1. 4
      Trust/EtherClient/TrustClient/Models/RawTransaction.swift
  2. 14
      Trust/EtherClient/TrustClient/TrustClient.swift

@ -2,10 +2,6 @@
import Foundation
struct RawTransactionResponse: Decodable {
let docs: [RawTransaction]
}
struct RawTransaction: Decodable {
let hash: String
let blockNumber: Int

@ -4,7 +4,8 @@ import Foundation
import Moya
enum TrustService {
case transactions(address: String, startBlock: Int)
case getTransactions(address: String, startBlock: Int)
case getTransaction(ID: String)
}
extension TrustService: TargetType {
@ -13,21 +14,26 @@ extension TrustService: TargetType {
var path: String {
switch self {
case .transactions:
case .getTransactions:
return "/transactions"
case .getTransaction(let ID):
return "/transactions/\(ID)"
}
}
var method: Moya.Method {
switch self {
case .transactions: return .get
case .getTransactions: return .get
case .getTransaction: return .get
}
}
var task: Task {
switch self {
case .transactions(let address, let startBlock):
case .getTransactions(let address, let startBlock):
return .requestParameters(parameters: ["address": address, "startBlock": startBlock], encoding: URLEncoding())
case .getTransaction:
return .requestPlain
}
}

Loading…
Cancel
Save