public static async Task <Fulfillment> FulfillOrderPartially(IConfiguration appConfig, long orderId, long lineItemId, int lineItemQuantity, string trackingNumber, bool notifyCustomer) { // get shopify configuration parameters var config = new MyConfiguration(appConfig); string shopifyDomain = config.GetString("ShopifyDomain"); string shopifyAPIPassword = config.GetString("ShopifyAPIPassword"); var service = new FulfillmentService(shopifyDomain, shopifyAPIPassword); var fulfillment = new Fulfillment() { TrackingCompany = "Posten", TrackingUrl = $"https://sporing.posten.no/sporing.html?q={trackingNumber}", TrackingNumber = trackingNumber, LineItems = new List <LineItem>() { new LineItem() { Id = lineItemId, Quantity = lineItemQuantity } } }; fulfillment = await service.CreateAsync(orderId, fulfillment, notifyCustomer); return(fulfillment); }
public static async Task <IEnumerable <ProductImage> > GetShopifyProductImages(IConfiguration appConfig, long productId) { // get shopify configuration parameters var config = new MyConfiguration(appConfig); string shopifyDomain = config.GetString("ShopifyDomain"); string shopifyAPIPassword = config.GetString("ShopifyAPIPassword"); var service = new ProductImageService(shopifyDomain, shopifyAPIPassword); return(await service.ListAsync(productId)); }
public static async Task <Order> SetOrderNoteAttributes(IConfiguration appConfig, long orderId, IEnumerable <NoteAttribute> noteAttributes) { // get shopify configuration parameters var config = new MyConfiguration(appConfig); string shopifyDomain = config.GetString("ShopifyDomain"); string shopifyAPIPassword = config.GetString("ShopifyAPIPassword"); var service = new OrderService(shopifyDomain, shopifyAPIPassword); var order = await service.UpdateAsync(orderId, new Order() { NoteAttributes = noteAttributes }); return(order); }
/// <summary> /// Send mail with attachment created using the byte array /// </summary> /// <param name="appConfig">the configuration that holds the email server info</param> /// <param name="subject">mail subject</param> /// <param name="body">mail body</param> /// <param name="to">mail to</param> /// <param name="cc">mail cc</param> /// <param name="fileDownloadName">the filename of the attachment</param> /// <param name="bytes">the byte array</param> public static void SendMailWithAttachment(IConfiguration appConfig, string subject, string body, string to, string cc, string fileDownloadName, byte[] bytes) { var config = new MyConfiguration(appConfig); var emailSMTPServer = config.GetString("EmailSMTPServer"); var emailSMTPPort = config.GetInt("EmailSMTPPort"); var emailUserName = config.GetString("EmailUserName"); var emailPassword = config.GetString("EmailPassword"); var emailDisplayName = config.GetString("EmailDisplayName"); /* * Note: * Google may block sign in attempts from some apps or devices that do not use modern security standards. * Since these apps and devices are easier to break into, blocking them helps keep your account safer. * Please make sure, in Gmail settings of your account, enable access for less secure apps to avoid below error: * The SMTP server requires a secure connection or the client was not * authenticated. The server response was: 5.5.1 Authentication Required? */ using (MailMessage mail = new MailMessage()) { mail.From = new MailAddress(emailUserName, emailDisplayName); mail.To.Add(to); if (!string.IsNullOrEmpty(cc)) { mail.CC.Add(cc); } mail.Subject = subject; mail.Body = body; mail.Priority = MailPriority.High; mail.Attachments.Add(new Attachment(new MemoryStream(bytes), fileDownloadName)); mail.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient(emailSMTPServer, emailSMTPPort)) { smtp.Credentials = new NetworkCredential(emailUserName, emailPassword); smtp.EnableSsl = true; smtp.Send(mail); } } }