public AkeneoDataStore() { string optionsJson = string.Empty; try { var options = new AkeneoOptions { ApiEndpoint = new Uri(App.AkeneoConfig.AkeneoUrl), ClientId = App.AkeneoConfig.ClientId, ClientSecret = App.AkeneoConfig.ClientSecret, UserName = App.AkeneoConfig.Username, Password = App.AkeneoConfig.Password }; optionsJson = options.ToJson(); _client = new AkeneoClient(options); } catch (Exception ex) { Crashes.TrackError(ex); var properties = new Dictionary <string, string> { { "options", optionsJson }, { "ApiEndpoint", App.AkeneoConfig.AkeneoUrl } }; Crashes.TrackError(ex, properties); throw ex; } _akeneoFamily = App.AkeneoConfig.Configuration.Family; }
public static async Task <List <TModel> > GetAllAsync <TModel>(this IAkeneoClient client, string parentCode, int limit = 10, CancellationToken ct = default(CancellationToken)) where TModel : ModelBase { var result = new List <TModel>(); var page = 1; bool hasMore = false; do { var pagination = await client.GetManyAsync <TModel>(parentCode, page, limit, ct : ct); result.AddRange(pagination.GetItems()); hasMore = pagination.Links.ContainsKey(PaginationLinks.Next); page++; } while (hasMore); return(result); }
public static Task <List <TModel> > GetAllAsync <TModel>(this IAkeneoClient client, int limit = 10, CancellationToken ct = default(CancellationToken)) where TModel : ModelBase { return(client.GetAllAsync <TModel>(null, limit, ct)); }