public async Task GetConversationAsync(string conversationId) { var conv = _active_conversations[conversationId].conversation_id; var evt = _active_conversations[conversationId].events.Min(c => c.timestamp); GetConversationRequest request = new GetConversationRequest() { request_header = RequestHeaderBody, include_event = true, max_events_per_conversation = 50, conversation_spec = new ConversationSpec() { conversation_id = conv }, event_continuation_token = new EventContinuationToken() { event_id = null, storage_continuation_token = null, event_timestamp = evt } }; using (HttpResponseMessage message = await _client.PostProtoJson("conversations/getconversation", _api_key, request)) { GetConversationResponse response = await message.Content.ReadAsProtoJson <GetConversationResponse>(); _active_conversations[response.conversation_state.conversation_id.id].conversation = response.conversation_state.conversation; // set continuation token _active_conversations[response.conversation_state.conversation_id.id].event_continuation_token = response.conversation_state.event_continuation_token; // reorder all events List <Event> events = _active_conversations[response.conversation_state.conversation_id.id].events; events.AddRange(response.conversation_state.events); _active_conversations[response.conversation_state.conversation_id.id].events = events.Distinct().OrderBy(c => c.timestamp).ToList(); OnConversationUpdated(this, _active_conversations[response.conversation_state.conversation_id.id]); } }
public void GetConversationResourceNames() { moq::Mock <Conversations.ConversationsClient> mockGrpcClient = new moq::Mock <Conversations.ConversationsClient>(moq::MockBehavior.Strict); GetConversationRequest request = new GetConversationRequest { ConversationName = ConversationName.FromProjectConversation("[PROJECT]", "[CONVERSATION]"), }; Conversation expectedResponse = new Conversation { ConversationName = ConversationName.FromProjectConversation("[PROJECT]", "[CONVERSATION]"), LifecycleState = Conversation.Types.LifecycleState.Unspecified, ConversationProfileAsConversationProfileName = ConversationProfileName.FromProjectConversationProfile("[PROJECT]", "[CONVERSATION_PROFILE]"), PhoneNumber = new ConversationPhoneNumber(), StartTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), ConversationStage = Conversation.Types.ConversationStage.HumanAssistStage, }; mockGrpcClient.Setup(x => x.GetConversation(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ConversationsClient client = new ConversationsClientImpl(mockGrpcClient.Object, null); Conversation response = client.GetConversation(request.ConversationName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task GetConversationAsync(string conversationId) { var conv = _active_conversations[conversationId]._conversation; var evt = _active_conversations[conversationId].messagesIds.Values.Min(); GetConversationRequest request = new GetConversationRequest() { request_header = RequestHeaderBody, include_event = true, max_events_per_conversation = 50, conversation_spec = new ConversationSpec() { conversation_id = conv.conversation_id }, event_continuation_token = new EventContinuationToken() { event_id = null, storage_continuation_token = null, event_timestamp = evt } }; using (HttpResponseMessage message = await _client.PostProtoJson("conversations/getconversation", _api_key, request)) { GetConversationResponse response = await message.Content.ReadAsProtoJson <GetConversationResponse>(); _active_conversations[response.conversation_state.conversation_id.id].AddOldMessages(response.conversation_state.events); } }
public async stt::Task GetConversationResourceNamesAsync() { moq::Mock <Conversations.ConversationsClient> mockGrpcClient = new moq::Mock <Conversations.ConversationsClient>(moq::MockBehavior.Strict); GetConversationRequest request = new GetConversationRequest { ConversationName = ConversationName.FromProjectConversation("[PROJECT]", "[CONVERSATION]"), }; Conversation expectedResponse = new Conversation { ConversationName = ConversationName.FromProjectConversation("[PROJECT]", "[CONVERSATION]"), LifecycleState = Conversation.Types.LifecycleState.Unspecified, ConversationProfileAsConversationProfileName = ConversationProfileName.FromProjectConversationProfile("[PROJECT]", "[CONVERSATION_PROFILE]"), PhoneNumber = new ConversationPhoneNumber(), StartTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), ConversationStage = Conversation.Types.ConversationStage.HumanAssistStage, }; mockGrpcClient.Setup(x => x.GetConversationAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Conversation>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ConversationsClient client = new ConversationsClientImpl(mockGrpcClient.Object, null); Conversation responseCallSettings = await client.GetConversationAsync(request.ConversationName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Conversation responseCancellationToken = await client.GetConversationAsync(request.ConversationName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public GetConversationResponse GetConversation(GetConversationRequest request) { Platform.CheckForNullReference(request, "request"); Platform.CheckMemberIsSet(request.OrderRef, "request.OrderRef"); var order = PersistenceContext.Load <Order>(request.OrderRef); // select only notes that are actually posted, and meet category filter var notes = CollectionUtils.Select(OrderNote.GetNotesForOrder(order), n => n.IsPosted && (request.CategoryFilters == null || request.CategoryFilters.Count == 0 || request.CategoryFilters.Contains(n.Category))); // put most recent notes first notes.Reverse(); var noteAssembler = new OrderNoteAssembler(); if (request.CountOnly) { return(new GetConversationResponse(order.GetRef(), null, notes.Count)); } return(new GetConversationResponse( order.GetRef(), CollectionUtils.Map(notes, (OrderNote n) => noteAssembler.CreateOrderNoteDetail(n, CurrentUserStaff, PersistenceContext)), notes.Count)); }
/// <summary> /// Called by the host to initialize the application component. /// </summary> public override void Start() { // init lookup handlers _cannedTextLookupHandler = new CannedTextLookupHandler(this.Host.DesktopWindow); // init recip table here, and not in constructor, because it relies on Host being set _recipients = new RecipientTable(this); // if exactly 1 template choice, then it is selected _selectedTemplate = _templateChoices.Count == 1 ? _templateChoices[0] : null; // create soft keys UpdateSoftKeys(); // load the existing conversation, plus editor form data GetConversationEditorFormDataResponse formDataResponse = null; Platform.GetService <IOrderNoteService>( service => { var formDataRequest = new GetConversationEditorFormDataRequest( _selectedTemplate != null ? _selectedTemplate.GetStaffRecipients() : new List <string>(), _selectedTemplate != null ? _selectedTemplate.GetGroupRecipients() : new List <string>()); formDataResponse = service.GetConversationEditorFormData(formDataRequest); var request = new GetConversationRequest(_orderRef, new List <string>(_orderNoteCategories), false); var response = service.GetConversation(request); _orderRef = response.OrderRef; _orderNotes = response.OrderNotes; }); // init on-behalf of choices _onBehalfOfChoices = formDataResponse.OnBehalfOfGroupChoices; _onBehalfOfChoices.Insert(0, _emptyStaffGroup); // initialize from template (which may be null) InitializeFromTemplate(_selectedTemplate, formDataResponse.RecipientStaffs, formDataResponse.RecipientStaffGroups); // build the action model _recipientsActionModel = new CrudActionModel(true, false, true, new ResourceResolver(this.GetType(), true)); _recipientsActionModel.Add.SetClickHandler(AddRecipient); _recipientsActionModel.Delete.SetClickHandler(DeleteRecipient); // init conversation view component _orderNoteViewComponent = new OrderNoteViewComponent(_orderNotes); _orderNoteViewComponent.CheckedItemsChanged += delegate { NotifyPropertyChanged("CompleteButtonLabel"); }; _orderNotesComponentHost = new ChildComponentHost(this.Host, _orderNoteViewComponent); _orderNotesComponentHost.StartComponent(); base.Start(); }
/// <summary>Snippet for GetConversation</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetConversationRequestObject() { // Create client ContactCenterInsightsClient contactCenterInsightsClient = ContactCenterInsightsClient.Create(); // Initialize request argument(s) GetConversationRequest request = new GetConversationRequest { ConversationName = ConversationName.FromProjectLocationConversation("[PROJECT]", "[LOCATION]", "[CONVERSATION]"), View = ConversationView.Unspecified, }; // Make the request Conversation response = contactCenterInsightsClient.GetConversation(request); }
/// <summary>Snippet for GetConversation</summary> public void GetConversationRequestObject() { // Snippet: GetConversation(GetConversationRequest, CallSettings) // Create client ConversationsClient conversationsClient = ConversationsClient.Create(); // Initialize request argument(s) GetConversationRequest request = new GetConversationRequest { ConversationName = ConversationName.FromProjectConversation("[PROJECT]", "[CONVERSATION]"), }; // Make the request Conversation response = conversationsClient.GetConversation(request); // End snippet }
public override Conversation Get(string id) { Known.TryGetValue(id, out var returned); if (returned == null) { var result = new GetConversationRequest(id).Execute(Api.Client); if (result.Status == 200) { returned = new Conversation(); returned.UpdateFromRequest(Utils.DictionaryOfJsonFields(result.Data)); Known.Add(returned.Id, returned); } } return(returned); }
/// <summary>Snippet for GetConversationAsync</summary> public async Task GetConversationRequestObjectAsync() { // Snippet: GetConversationAsync(GetConversationRequest, CallSettings) // Additional: GetConversationAsync(GetConversationRequest, CancellationToken) // Create client ConversationsClient conversationsClient = await ConversationsClient.CreateAsync(); // Initialize request argument(s) GetConversationRequest request = new GetConversationRequest { ConversationName = ConversationName.FromProjectConversation("[PROJECT]", "[CONVERSATION]"), }; // Make the request Conversation response = await conversationsClient.GetConversationAsync(request); // End snippet }