//
//  Client_Genres.swift
//  MDBSwiftWrapper
//
//  Created by George Kye on 2016-02-12.
//  Copyright © 2016 George Kye. All rights reserved.
//

import Foundation

extension Client{  
  static func Genres(listType: String, language: String?, genreId: Int, page: Double?, include_all_movies: Bool?, include_adult: Bool?, movieList: Bool?, completion: @escaping (ClientReturn) -> ()) -> (){
    var parameters: [String : AnyObject] = [:]
    var url = "";
    if(movieList == false || movieList == nil){
      url = TMDBConfig.apiUrl + "/genre/" + listType + "/list";
    }else{
      url = TMDBConfig.apiUrl + "/genre/" + String(genreId) + "/movies";
    }
    
    if(language != nil){
      parameters["language"] = language as AnyObject?
    }
    
    if(page != nil){
      parameters["page"] = page as AnyObject?
    }
    if(include_all_movies != nil){
      parameters["include_all_movies"] = include_all_movies as AnyObject?
    }
    if(include_adult != nil){
      parameters["include_adult"] = include_adult as AnyObject?
    }
    
    networkRequest(url: url, parameters: parameters, completion: {
      apiReturn in
      completion(apiReturn)
    })
  }
  
}
