public void OrderNumbers() { string requestJson = GetJsonPayload("/account/ordersApi/request/orderNumbers.json"); string responseJson = GetJsonPayload("/account/ordersApi/response/orderNumbers.json"); var restRequest = MockRestResponse(responseJson); var request = new NumberPurchaseRequest { LocalCount = 2, Zipcode = "90401" }; var id = Client.OrdersApi.OrderNumbers(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 numbers. There are many ways to purchase a number. Set either tollFreeCount or localCount /// along with some querying fields to purchase numbers by bulk query. Set the list of numbers /// to purchase by list. Available numbers will be purchased using CallFire credits owned by the user. /// 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 OrderNumbers(NumberPurchaseRequest request) { return Client.Post<ResourceId>(ORDERS_NUMBERS, request); }