public static void Main(string[] args)
 {
     var client  = new CallfireClient("api_login", "api_password");
     var request = new KeywordPurchaseRequest
     {
         Keywords = { "SUN", "MOON" }
     };
     ResourceId resourceId = client.OrdersApi.OrderKeywords(request);
 }
        public void OrderKeywords()
        {
            var request = new KeywordPurchaseRequest {
                Keywords = { "TEST1", "TEST2" }
            };

            Assert.That(() => Client.OrdersApi.OrderKeywords(request),
                        Throws.TypeOf <BadRequestException>().With.Property("ApiErrorMessage").With.Property("HttpStatusCode").EqualTo(400)
                        .And.Property("Message").StringContaining("no valid credit card on file"));
            Assert.Throws <ResourceNotFoundException>(() => Client.OrdersApi.GetOrder(123));
        }
        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));
 }