csharp-rest-api
csharp-rest-api copied to clipboard
How Do I Fetch All The Conversations That Belong To A Contact?
Currently The code i have fetches everything then filters on all results, the payload can be heavy in the future for this.
[HttpGet("{contactId}")] public List<Conversation> GetConversations(string contactId, [FromHeader(Name = "keys")] string headerKeys) { JavaScriptSerializer serializer = new JavaScriptSerializer(); MessageBirdKeys mbKeys = serializer.Deserialize<MessageBirdKeys>(headerKeys);
var restClient = new RestClient(CONVERSATIONS_ENDPOINT, mbKeys.AccessKey, null);
var client = Client.Create(restClient);
ConversationList conversations = client.ListConversations();
return conversations.Items.Where(i => i.ContactId == contactId).ToList();
}