A REST request to be made to the Pusher API
상속: IPusherRestRequest
        /// <inheritdoc/>
        public IPusherRestRequest Build(PusherMethod requestType, string resource, object requestParameters = null, object requestBody = null)
        {
            SortedDictionary<string, string> queryParams = GetQueryString(requestParameters, requestBody);

            string queryString = string.Empty;
            foreach (KeyValuePair<string, string> parameter in queryParams)
            {
                queryString += parameter.Key + "=" + parameter.Value + "&";
            }
            queryString = queryString.TrimEnd('&');

            string path = $"/apps/{_appId}/{resource.TrimStart('/')}";

            string authToSign = String.Format(
                Enum.GetName(requestType.GetType(), requestType) +
                "\n{0}\n{1}",
                path,
                queryString);

            string authSignature = CryptoHelper.GetHmac256(_appSecret, authToSign);

            string requestUrl = $"{path}?auth_signature={authSignature}&{queryString}";

            IPusherRestRequest request = new PusherRestRequest(requestUrl);
            request.Method = requestType;
            request.Body = requestBody;

            return request;
        }
        /// <inheritdoc/>
        public IPusherRestRequest Build(PusherMethod requestType, string resource, object requestParameters = null, object requestBody = null)
        {
            SortedDictionary <string, string> queryParams = GetQueryString(requestParameters, requestBody);

            string queryString = string.Empty;

            foreach (KeyValuePair <string, string> parameter in queryParams)
            {
                queryString += parameter.Key + "=" + parameter.Value + "&";
            }
            queryString = queryString.TrimEnd('&');

            string path = $"/apps/{_appId}/{resource.TrimStart('/')}";

            string authToSign = String.Format(
                Enum.GetName(requestType.GetType(), requestType) +
                "\n{0}\n{1}",
                path,
                queryString);

            string authSignature = CryptoHelper.GetHmac256(_appSecret, authToSign);

            string requestUrl = $"{path}?auth_signature={authSignature}&{queryString}";

            IPusherRestRequest request = new PusherRestRequest(requestUrl);

            request.Method = requestType;
            request.Body   = requestBody;

            return(request);
        }
        public void then_the_request_should_return_the_resource()
        {
            // Act
            var request = new PusherRestRequest("testUrl");

            // Assert
            Assert.IsNotNull(request.ResourceUri);
            StringAssert.AreEqualIgnoringCase("testUrl", request.ResourceUri);
        }
        public void then_the_request_should_return_the_body_as_null_when_not_present()
        {
            // Arrange
            var request = new PusherRestRequest("testUrl");

            // Act
            var jsonString = request.GetContentAsJsonString();

            // Assert
            Assert.IsNotNull(request);
            Assert.IsNull(jsonString);
        }
        public void then_the_request_should_return_the_body_as_a_string_when_present()
        {
            // Arrange
            var request = new PusherRestRequest("testUrl");

            // Act
            request.Body = _factory.Create("Test Property 1", 2, true);
            var jsonString = request.GetContentAsJsonString();

            // Assert
            Assert.IsNotNull(request);
            StringAssert.Contains("{\"Property1\":\"Test Property 1\",\"Property2\":2,\"Property3\":true}", jsonString);
        }
        public void then_the_request_should_throw_an_exception_when_given_an_unpopulated_resource_uri()
        {
            // Arrange
            ArgumentNullException caughtException = null;

            // Act
            try
            {
                var request = new PusherRestRequest(null);
            }
            catch (ArgumentNullException ex)
            {
                caughtException = ex;
            }

            // Assert
            Assert.IsNotNull(caughtException);
            StringAssert.AreEqualIgnoringCase($"The resource URI must be a populated string{Environment.NewLine}Parameter name: resourceUri", caughtException.Message);
        }