示例#1
0
        public EbayServiceResponse <AddMemberMessageRTQResponseType> SendMessage(string token, string subject, string parentMessageId, MemberMessage memberMessage)
        {
            var apiContext = CreateApiContext(apiServerUrl, ruName, appId, devId, certId, token);
            var result     = new EbayServiceResponse <AddMemberMessageRTQResponseType>();

            try
            {
                var apiCall = new AddMemberMessageRTQCall(apiContext)
                {
                    ItemID        = memberMessage.ItemId,
                    MemberMessage = new MemberMessageType()
                    {
                        ParentMessageID = parentMessageId,
                        MessageType     = MessageTypeCodeType.ContactEbayMember,
                        Body            = memberMessage.Body,
                        Subject         = subject,
                        QuestionType    = QuestionTypeCodeType.General,
                        SenderID        = memberMessage.SenderId,
                        SenderEmail     = memberMessage.SenderEmail,
                        RecipientID     = new StringCollection {
                            memberMessage.RecipientId
                        },
                    }
                };
                apiCall.Execute();
                result.Result = apiCall.ApiResponse;
            }
            catch (Exception ex)
            {
                result.Error = ex.Message;
            }

            return(result);
        }
示例#2
0
        public EbayServiceResponse <TokenStatusType> GetTokenStatus(string token)
        {
            var apiContext = CreateApiContext(apiServerUrl, ruName, appId, devId, certId, token);
            var result     = new EbayServiceResponse <TokenStatusType>();

            try
            {
                var apiCall = new GetTokenStatusCall(apiContext);
                result.Result = apiCall.GetTokenStatus();
            }
            catch (Exception ex)
            {
                result.Error = ex.Message;
            }
            return(result);
        }
示例#3
0
        public EbayServiceResponse <string> GetToken(string sessionId)
        {
            var apiContext = CreateApiContext(apiServerUrl, ruName, appId, devId, certId);
            var result     = new EbayServiceResponse <string>();

            try
            {
                var call = new FetchTokenCall(apiContext);
                result.Result = call.FetchToken(sessionId);
            }
            catch (Exception ex)
            {
                result.Error = ex.Message;
            }
            return(result);
        }
示例#4
0
        public EbayServiceResponse <string> GetSignInUrl()
        {
            var apiContext = CreateApiContext(apiServerUrl, ruName, appId, devId, certId);
            var result     = new EbayServiceResponse <string>();

            try
            {
                GetSessionIDCall sidCall   = new GetSessionIDCall(apiContext);
                string           sessionId = sidCall.GetSessionID(apiContext.RuName);
                result.Result = signinUrl + "&RuName=" + apiContext.RuName + "&SessID=" + HttpUtility.UrlEncode(sessionId);
            }
            catch (Exception ex)
            {
                result.Error = ex.Message;
            }
            return(result);
        }
示例#5
0
        public EbayServiceResponse <bool> IsValidToken(string token)
        {
            var apiContext = CreateApiContext(apiServerUrl, ruName, appId, devId, certId, token);
            var result     = new EbayServiceResponse <bool>();

            try
            {
                apiContext.ApiCredential.eBayToken = token;
                var apiCall = new GetTokenStatusCall(apiContext);
                result.Result = apiCall.GetTokenStatus().ExpirationTime > DateTime.UtcNow;
            }
            catch (Exception ex)
            {
                result.Error = ex.Message;
            }
            return(result);
        }
示例#6
0
        public EbayServiceResponse <IEnumerable <MemberMessage> > GetMemberMessage(string token, DateTime from, DateTime to, MessageTypeCodeType messageTypeCodeType,
                                                                                   MessageStatusTypeCodeType messageStatusTypeCode)
        {
            var apiContext = CreateApiContext(apiServerUrl, ruName, appId, devId, certId, token);
            var response   = new EbayServiceResponse <IEnumerable <MemberMessage> >();

            try
            {
                var apiCall    = new GetMemberMessagesCall(apiContext);
                var timeFilter = new TimeFilter(from, to);
                var messages   = apiCall.GetMemberMessages(timeFilter, messageTypeCodeType, messageStatusTypeCode);
                var result     = new List <MemberMessage>();
                foreach (MemberMessageExchangeType message in messages)
                {
                    var memberMessage = new MemberMessage
                    {
                        ParentMessageId  = message.Question.ParentMessageID,
                        MessageId        = message.Question.MessageID,
                        MessageStatus    = message.MessageStatus.ToString(),
                        ItemId           = message.Item != null ? message.Item.ItemID : string.Empty,
                        QuestionType     = message.Question.QuestionType.ToString(),
                        SenderId         = message.Question.SenderID,
                        SenderEmail      = message.Question.SenderEmail,
                        RecipientId      = message.Question.RecipientID[0],
                        Body             = message.Question.Body,
                        CreatedDate      = message.CreationDate,
                        LastModifiedDate = message.LastModifiedDate
                    };
                    result.Add(memberMessage);
                }
                response.Result = result;
            }
            catch (Exception ex)
            {
                response.Error = ex.Message;
            }
            return(response);
        }