Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
rename id -> ID everwhere
Browse files Browse the repository at this point in the history
to avoid confusion when bridging to objective-c

Signed-off-by: Marco Musella <[email protected]>
  • Loading branch information
dev-mush committed Mar 1, 2017
1 parent 8d2d8ec commit 6987454
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Example/Tests/JRPCClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import OHHTTPStubs

class JRPCClientTests: XCTestCase {

let mockJRPCRequest = JRPCRequest(id: "1010", method: "mockMethod", params: ["mock":"param"])
let mockJRPCRequest = JRPCRequest(ID: "1010", method: "mockMethod", params: ["mock":"param"])

let mockJRPCResponse = "{\"jsonrpc\":\"2.0\", \"id\":\"1010\",\"result\":{\"mock\":\"value\"},\"error\": null}"

Expand Down Expand Up @@ -113,7 +113,7 @@ class JRPCClientTests: XCTestCase {
}

if let resp = jrpcresponse,
resp.id != "1010",
resp.ID != "1010",
(resp.result as? Dictionary<String,String>)?["mock"] != "value" {
XCTFail("received response is different than expected: \(resp)")
}
Expand Down
2 changes: 1 addition & 1 deletion jrpc/Classes/JRPCClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ extension JRPCRequest: JRPCParsable{}
ID = "\(rawID)"
}

return (JRPCResponse(id: ID, result: dictionary["result"], error: jrpcError), nil)
return (JRPCResponse(ID: ID, result: dictionary["result"], error: jrpcError), nil)
}

// parses a dictionary into a JRPCResponseError, returns an error if something goes wrong.
Expand Down
20 changes: 10 additions & 10 deletions jrpc/Classes/JRPCObjects.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Foundation
@objc public class JRPCRequest: NSObject{

/// the ID of the request object
public let id: String
public let ID: String
/// the remote method to call on the JSONRPC server
public let method: String
/// the parameters for the remote method
Expand All @@ -30,17 +30,17 @@ import Foundation
parameters passing method.

- Parameters:
- id: the id of the JSONRPC request
- ID: the id of the JSONRPC request
- method: the remote method to call
- params: the dictionary or array of named parameters, depending on the chosen param input method

- Returns: a new JRPCRequest object with named parameters.
*/
public init(id:String, method: String, params: Any?) {
assert(!id.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty)
public init(ID:String, method: String, params: Any?) {
assert(!ID.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty)
assert(!method.trimmingCharacters(in: CharacterSet.whitespaces).isEmpty)

self.id = id
self.ID = ID
self.method = method
self.params = params
super.init()
Expand All @@ -52,7 +52,7 @@ import Foundation

var jsonData: Data

let raw = ["jsonrpc":"2.0", "id": self.id, "method": self.method, "params": self.params]
let raw = ["jsonrpc":"2.0", "id": self.ID, "method": self.method, "params": self.params]
do{
jsonData = try JSONSerialization.data(withJSONObject: raw, options: JSONSerialization.WritingOptions.prettyPrinted)
} catch{
Expand Down Expand Up @@ -98,7 +98,7 @@ import Foundation
*/
@objc public class JRPCResponse: NSObject{
/// the ID of the JSONRPC response
public let id: String?
public let ID: String?
/// the result of the remote method
public let result: Any?
/// the error
Expand All @@ -107,12 +107,12 @@ import Foundation
/** Initializes and returns a JRPCResponseError

- Parameters:
- id: the id of the response, nil if the response is errored
- ID: the id of the response, nil if the response is errored
- result: the message of the remote procedure, nil if the response is errored
- error: the error of the remote procedure, nil if the reponse is successful
*/
public init(id: String?, result: Any?, error: JRPCResponseError?){
self.id = id
public init(ID: String?, result: Any?, error: JRPCResponseError?){
self.ID = ID
self.result = result
self.error = error
super.init()
Expand Down

0 comments on commit 6987454

Please sign in to comment.