public ProductDataSource() { // TODO: Of course it's a bad idea to hardcode this. In fact having this in your app is a bad idea period. This really should be exposed via // your own custom REST API that then connected to Shopify's. // This is just an example to show that it can be done, not how it *should* be done. ShopifyAuthorizationState authState = new ShopifyAuthorizationState { ShopName = "buckridge-hyatt6895", AccessToken = "42d4917ed3507278c748046addb01f3d" }; var api = new ShopifyAPIClient(authState, new JsonDataTranslator()); // The JSON Data Translator will automatically decode the JSON for you var result = api.Get("/admin/products.json"); result.Completed = delegate(IAsyncOperation <dynamic> asyncAction, AsyncStatus asyncStatus) { var data = asyncAction.GetResults(); var products = data.products; foreach (var product in products) { var group = new ProductDataGroup(product.id.ToString(), product.title.ToString(), product.vendor.ToString(), product.images.Count > 0 ? product.images[0].src.ToString() : "", product.body_html.ToString()); var imgCount = 0; foreach (var variant in product.variants) { group.Items.Add(new ProductDataItem(variant.id.ToString(), variant.option1.ToString(), variant.option2.ToString(), imgCount < product.images.Count ? product.images[imgCount++].src.ToString() : "", "", group.Description, group)); } this.AllGroups.Add(group); } }; }
public ProductDataSource() { // TODO: Of course it's a bad idea to hardcode this. In fact having this in your app is a bad idea period. This really should be exposed via // your own custom REST API that then connected to Shopify's. // This is just an example to show that it can be done, not how it *should* be done. ShopifyAuthorizationState authState = new ShopifyAuthorizationState { ShopName = "buckridge-hyatt6895", AccessToken = "42d4917ed3507278c748046addb01f3d" }; var api = new ShopifyAPIClient(authState, new JsonDataTranslator()); // The JSON Data Translator will automatically decode the JSON for you var result = api.Get("/admin/products.json"); result.Completed = delegate(IAsyncOperation<dynamic> asyncAction, AsyncStatus asyncStatus) { var data = asyncAction.GetResults(); var products = data.products; foreach (var product in products) { var group = new ProductDataGroup(product.id.ToString(), product.title.ToString(), product.vendor.ToString(), product.images.Count > 0 ? product.images[0].src.ToString() : "", product.body_html.ToString()); var imgCount = 0; foreach (var variant in product.variants) { group.Items.Add(new ProductDataItem(variant.id.ToString(), variant.option1.ToString(), variant.option2.ToString(), imgCount < product.images.Count ? product.images[imgCount++].src.ToString() : "", "", group.Description, group)); } this.AllGroups.Add(group); } }; }
public ProductDataItem(String uniqueId, String title, String subtitle, String imagePath, String description, String content, ProductDataGroup group) : base(uniqueId, title, subtitle, imagePath, description) { this._content = content; this._group = group; }