protected override void ExecuteInternal() { this.Message = null; GetMyMessagesCall apiCall = new GetMyMessagesCall(this.ApiContext); apiCall.ApiRequest.DetailLevel = new DetailLevelCodeTypeCollection(); apiCall.ApiRequest.DetailLevel.Add(DetailLevelCodeType.ReturnMessages); apiCall.ApiRequest.ExternalMessageIDs = new StringCollection(); apiCall.ApiRequest.ExternalMessageIDs.Add(this.MessageId); apiCall.Execute(); if (apiCall.HasWarning) { string message = apiCall.ApiException.Message; } if (apiCall.HasError) { string message = apiCall.ApiException.Message; } if (apiCall.ApiResponse != null && apiCall.ApiResponse.Messages != null && apiCall.ApiResponse.Messages.Count > 0) { this.Message = apiCall.ApiResponse.Messages[0]; } }
// // GetMyMessages // Returns information about the threaded messages sent to a user's My Messages mailbox. // http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetMyMessages.html // For maximum efficiency, make sure your application can first call GetMyMessages // with DetailLevel set to ReturnHeaders. // // With a detail level of ReturnHeaders or ReturnMessages, // GetMyMessages only accepts 10 unique message ID values, per request. // // GetMemberMessages // http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetMemberMessages.html // You can get all the messages sent within a specific time range // by providing StartCreationTime and EndCreationTime in your request. // Or you can specify an item's ItemID to get messages about an item. // After calling GetMemberMessages, inspect the children of the MemberMessages container. // For instance, if you want to know whether a message was previously answered, inspect the MessageStatus field. public static StringCollection GetAllMessageIds(AccountType account, DateTime startTime, DateTime endTime) { GetMyMessagesCall getMyMessageApiCall = new GetMyMessagesCall(account.SellerApiContext); getMyMessageApiCall.StartTime = startTime; getMyMessageApiCall.EndTime = endTime; DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnHeaders }; getMyMessageApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); StringCollection msgIds = new StringCollection(); for (int folderId = 0; folderId <= 1; folderId++) { getMyMessageApiCall.FolderID = folderId; getMyMessageApiCall.GetMyMessages(); MyMessagesMessageTypeCollection messages = getMyMessageApiCall.MessageList; foreach (MyMessagesMessageType msg in messages) { msgIds.Add(msg.MessageID); } } return(msgIds); } // GetAllMessageIds
} // GetAllMessageByIds // Get all messages between buyers and sellers. public static bool GetAllMessages(AccountType account, DateTime startTime, DateTime endTime) { GetMyMessagesCall getMyMessageApiCall = new GetMyMessagesCall(account.SellerApiContext); getMyMessageApiCall.StartTime = startTime; getMyMessageApiCall.EndTime = endTime; DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnHeaders }; getMyMessageApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); getMyMessageApiCall.GetMyMessages(); MyMessagesMessageTypeCollection messages = getMyMessageApiCall.MessageList; foreach (MyMessagesMessageType msg in messages) { string msgId = msg.MessageID; GetMyMessagesCall getMyMessageApiCall2 = new GetMyMessagesCall(account.SellerApiContext); StringCollection msgIds = new StringCollection(); msgIds.Add(msgId); getMyMessageApiCall2.MessageIDList = msgIds; detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnMessages }; getMyMessageApiCall2.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); getMyMessageApiCall2.GetMyMessages(); MyMessagesMessageType msg2 = getMyMessageApiCall2.MessageList[0]; EbayMessageType ebayMsg = new EbayMessageType(); ebayMsg.EbayMessageId = msgId; ebayMsg.SellerName = account.ebayAccount; ebayMsg.MessageType = msg2.MessageType.ToString(); ebayMsg.QuestionType = msg2.QuestionType.ToString(); ebayMsg.IsRead = msg2.Read; ebayMsg.IsReplied = msg2.Replied; ebayMsg.IsResponseEnabled = msg2.ResponseDetails != null ? msg2.ResponseDetails.ResponseEnabled : false; ebayMsg.ResponseURL = msg2.ResponseDetails != null ? msg2.ResponseDetails.ResponseURL : ""; ebayMsg.UserResponseDate = msg2.ResponseDetails != null ? msg2.ResponseDetails.UserResponseDate : DateTime.MinValue; ebayMsg.ReceiveDate = msg2.ReceiveDate; ebayMsg.RecipientUserId = msg2.RecipientUserID; ebayMsg.Sender = msg2.Sender; ebayMsg.Subject = msg2.Subject; ebayMsg.IsHighPriority = msg2.HighPriority; ebayMsg.Content = msg2.Content; ebayMsg.Text = msg2.Text; ebayMsg.ExternalMessageId = msg2.ExternalMessageID; ebayMsg.FolderId = msg2.Folder != null ? msg2.Folder.FolderID : -1; ebayMsg.ItemID = msg2.ItemID; ebayMsg.ItemTitle = msg2.ItemTitle; ebayMsg.ItemEndTime = msg2.ItemEndTime; ebayMsg.ListingStatus = msg2.ListingStatus.ToString(); EbayMessageDAL.InsertOneMessage(ebayMsg); } return(true); } // GetAllMessages
private void BtnGetMessage_Click(object sender, EventArgs e) { GetMyMessagesCall apicall = new GetMyMessagesCall(Program.GetApiContext()); //OrderTypeCollection list = apicall.GetMyMessages(orderids); //if (list.Count == 0) //{ // MessageBox.Show("There is no order!"); // return; //} TxtXml.Text = apicall.SoapResponse; }
public void GetMyMessages() { GetMyMessagesCall api = new GetMyMessagesCall(this.apiContext); api.DetailLevelList = new DetailLevelCodeTypeCollection(); api.DetailLevelList.Add(DetailLevelCodeType.ReturnSummary); // Make API call. api.GetMyMessages(); MyMessagesAlertTypeCollection alerts = api.ApiResponse.Alerts; Assert.IsNotNull(alerts); MyMessagesMessageTypeCollection msgs = api.ApiResponse.Messages; Assert.IsNotNull(msgs); MyMessagesSummaryType summary = api.ApiResponse.Summary; Assert.IsNotNull(summary); }
} // GetAllMessageIds public static List <EbayMessageType> GetAllMessageByIds(AccountType account, StringCollection msgIds) { List <EbayMessageType> messageList = new List <EbayMessageType>(); if (msgIds.Count > 10) { Logger.WriteSystemLog("[GetAllMessageByIds]: can only get at most 10 messages once."); return(messageList); } GetMyMessagesCall getMyMessageApiCall = new GetMyMessagesCall(account.SellerApiContext); getMyMessageApiCall.MessageIDList = msgIds; DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnMessages }; getMyMessageApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); getMyMessageApiCall.GetMyMessages(); MyMessagesMessageTypeCollection messages = getMyMessageApiCall.MessageList; foreach (MyMessagesMessageType msg in messages) { // See if this message has already existed. String msgId = msg.MessageID; EbayMessageType tmpEbayMsg = EbayMessageDAL.GetOneMessage(msgId); if (tmpEbayMsg != null && tmpEbayMsg.EbayMessageId != "") { Logger.WriteSystemLog(string.Format("[GetAllMessageByIds]: message with id={0} has already existed, skip and continue.", msgId)); continue; } EbayMessageType ebayMsg = new EbayMessageType(); ebayMsg.EbayMessageId = msg.MessageID; ebayMsg.SellerName = account.ebayAccount; ebayMsg.MessageType = msg.MessageType.ToString(); ebayMsg.QuestionType = msg.QuestionType.ToString(); ebayMsg.IsRead = msg.Read; ebayMsg.IsReplied = msg.Replied; ebayMsg.IsResponseEnabled = msg.ResponseDetails != null ? msg.ResponseDetails.ResponseEnabled : false; ebayMsg.ResponseURL = msg.ResponseDetails != null ? msg.ResponseDetails.ResponseURL : ""; ebayMsg.UserResponseDate = msg.ResponseDetails != null ? msg.ResponseDetails.UserResponseDate : DateTime.MinValue; ebayMsg.ReceiveDate = msg.ReceiveDate; //ebayMsg.RecipientUserId = msg.RecipientUserID; ebayMsg.RecipientUserId = msg.SendToName; ebayMsg.Sender = msg.Sender; ebayMsg.Subject = msg.Subject; ebayMsg.IsHighPriority = msg.HighPriority; // The message body. Plain text. ebayMsg.Content = msg.Content; // This field contains message content, and can contain a threaded message. // Max length: 2 megabytes in size. ebayMsg.Text = msg.Text; ebayMsg.ExternalMessageId = msg.ExternalMessageID; ebayMsg.FolderId = msg.Folder != null ? msg.Folder.FolderID : -1; ebayMsg.ItemID = msg.ItemID; ebayMsg.ItemTitle = msg.ItemTitle; ebayMsg.ItemEndTime = msg.ItemEndTime; ebayMsg.ListingStatus = msg.ListingStatus.ToString(); messageList.Add(ebayMsg); } return(messageList); } // GetAllMessageByIds