public void FindTexts() { string expectedJson = GetJsonPayload("/callstexts/textsApi/response/findTexts.json"); var restRequest = MockRestResponse(expectedJson); var request = new FindTextsRequest { Limit = 5, Offset = 0, States = new List<StateType> { StateType.CALLBACK, StateType.DISABLED }, Id = new List<long> { 1, 2, 3 }, BatchId = 1001 }; Page<CallfireApiClient.Api.CallsTexts.Model.Text> texts = Client.TextsApi.Find(request); Assert.That(Serializer.Serialize(texts), Is.EqualTo(expectedJson)); Assert.AreEqual(Method.GET, restRequest.Value.Method); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("limit") && p.Value.Equals("5"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("offset") && p.Value.Equals("0"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("batchId") && p.Value.Equals("1001"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("id") && p.Value.Equals("1"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("id") && p.Value.Equals("2"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("id") && p.Value.Equals("3"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("states") && p.Value.Equals("CALLBACK"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches<Parameter>(p => p.Name.Equals("states") && p.Value.Equals("DISABLED"))); }
public void FindAndGetParticularTexts() { var request = new FindTextsRequest { States = new List<StateType> { StateType.FINISHED, StateType.READY }, Results = new List<TextRecord.TextResult> { TextRecord.TextResult.SENT, TextRecord.TextResult.RECEIVED }, Limit = 2 }; Page<CallfireApiClient.Api.CallsTexts.Model.Text> texts = Client.TextsApi.Find(request); Assert.IsNotEmpty(texts.Items); CallfireApiClient.Api.CallsTexts.Model.Text text = Client.TextsApi.Get((long)texts.Items[0].Id, "id,fromNumber,state"); Assert.NotNull(text.Id); Assert.NotNull(text.FromNumber); Assert.NotNull(text.State); Assert.IsNull(text.ToNumber); }
/// <summary> /// Finds all texts sent or received by the user. Use "campaignId=0" parameter to query for all /// texts sent through the POST /texts API. /// If no limit is given then the last 100 texts will be returned. /// </summary> /// <param name="request">request object with different fields to filter</param> /// <returns>paged list with text objects</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 Page<Text> Find(FindTextsRequest request) { return Client.Get<Page<Text>>(TEXTS_PATH, request); }