 //  Copyright (c) 2016. All rights reserved.
 //
 
+public protocol JSONBacking {
+	var json: [String: Any] { get }
+}
+
 /// Holds the result of a SOQL query
 /// See https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm
 public struct QueryResult {

	public let nextRecordsPath: String?
	
	init(json: [String: Any]) throws {
		guard let totalSize = json["totalSize"] as? Int, let isDone = json["done"] as? Bool, let records = json["records"] as? [[String: Any]] else {
			throw SalesforceError.jsonDeserializationFailure(elementName: nil, json: json)
		}
		self.totalSize = totalSize

	public let maximum: Int
	public let remaining: Int
	
	public init(name: String, json: [String: Int]) throws {
		guard let remaining = json["Remaining"], let maximum = json["Max"] else {
			throw SalesforceError.jsonDeserializationFailure(elementName: name, json: json)
		}
		self.name = name
		self.maximum = maximum
		self.remaining = remaining
