//
// ProfilesAPI.swift
//
// Generated by swagger-codegen
// https://github.com/swagger-api/swagger-codegen
//

import Foundation
import Alamofire


open class ProfilesAPI {
    /**
     Подтверждение адреса электронной почты

     - parameter email: (query) Адрес электронной почты 
     - parameter confirm: (query)  (optional)
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func confirmEmail(email: String, confirm: Bool? = nil, completion: @escaping ((_ data: StoryProfile?,_ error: Error?) -> Void)) {
        confirmEmailWithRequestBuilder(email: email, confirm: confirm).execute { (response, error) -> Void in
            completion(response?.body, error)
        }
    }


    /**
     Подтверждение адреса электронной почты
     - PUT /Profiles/confirmemail

     - examples: [{contentType=application/json, example={
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
}}]
     - parameter email: (query) Адрес электронной почты 
     - parameter confirm: (query)  (optional)

     - returns: RequestBuilder<StoryProfile> 
     */
    open class func confirmEmailWithRequestBuilder(email: String, confirm: Bool? = nil) -> RequestBuilder<StoryProfile> {
        let path = "/Profiles/confirmemail"
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil
        var url = URLComponents(string: URLString)
        url?.queryItems = APIHelper.mapValuesToQueryItems([
                        "email": email, 
                        "confirm": confirm
        ])

        let requestBuilder: RequestBuilder<StoryProfile>.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
    }

    /**
     Подтверждение номера мобильного телефона

     - parameter phone: (query) Номер мобильного телефона 
     - parameter confirm: (query)  (optional)
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func confirmPhone(phone: String, confirm: Bool? = nil, completion: @escaping ((_ data: StoryProfile?,_ error: Error?) -> Void)) {
        confirmPhoneWithRequestBuilder(phone: phone, confirm: confirm).execute { (response, error) -> Void in
            completion(response?.body, error)
        }
    }


    /**
     Подтверждение номера мобильного телефона
     - PUT /Profiles/confirmphone

     - examples: [{contentType=application/json, example={
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
}}]
     - parameter phone: (query) Номер мобильного телефона 
     - parameter confirm: (query)  (optional)

     - returns: RequestBuilder<StoryProfile> 
     */
    open class func confirmPhoneWithRequestBuilder(phone: String, confirm: Bool? = nil) -> RequestBuilder<StoryProfile> {
        let path = "/Profiles/confirmphone"
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil
        var url = URLComponents(string: URLString)
        url?.queryItems = APIHelper.mapValuesToQueryItems([
                        "phone": phone, 
                        "confirm": confirm
        ])

        let requestBuilder: RequestBuilder<StoryProfile>.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
    }

    /**
     Создание профиля

     - parameter body: (body)  (optional)
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func createProfile(body: StoryProfileDTO? = nil, completion: @escaping ((_ data: StoryProfile?,_ error: Error?) -> Void)) {
        createProfileWithRequestBuilder(body: body).execute { (response, error) -> Void in
            completion(response?.body, error)
        }
    }


    /**
     Создание профиля
     - POST /Profiles

     - examples: [{contentType=application/json, example={
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
}}]
     - parameter body: (body)  (optional)

     - returns: RequestBuilder<StoryProfile> 
     */
    open class func createProfileWithRequestBuilder(body: StoryProfileDTO? = nil) -> RequestBuilder<StoryProfile> {
        let path = "/Profiles"
        let URLString = SwaggerClientAPI.basePath + path
        let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)

        let url = URLComponents(string: URLString)

