//
//  RPCRequest.swift
//  Astro
//
//  Created by Mark Sandstrom on 4/23/15.
//  Copyright (c) 2015 Mobify Research & Development Inc. All rights reserved.
//

import Foundation

public class RPCRequest: RPCMessage {
    var method: String {
        return payload["method"]! as! String
    }

    var params: JSONObject {
        return payload["params"] as! JSONObject
    }

    init(to: MessageAddress, from: MessageAddress, id: RPCMessageID, method: String, params: JSONObject) {
        super.init(to: to, from: from, id: id, payload: ["method": method, "params": params])
    }

    func createResponse(_ rpcMethodResult: RPCMethodResult) -> RPCResponse {
        return RPCResponse(to: self.from, from: self.to, id: self.id, rpcMethodResult: rpcMethodResult)
    }
}
