Exemple #1
0
        /// <summary>
        /// Update keyword lease
        /// </summary>
        /// <param name="keywordLease">keyword lease payload</param>
        /// <exception cref="BadRequestException">          in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception>
        /// <exception cref="UnauthorizedException">        in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception>
        /// <exception cref="AccessForbiddenException">     in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception>
        /// <exception cref="ResourceNotFoundException">    in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception>
        /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception>
        /// <exception cref="CallfireApiException">         in case HTTP response code is something different from codes listed above.</exception>
        /// <exception cref="CallfireClientException">      in case error has occurred in client.</exception>
        public void Update(KeywordLease keywordLease)
        {
            Validate.NotBlank(keywordLease.KeywordName, "keyword in keywordLease cannot be null");
            string path = KEYWORD_LEASES_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, keywordLease.KeywordName);

            Client.Put <object>(path, keywordLease);
        }
Exemple #2
0
    public static void Main(string[] args)
    {
        var client = new CallfireClient("api_login", "api_password");
        var lease  = new KeywordLease
        {
            KeywordName = "SUN",
            AutoRenew   = false
        };

        client.KeywordLeasesApi.Update(lease);
    }
Exemple #3
0
        public void Get()
        {
            string expectedJson = GetJsonPayload("/keywords/keywordLeasesApi/response/getKeywordLease.json");
            var    restRequest  = MockRestResponse(expectedJson);

            KeywordLease keywordLease = Client.KeywordLeasesApi.Get(TEST_STRING, FIELDS);

            Assert.That(Serializer.Serialize(keywordLease), Is.EqualTo(expectedJson));
            Assert.AreEqual(Method.GET, restRequest.Value.Method);
            Assert.That(restRequest.Value.Resource, Is.StringContaining("/" + TEST_STRING));
            Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("fields") && p.Value.Equals(FIELDS)));

            Client.KeywordLeasesApi.Get(TEST_STRING);
            Assert.That(restRequest.Value.Parameters, Has.No.Some.Matches <Parameter>(p => p.Name.Equals("fields") && p.Value.Equals(FIELDS)));
            Assert.That(restRequest.Value.Resource, Is.StringContaining("/" + TEST_STRING));
        }
Exemple #4
0
        public void Update()
        {
            string requestJson = GetJsonPayload("/keywords/keywordLeasesApi/request/updateKeywordLease.json");
            var    restRequest = MockRestResponse();

            var keywordLease = new KeywordLease
            {
                KeywordName = TEST_STRING,
                AutoRenew   = false
            };

            Client.KeywordLeasesApi.Update(keywordLease);

            Assert.AreEqual(Method.PUT, restRequest.Value.Method);
            Assert.That(restRequest.Value.Resource, Is.StringContaining("/keywords/leases/" + TEST_STRING));
            var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);

            Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson));
        }