/*
 * Copyright (c) 2010-2022 Belledonne Communications SARL.
 *
 * This file is part of Liblinphone 
 * (see https://gitlab.linphone.org/BC/public/liblinphone).
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif // _MSC_VER

#ifndef _ACCOUNT_MANAGER_SERVICES_HH
#define _ACCOUNT_MANAGER_SERVICES_HH

#include <string>
#include "object.hh"




struct _LinphoneAccountManagerServices;


namespace linphone {

	class AccountManagerServicesRequest;
	class Address;
	class AccountDevice;

	/**
	 * @brief Creates and manage SIP user accounts remotely, using the REST API of the
	 * Flexisip Account Manager. 
	 *
	 * @see https://gitlab.linphone.org/BC/public/flexisip-account-manager 
	 */
	class AccountManagerServices: public Object {
	
		public:

			LINPHONECXX_PUBLIC AccountManagerServices(void *ptr, bool takeRef=true);
			LINPHONECXX_PUBLIC _LinphoneAccountManagerServices *cPtr() {return (_LinphoneAccountManagerServices *)mPrivPtr;}

	
		public:
			
		
			/**
			 * @brief Gets the configurer preferred language, if set. 
			 *
			 * @return the language previously set, if any (otherwise nullptr).    
			 */
			LINPHONECXX_PUBLIC std::string getLanguage() const;
			
			/**
			 * @brief Sets the preferred language to get error messages from account manager
			 * (if supported, otherwise will be english). 
			 *
			 * @param language The language (en, fr, etc...) you'd like to have error messages
			 * in (if possible).    
			 */
			LINPHONECXX_PUBLIC void setLanguage(const std::string & language);
			
			/**
			 * @brief Requests to delete a device from the list of currently known devices. 
			 *
			 * @param sipIdentity the SIP identity URI that identifies your account for which
			 * you want the devices list.    
			 * @param device the @ref AccountDevice to delete.    
			 * @return the @ref AccountManagerServicesRequest request object.    
			 */
			LINPHONECXX_PUBLIC std::shared_ptr<linphone::AccountManagerServicesRequest> createDeleteDeviceRequest(const std::shared_ptr<const linphone::Address> & sipIdentity, const std::shared_ptr<const linphone::AccountDevice> & device);
			
			/**
			 * @brief Requests a an account creation request token that once validated using
			 * the URL returned by this method upon success, will allow you to call
			 * createGetAccountCreationTokenFromRequestTokenRequest() to obtain a valid
			 * account creation token. 
			 *
			 * Once the account creation token is obtained, you can call
			 * createNewAccountUsingTokenRequest(). 
			 * @return the @ref AccountManagerServicesRequest request object.    
			 */
			LINPHONECXX_PUBLIC std::shared_ptr<linphone::AccountManagerServicesRequest> createGetAccountCreationRequestTokenRequest();
			
			/**
			 * @brief Converts an account creation request token obtained by
			 * linphone_account_manager_services_request_account_creation_request_token to an
			 * account creation token. 
			 *
			 * The obtained token can be used to call createNewAccountUsingTokenRequest(). 
			 * @param requestToken the token obtained previously and validated using your web
			 * browser.    
			 * @return the @ref AccountManagerServicesRequest request object.    
			 */
			LINPHONECXX_PUBLIC std::shared_ptr<linphone::AccountManagerServicesRequest> createGetAccountCreationTokenFromRequestTokenRequest(const std::string & requestToken);
			
			/**
			 * @brief Requests the list of devices currently known. 
			 *
			 * @param sipIdentity the SIP identity URI that identifies your account for which
			 * you want the devices list.    
			 * @return the @ref AccountManagerServicesRequest request object.    
			 */
			LINPHONECXX_PUBLIC std::shared_ptr<linphone::AccountManagerServicesRequest> createGetDevicesListRequest(const std::shared_ptr<const linphone::Address> & sipIdentity);
			
			/**
			 * @brief Validates the link between an email address and an account using a code
			 * received by email after calling createSendEmailLinkingCodeByEmailRequest(). 
			 *
			 * @param sipIdentity the SIP identity URI that identifies the account to which
			 * you want to link the email address to.    
			 * @param code the code received by email.    
			 * @return the @ref AccountManagerServicesRequest request object.    
			 */
			LINPHONECXX_PUBLIC std::shared_ptr<linphone::AccountManagerServicesRequest> createLinkEmailToAccountUsingCodeRequest(const std::shared_ptr<const linphone::Address> & sipIdentity, const std::string & code);
			
			/**
			 * @brief Validates the link between a phone number and an account using a code
			 * received by SMS after calling createSendPhoneNumberLinkingCodeBySmsRequest(). 
			 *
			 * @param sipIdentity the SIP identity URI that identifies the account to which
			 * you want to link the phone number to.    
			 * @param code the code received by SMS.    
			 * @return the @ref AccountManagerServicesRequest request object.    
			 */
			LINPHONECXX_PUBLIC std::shared_ptr<linphone::AccountManagerServicesRequest> createLinkPhoneNumberToAccountUsingCodeRequest(const std::shared_ptr<const linphone::Address> & sipIdentity, const std::string & code);
			
			/**
			 * @brief Creates an account using an account creation token, for example obtained
			 * using createSendAccountCreationTokenByPushRequest(). 
			 *
			 * @param username the username of the newly created account.    
			 * @param password the password to use for the newly created account.    
			 * @param algorithm the algorithm to use to hash the password (must be either MD5
			 * or SHA-256).    
			 * @param token the account creation token obtained previously.    
			 * @return the @ref AccountManagerServicesRequest request object.    
			 */
			LINPHONECXX_PUBLIC std::shared_ptr<linphone::AccountManagerServicesRequest> createNewAccountUsingTokenRequest(const std::string & username, const std::string & password, const std::string & algorithm, const std::string & token);
			
			/**
			 * @brief Requests a push notification to be sent to device, containing a valid
			 * account creation token. 
			 *
			 * Provider, param & prid can be obtained from Core::getPushNotificationConfig(),
			 * but on iOS may need some modifications (depending on debug mode for example).
			 * Once the token is obtained, you can call createNewAccountUsingTokenRequest(). 
			 * @param pnProvider The provider, for example "apns.dev".    
			 * @param pnParam The parameters, for example
			 * "ABCD1234.org.linphone.phone.remote".    
			 * @param pnPrid The prid, also known as push token.    
			 * @return the @ref AccountManagerServicesRequest request object.    
			 */
			LINPHONECXX_PUBLIC std::shared_ptr<linphone::AccountManagerServicesRequest> createSendAccountCreationTokenByPushRequest(const std::string & pnProvider, const std::string & pnParam, const std::string & pnPrid);
			
			/**
			 * @brief Requests a code to be sent to a given email address, that can be used
			 * later to associate said email to an account using
			 * createLinkEmailToAccountUsingCodeRequest(). 
			 *
			 * @param sipIdentity the SIP identity URI that identifies the account to which
			 * you want to link the email address to.    
			 * @param emailAddress the email address to which to send the code to.    
			 * @return the @ref AccountManagerServicesRequest request object.    
			 */
			LINPHONECXX_PUBLIC std::shared_ptr<linphone::AccountManagerServicesRequest> createSendEmailLinkingCodeByEmailRequest(const std::shared_ptr<const linphone::Address> & sipIdentity, const std::string & emailAddress);
			
			/**
			 * @brief Requests a code to be sent to a given phone number, that can be used
			 * later to associate said phone number to an account using
			 * createLinkPhoneNumberToAccountUsingCodeRequest(). 
			 *
			 * @param sipIdentity the SIP identity URI that identifies the account to which
			 * you want to link the phone number to.    
			 * @param phoneNumber the phone number to which to send the code by SMS.    
			 * @return the @ref AccountManagerServicesRequest request object.    
			 */
			LINPHONECXX_PUBLIC std::shared_ptr<linphone::AccountManagerServicesRequest> createSendPhoneNumberLinkingCodeBySmsRequest(const std::shared_ptr<const linphone::Address> & sipIdentity, const std::string & phoneNumber);
			
			
	};

};

#endif // _ACCOUNT_MANAGER_SERVICES_HH

#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif // _MSC_VER
