csharp-rest-api icon indicating copy to clipboard operation
csharp-rest-api copied to clipboard

How Do I Fetch All The Conversations That Belong To A Contact?

Open heroddube opened this issue 3 years ago • 0 comments

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();
    }

heroddube avatar Mar 02 '22 13:03 heroddube