public void Login(Account account) { EbayContext context = new EbayContext(account.EbayToken); // Get the Token // TODO: Initial failure point is on login here.... string userAlertsToken = null; { GetUserAlertsToken command = new GetUserAlertsToken(context); command.Execute(); userAlertsToken = command.ClientAlertsAuthToken; } // Login ... ItGoesChaChing.Ebay.ILogger clientAlertsLogger = this.Logger as ItGoesChaChing.Ebay.ILogger; LoginCall apiCall = new LoginCall(clientAlertsLogger); apiCall.ApiRequest.ClientAlertsAuthToken = userAlertsToken; apiCall.Execute(); account.SessionID = apiCall.ApiResponse.SessionID; account.SessionData = apiCall.ApiResponse.SessionData; }
public void Execute(Account account, ObservableCollection <AlertPreference> alertPreferences) { this.Logger.Log(LogLevel.Info, "Saving Preferences for Account {0}.", account.UserId); EbayContext eBayContext = new EbayContext(account.EbayToken, account.SiteCode); SetNotificationPreferences command = new SetNotificationPreferences(eBayContext); // Build up the list List <NotificationPreference> list = new List <NotificationPreference>(); foreach (AlertPreference alertPreference in alertPreferences) { List <NotificationPreference> newItems = alertPreference.GetNotificationPreferences(); foreach (NotificationPreference item in newItems) { list.Add(item); } } command.NotificationPreferences = list.ToArray(); command.Execute(); this.Logger.Log(LogLevel.Info, "Saving Preferences for Account {0} Done.", account.UserId); }
public void Confirm() { string eBayToken = null; { EbayContext context = new EbayContext(null); FetchToken command = new FetchToken(context); command.SessionId = this.SessionId; command.Execute(); eBayToken = command.EbayToken; } // Get the User's Details string userId = null; string siteCode = null; { EbayContext context = new EbayContext(eBayToken); GetUserCommand command = new GetUserCommand(context); command.Execute(); userId = command.UserId; siteCode = command.SiteCode; } Account account = new Account() { EbayToken = eBayToken, UserId = userId, SiteCode = siteCode }; // Get the Account's related Site Details { PopulateSitesJob job = new PopulateSitesJob(); Site site = job.PopulateSite(this.Context.Sites, account); account.Site = site; } // Set the Accounts Alert Preferences // TODO: Need to try catch this. { UpdatePreferencesJob job = new UpdatePreferencesJob(); job.Execute(account, this.Context.AlertPreferences); } // Save the account { this.Context.Accounts.Add(account); AccountsFactory factory = new AccountsFactory(); factory.Save(this.Context.Accounts); ObservableCollection <Account> newAccounts = factory.Load(); } this.Result = "Account Added"; }
public void LinkToEbay() { EbayContext eBayContext = new EbayContext(null); GetSignInUrl command = new GetSignInUrl(eBayContext); command.Execute(); this.SessionId = command.SessionId; string url = command.SignInUrl; System.Diagnostics.Process.Start(url); }
public Site PopulateSite(ObservableCollection <Site> sites, Account account) { Site site = sites.FirstOrDefault(s => s.SiteCode == account.SiteCode); if (site == null) { site = new Site() { SiteCode = account.SiteCode }; sites.Add(site); } EbayContext context = new EbayContext(account.EbayToken); GetEbayDetails command = new GetEbayDetails(context); command.SiteCode = account.SiteCode; command.Execute(); foreach (URLDetailsType urlDetails in command.UrlDetails) { UrlLink link = site.UrlLinks.FirstOrDefault(u => u.UrlType == urlDetails.URLType); if (link == null) { link = new UrlLink() { UrlType = urlDetails.URLType }; site.UrlLinks.Add(link); } link.Url = urlDetails.URL; } SitesFactory factory = new SitesFactory(); factory.Save(sites); return(site); }
public AlertBase PopulateAlert(Account account, ClientAlertEventType item) { if (item is FeedbackLeftEventType) { return(null); // Feedback received alerts are kind of worthless } if (item is ItemMarkedPaidEventType && ((ItemMarkedPaidEventType)item).SellerUserID == account.UserId) { return(null); // Not interested in alerts informing us we have marked the item as paid. } // Feedback Received if (item is FeedbackReceivedEventType) { FeedbackReceivedEventType eventType = (FeedbackReceivedEventType)item; FeedbackReceivedAlert alert = new FeedbackReceivedAlert(); alert.Account = account; alert.CommentingUser = new User(account.Site, eventType.FeedbackDetail.CommentingUser, eventType.FeedbackDetail.FeedbackScore); alert.Item = new Item(account.Site, eventType.FeedbackDetail.ItemID, eventType.FeedbackDetail.ItemTitle, eventType.FeedbackDetail.ItemPrice); alert.CommentText = eventType.FeedbackDetail.CommentText; alert.CommentType = eventType.FeedbackDetail.CommentType; return(alert); } // AskSellerQuestion else if (item is AskSellerQuestionEventType) { AskSellerQuestionEventType eventType = (AskSellerQuestionEventType)item; MessageAlert alert = new MessageAlert(); // Extract some more details from eBay { EbayContext context = new EbayContext(account.EbayToken); GetMemberMessages getMessagesCall = new GetMemberMessages(context); getMessagesCall.MessageId = eventType.MessageID; getMessagesCall.Execute(); MemberMessageExchangeType messageType = getMessagesCall.Message; alert.Account = account; alert.Sender = new User(account.Site, messageType.Question.SenderID); alert.Subject = messageType.Question.Subject; alert.Body = messageType.Question.Body.Replace("'", "'"); alert.Item = new Item(account.Site, messageType.Item.ItemID, messageType.Item.Title); foreach (MessageMediaType mediaType in messageType.MessageMedia) { PictureDownloader downloader = new PictureDownloader(); Bitmap bitmap = downloader.DownloadImage(mediaType.MediaURL); Media media = new Media(bitmap, mediaType.MediaURL); alert.MediaList.Add(media); } } return(alert); } else if (item is EndOfTransactionEventType && item.EventType == ClientAlertsEventTypeCodeType.FixedPriceTransaction) { EndOfTransactionEventType eventType = (EndOfTransactionEventType)item; ItemSoldAlert alert = new ItemSoldAlert(); alert.TransactionId = eventType.Transaction.TransactionID; alert.Account = account; alert.Item = new Item(account.Site, eventType.ItemID, eventType.Title, eventType.CurrentPrice); alert.Buyer = new User(account.Site, eventType.Transaction.BuyerUserID); alert.AmountPaid = eventType.Transaction.AmountPaid; alert.QuantitySold = eventType.Transaction.QuantitySold; if (!String.IsNullOrEmpty(eventType.GalleryURL)) { PictureDownloader downloader = new PictureDownloader(); Bitmap bitmap = downloader.DownloadImage(eventType.GalleryURL); Media media = new Media(bitmap, eventType.GalleryURL); alert.Item.Media = media; } return(alert); } return(null); }
public ProductsController(EbayContext context) { _context = context; }