import Foundation
import Argo
import Result

public protocol Request {
  typealias ResponseType
  func build() -> NSURLRequest
  func parse(j: JSON) -> Result<ResponseType, NSError>
}

import Foundation
import Argo
import Result

public protocol Request {
  typealias ResponseType
  func build() -> NSURLRequest
  func parse(j: JSON) -> Result<ResponseType, NSError>
}

extension Request where ResponseType: Decodable, ResponseType.DecodedType == ResponseType {
  func parse(j: JSON) -> Result<ResponseType, NSError> {
    return .fromDecoded(ResponseType.decode(j))
  }
}

Add default implementation of parse for Decodable
Add default implementation of parse for Decodable

If our `ResponseType` is already `Decodable`, we can simplify things and
offer a default implementation of `parse`. This should reduce the times
where we just need to do this manually, while still letting us override
the default implementation if we need to do a more complex parsing
operation (like pulling out root keys, etc)
