<commit_before>import Foundation
import Moya

enum GitHub {
  case userProfile(String)
  case userRepositories(String)
}

extension GitHub: TargetType {

  var baseURL: URL { return URL(string: "https://api.github.com")! }

  var path: String {
    switch self {
    case .userProfile(let name):
      return "/users/\(name.urlEscaped)"
    case .userRepositories(let name):
      return "/users/\(name.urlEscaped)/repos"
    }
  }

  var method: Moya.Method {
    return .get
  }

  var parameters: [String: Any]? {
    switch self {
    case .userRepositories(_):
      return ["sort": "pushed"]
    default:
      return nil
    }
  }

  var parameterEncoding: ParameterEncoding {
    return URLEncoding.default
  }

  var task: Task {
    return .request
  }

  var validate: Bool {
    return false
  }
  
  var sampleData: Data {
    switch self {
    case .userProfile(let name):
      return "{\"login\": \"\(name)\", \"id\": 100}".data(using: String.Encoding.utf8)!
    case .userRepositories(_):
      return "[{\"name\": \"Repo Name\"}]".data(using: String.Encoding.utf8)!
    }
  }
}<commit_msg>added user repositories sample data to API<commit_after>import Foundation
import Moya

enum GitHub {
  case userProfile(String)
  case userRepositories(String)
}

extension GitHub: TargetType {

  var baseURL: URL { return URL(string: "https://api.github.com")! }

  var path: String {
    switch self {
    case .userProfile(let name):
      return "/users/\(name.urlEscaped)"
    case .userRepositories(let name):
      return "/users/\(name.urlEscaped)/repos"
    }
  }

  var method: Moya.Method {
    return .get
  }

  var parameters: [String: Any]? {
    switch self {
    case .userRepositories(_):
      return ["sort": "pushed"]
    default:
      return nil
    }
  }

  var parameterEncoding: ParameterEncoding {
    return URLEncoding.default
  }

  var task: Task {
    return .request
  }

  var validate: Bool {
    return false
  }

  var sampleData: Data {
    switch self {
    case .userProfile(let name):
      return "{\"login\": \"\(name)\", \"id\": 100}".data(using: String.Encoding.utf8)!
    case .userRepositories(_):
      return JSONReader.data(fromFile: "ivanbruel") ?? Data()
    }
  }
}
{'fraction_non_alphanumeric': 0.13573033707865167, 'fraction_numerical': 0.004044943820224719, 'mean_word_length': 2.728643216080402, 'pattern_counts': {'":': 7, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7044399', 'n_tokens_mistral': 753, 'n_tokens_neox': 711, 'n_words': 183}