        let requestBuilder: RequestBuilder<StoryProfile>.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
    }

    /**
     Удаление профиля

     - parameter _id: (path) Уникальный идентификатор в формате StoryId 
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func deleteProfileById(_id: String, completion: @escaping ((_ data: StoryProfile?,_ error: Error?) -> Void)) {
        deleteProfileByIdWithRequestBuilder(_id: _id).execute { (response, error) -> Void in
            completion(response?.body, error)
        }
    }


    /**
     Удаление профиля
     - DELETE /Profiles/{id}

     - examples: [{contentType=application/json, example={
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
}}]
     - parameter _id: (path) Уникальный идентификатор в формате StoryId 

     - returns: RequestBuilder<StoryProfile> 
     */
    open class func deleteProfileByIdWithRequestBuilder(_id: String) -> RequestBuilder<StoryProfile> {
        var path = "/Profiles/{id}"
        let _idPreEscape = "\(_id)"
        let _idPostEscape = _idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
        path = path.replacingOccurrences(of: "{id}", with: _idPostEscape, options: .literal, range: nil)
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil

        let url = URLComponents(string: URLString)

        let requestBuilder: RequestBuilder<StoryProfile>.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
    }

    /**
     Получение профиля по идентификатору

     - parameter _id: (path) Уникальный идентификатор в формате StoryId 
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func getProfileById(_id: String, completion: @escaping ((_ data: StoryProfile?,_ error: Error?) -> Void)) {
        getProfileByIdWithRequestBuilder(_id: _id).execute { (response, error) -> Void in
            completion(response?.body, error)
        }
    }


    /**
     Получение профиля по идентификатору
     - GET /Profiles/{id}

     - examples: [{contentType=application/json, example={
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
}}]
     - parameter _id: (path) Уникальный идентификатор в формате StoryId 

     - returns: RequestBuilder<StoryProfile> 
     */
    open class func getProfileByIdWithRequestBuilder(_id: String) -> RequestBuilder<StoryProfile> {
        var path = "/Profiles/{id}"
        let _idPreEscape = "\(_id)"
        let _idPostEscape = _idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
        path = path.replacingOccurrences(of: "{id}", with: _idPostEscape, options: .literal, range: nil)
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil

        let url = URLComponents(string: URLString)

        let requestBuilder: RequestBuilder<StoryProfile>.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
    }

    /**
     Профили по списку идентификаторов

     - parameter ids: (query)  (optional)
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func getProfilesByIds(ids: [String]? = nil, completion: @escaping ((_ data: [StoryProfile]?,_ error: Error?) -> Void)) {
        getProfilesByIdsWithRequestBuilder(ids: ids).execute { (response, error) -> Void in
            completion(response?.body, error)
        }
    }


    /**
     Профили по списку идентификаторов
     - GET /Profiles/package

     - examples: [{contentType=application/json, example=[ {
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
}, {
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
} ]}]
     - parameter ids: (query)  (optional)

     - returns: RequestBuilder<[StoryProfile]> 
     */
    open class func getProfilesByIdsWithRequestBuilder(ids: [String]? = nil) -> RequestBuilder<[StoryProfile]> {
        let path = "/Profiles/package"
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil
        var url = URLComponents(string: URLString)
        url?.queryItems = APIHelper.mapValuesToQueryItems([
                        "ids": ids
        ])

        let requestBuilder: RequestBuilder<[StoryProfile]>.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
    }

    /**
     Список профилей

     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func listProfiles(completion: @escaping ((_ data: [StoryProfile]?,_ error: Error?) -> Void)) {
        listProfilesWithRequestBuilder().execute { (response, error) -> Void in
            completion(response?.body, error)
        }
    }


    /**
     Список профилей
     - GET /Profiles

     - examples: [{contentType=application/json, example=[ {
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
}, {
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
} ]}]

     - returns: RequestBuilder<[StoryProfile]> 
     */
    open class func listProfilesWithRequestBuilder() -> RequestBuilder<[StoryProfile]> {
        let path = "/Profiles"
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil

        let url = URLComponents(string: URLString)

        let requestBuilder: RequestBuilder<[StoryProfile]>.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
    }

    /**
     Получение пользователя по login

     - parameter login: (query)  (optional)
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func profileExists(login: String? = nil, completion: @escaping ((_ data: StoryProfile?,_ error: Error?) -> Void)) {
        profileExistsWithRequestBuilder(login: login).execute { (response, error) -> Void in
            completion(response?.body, error)
        }
    }


    /**
     Получение пользователя по login
     - GET /Profiles/exists

     - examples: [{contentType=application/json, example={
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
}}]
     - parameter login: (query)  (optional)

     - returns: RequestBuilder<StoryProfile> 
     */
    open class func profileExistsWithRequestBuilder(login: String? = nil) -> RequestBuilder<StoryProfile> {
        let path = "/Profiles/exists"
        let URLString = SwaggerClientAPI.basePath + path
        let parameters: [String:Any]? = nil
        var url = URLComponents(string: URLString)
        url?.queryItems = APIHelper.mapValuesToQueryItems([
                        "login": login
        ])

        let requestBuilder: RequestBuilder<StoryProfile>.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
    }

    /**
     Присвоение нового пароля

     - parameter _id: (path) Уникальный идентификатор в формате StoryId 
     - parameter body: (body)  (optional)
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func setPassword(_id: String, body: SetPasswordViewModel? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
        setPasswordWithRequestBuilder(_id: _id, body: body).execute { (response, error) -> Void in
            if error == nil {
                completion((), error)
            } else {
                completion(nil, error)
            }
        }
    }


    /**
     Присвоение нового пароля
     - PUT /Profiles/{id}/setpassword

     - parameter _id: (path) Уникальный идентификатор в формате StoryId 
     - parameter body: (body)  (optional)

     - returns: RequestBuilder<Void> 
     */
    open class func setPasswordWithRequestBuilder(_id: String, body: SetPasswordViewModel? = nil) -> RequestBuilder<Void> {
        var path = "/Profiles/{id}/setpassword"
        let _idPreEscape = "\(_id)"
        let _idPostEscape = _idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
        path = path.replacingOccurrences(of: "{id}", with: _idPostEscape, options: .literal, range: nil)
        let URLString = SwaggerClientAPI.basePath + path
        let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)

        let url = URLComponents(string: URLString)

        let requestBuilder: RequestBuilder<Void>.Type = SwaggerClientAPI.requestBuilderFactory.getNonDecodableBuilder()

        return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
    }

    /**
     Обновление профиля

     - parameter _id: (path) Уникальный идентификатор в формате StoryId 
     - parameter body: (body)  (optional)
     - parameter completion: completion handler to receive the data and the error objects
     */
    open class func updateProfile(_id: String, body: StoryProfileDTO? = nil, completion: @escaping ((_ data: StoryProfile?,_ error: Error?) -> Void)) {
        updateProfileWithRequestBuilder(_id: _id, body: body).execute { (response, error) -> Void in
            completion(response?.body, error)
        }
    }


    /**
     Обновление профиля
     - PUT /Profiles/{id}

     - examples: [{contentType=application/json, example={
  "createdAt" : "2000-01-23T04:56:07.000+00:00",
  "emailVerified" : true,
  "createdBy" : "createdBy",
  "phone" : "phone",
  "modifiedAt" : "2000-01-23T04:56:07.000+00:00",
  "phoneVerified" : true,
  "modifiedBy" : "modifiedBy",
  "id" : "id",
  "email" : "email",
  "username" : "username"
}}]
     - parameter _id: (path) Уникальный идентификатор в формате StoryId 
     - parameter body: (body)  (optional)

     - returns: RequestBuilder<StoryProfile> 
     */
    open class func updateProfileWithRequestBuilder(_id: String, body: StoryProfileDTO? = nil) -> RequestBuilder<StoryProfile> {
        var path = "/Profiles/{id}"
        let _idPreEscape = "\(_id)"
        let _idPostEscape = _idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
        path = path.replacingOccurrences(of: "{id}", with: _idPostEscape, options: .literal, range: nil)
        let URLString = SwaggerClientAPI.basePath + path
        let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)

        let url = URLComponents(string: URLString)

        let requestBuilder: RequestBuilder<StoryProfile>.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
    }

}
