public void OrderKeywords() { string requestJson = GetJsonPayload("/account/ordersApi/request/orderKeywords.json"); string responseJson = GetJsonPayload("/account/ordersApi/response/orderKeywords.json"); var restRequest = MockRestResponse(responseJson); var request = new KeywordPurchaseRequest { Keywords = { "KW1", "KW2" } }; var id = Client.OrdersApi.OrderKeywords(request); Assert.That(Serializer.Serialize(id), Is.EqualTo(responseJson)); Assert.AreEqual(Method.POST, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson)); }
/// <summary> /// Purchase keywords. Send a list of available keywords into this API to purchase them /// using CallFire credits. Be sure the account has credits before trying to purchase. /// GET /me/account /// </summary> /// <param name="request">request payload</param> /// <returns>ResourceId with id of created order</returns> /// <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 ResourceId OrderKeywords(KeywordPurchaseRequest request) { return Client.Post<ResourceId>(ORDERS_KEYWORDS, request); }