/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *     http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

#ifndef ACSDKDAVSCLIENT_DAVSENDPOINTHANDLERV3_H_
#define ACSDKDAVSCLIENT_DAVSENDPOINTHANDLERV3_H_

#include "acsdkDavsClientInterfaces/DavsEndpointHandlerInterface.h"

namespace alexaClientSDK {
namespace acsdkAssets {
namespace davs {

/**
 * This class implements the DavsEndpointHandlerInterface and uses the following to construct a proper DAVS Url:
 *   1. Segment ID: Required, opaque identifier provided by Amazon for AVS customers
 *   2. DAVS Request: Required, to generate the path for the specific DAVS Artifact
 *   3. Locale(s): Optional, can be used to specify which artifact to use in certain cases
 */
class DavsEndpointHandlerV3 : public davsInterfaces::DavsEndpointHandlerInterface {
public:
    /**
     * Creates a new DAVS Endpoint Handler for V3 API given Segment ID (and optionally locale(s))
     *
     * @param segmentId REQUIRED, opaque identifier generated by Amazon for an AVS customer
     * @param locale OPTIONAL, specifies the locale(s) used for the endpoint, multiple locales can be separated by ","
     * @return a new DAVS Endpoint Handler for V3 upon success, nullptr otherwise.
     */
    static std::shared_ptr<DavsEndpointHandlerV3> create(const std::string& segmentId, const std::string& locale = "");

    /**
     * Destructor.
     */
    ~DavsEndpointHandlerV3() override = default;

    /// @name DavsEndpointHandlerInterface Functions
    /// @{
    std::string getDavsUrl(std::shared_ptr<commonInterfaces::DavsRequest> request) override;
    /// @}

    /**
     * Sets the locale for future DAVS requests
     *
     * @param newLocale new locale(s) to set (empty to avoid using this field)
     * @note you can specify one locale (ie. en-US) or multiple locales separated by "," (ie. en-US,en-CA)
     */
    void setLocale(std::string newLocale);

private:
    DavsEndpointHandlerV3(std::string segmentId, std::string locale);

private:
    /// Segment ID used for constructing the DAVS request URL
    const std::string m_segmentId;
    /// Optional locale which can be used to construct the DAVS request URL
    std::string m_locale;
};

}  // namespace davs
}  // namespace acsdkAssets
}  // namespace alexaClientSDK

#endif  // ACSDKDAVSCLIENT_DAVSENDPOINTHANDLERV3_H_
