/// <summary>
        /// Helper method for validating and setting up an APIContext object in preparation for it being used when sending an HTTP request.
        /// </summary>
        /// <param name="apiContext">APIContext used for API calls.</param>
        public static void ValidateAndSetupAPIContext(APIContext apiContext)
        {
            ArgumentValidator.Validate(apiContext, "APIContext");
            if (apiContext.HTTPHeaders == null)
            {
                apiContext.HTTPHeaders = new Dictionary<string, string>();
            }

            apiContext.HTTPHeaders[BaseConstants.ContentTypeHeader] = BaseConstants.ContentTypeHeaderJson;
        }
        /// <summary>
        /// Create Campaign
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="campaignCustomerUuid">Customer uuid</param>
        /// <returns>HTML of the popup</returns>
        public String GetPopupHtml(APIContext apiContext, string campaignCustomerUuid)
        {
            // Validate
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(campaignCustomerUuid, "uuid");

            // Configure and send the request
            var pattern = "v2/migration/{0}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { campaignCustomerUuid });

            return ExpresslyClient.ConfigureAndExecute<String>(apiContext, ExpresslyClient.HttpMethod.GET, resourcePath);
        }
        ///----

        /// <summary>
        /// Confirm Migration
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="campaignCustomerUuid">Customer uuid</param>
        /// <returns>Is success</returns>
        public static bool ConfirmMigration(APIContext apiContext, string campaignCustomerUuid)
        {
            // Validate
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(campaignCustomerUuid, "uuid");

            // Configure and send the request
            var pattern = "v2/migration/{0}/success";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { campaignCustomerUuid });

            return ExpresslyClient.ConfigureAndExecute<SuccessMessageResponse>(apiContext, ExpresslyClient.HttpMethod.POST, resourcePath).success;
        }
        /// <summary>
        /// Install plugin
        /// </summary>
        /// <returns>boolean status</returns>
        public bool Install(APIContext APIContext, String ApiKey, String ApiBaseUrl)
        {
            // Validate
            ArgumentValidator.ValidateAndSetupAPIContext(APIContext);
            ArgumentValidator.Validate(ApiKey, "apiKey");
            ArgumentValidator.Validate(ApiBaseUrl, "apiBaseUrl");

            // Configure and send the request
            var resourcePath = "v2/plugin/merchant";
            var model = new RegisterPluginRequest() { apiBaseUrl = ApiBaseUrl, apiKey = ApiKey, pluginVersion = "v2" };

            var responceCode = ExpresslyClient.ConfigureAndExecute(APIContext, ExpresslyClient.HttpMethod.POST, resourcePath, model.ConvertToJson());
            return responceCode != null && responceCode.ToString() == "204";
        }
        /// <summary>
        /// Get Banner
        /// </summary>
        /// <param name="apiContext">APIContext used for the API call.</param>
        /// <param name="email">Email</param>
        /// <param name="merchantUuid">merchantUuid</param>
        /// <returns>Banner Object</returns>
        public Banner GetBanner(APIContext apiContext, string email, string merchantUuid = "")
        {
            // Set Up default value
            merchantUuid = merchantUuid.Length == 0 ? apiContext.GetMerchantUuid() : merchantUuid;

            // Validate
            ArgumentValidator.ValidateAndSetupAPIContext(apiContext);
            ArgumentValidator.Validate(email, "email");
            ArgumentValidator.Validate(merchantUuid, "merchantUuid");

            var queryParameters = new QueryParameters();
            queryParameters["email"] = email;

            // Configure and send the request
            var pattern = "v2/banner/{0}";
            var resourcePath = SDKUtil.FormatURIPath(pattern, new object[] { merchantUuid }) + queryParameters.ToUrlFormattedString();
            return ExpresslyClient.ConfigureAndExecute<Banner>(apiContext, ExpresslyClient.HttpMethod.GET, resourcePath);
        }
 public HomeController()
 {
     _expresslyApiContext = ExpresslyPlugin.APIContext;
 }
 public void APIContextValidConstructorTest()
 {
     var apiContext = new APIContext();
     Assert.IsNull(apiContext.Config);
     Assert.IsNull(apiContext.HTTPHeaders);
 }