Exemplo n.º 1
0
        public async Task FetchAttachmentAsync()
        {
            var request = new FetchAttachmentRequest()
            {
                Domain = Domain.Name, Inbox = PrivateInbox, MessageId = MessageIdWithAttachment, AttachmentId = AttachmentId
            };
            var response = await mailinatorClient.MessagesClient.FetchAttachmentAsync(request);

            Assert.IsTrue(response != null);
        }
        /// <summary>
        /// This endpoint retrieves attachment for a message. Note attachment is expected to be in Email format.
        /// </summary>
        /// <param name="request">FetchAttachmentRequest object.</param>
        /// <returns></returns>
        public async Task <FetchAttachmentResponse> FetchAttachmentAsync(FetchAttachmentRequest request)
        {
            var requestObject = httpClient.GetRequest(endpointUrl + "/{domain}/inboxes/{inbox}/messages/{messageId}/attachments/{attachmentId}", Method.GET);

            requestObject.AddUrlSegment("domain", request.Domain);
            requestObject.AddUrlSegment("inbox", request.Inbox);
            requestObject.AddUrlSegment("messageId", request.MessageId);
            requestObject.AddUrlSegment("attachmentId", request.AttachmentId);

            var response = await httpClient.ExecuteAsync <FetchAttachmentResponse>(requestObject, (restResponse) =>
            {
                return(new FetchAttachmentResponse
                {
                    Bytes = restResponse.RawBytes,
                    Content = restResponse.Content,
                    ContentType = restResponse.ContentType
                });
            });

            return(response);
        }