//using Newtonsoft.Json; //using PartSource.Data.Shopify; //using PartSource.Services.Integrations; //using Ratermania.Shopify; //using System; //using System.Collections.Generic; //using System.Diagnostics.CodeAnalysis; //using System.Text; //using System.Threading.Tasks; //namespace PartSource.Services //{ // public class MetafieldService // { // private readonly ShopifyClient _shopifyClient; // public MetafieldService(ShopifyClient shopifyClient) // { // _shopifyClient = shopifyClient; // } // [SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "Lowercase is expected by Shopify")] // public async Task SaveMetafield(T shopifyEntity, IList vehicleIds, string @namespace) where T : ShopifyEntity // { // if (vehicleIds.Count == 0) // { // return; // } // string json = JsonConvert.SerializeObject(vehicleIds); // if (json.Length >= 100000) // { // // TODO: Logging // return; // } // string key = @namespace.ToLowerInvariant().Replace(" ", "_"); // if (key.Length > 20) // { // key = key.Substring(0, 20); // } // Metafield metafield = new Metafield // { // Namespace = "position", // Key = key, // Value = json, // ValueType = "json_string", // OwnerResource = "product", // OwnerId = shopifyEntity.Id // }; // await _shopifyClient.Metafields.Add(metafield); // } // public async Task DeleteMetafields(long shopifyId) where T : ShopifyEntity // { // IDictionary parameters = new Dictionary // { // { "metafield[owner_id]", shopifyId}, // { "metafield[owner_resource]", "product" }, // { "namespace", "position" }, // }; // IEnumerable metafields = await _shopifyClient.Metafields.Get(parameters); // foreach (Metafield metafield in metafields) // { // await _shopifyClient.Metafields.Delete(metafield); // } // } // } //}