public override DataTableStore GetDataTable(DataTableStore dt, DataTableKeySet keyset)
        {
            dt.AddIdentifierColumn(typeof(string));

            var uriHelper        = new MailChimpUriHelper(APIKey);
            var mapping          = new DataSchemaMapping(SchemaMap, Side);
            var schema           = MailChimpDataSchema.MailChimpMemberSchema();
            var hash_helper      = new HashHelper(HashHelper.HashType.MD5);
            var included_columns = SchemaMap.GetIncludedColumns();

            helper.SetAuthorizationHeader(APIKey);

            var target_index = mapping.MapColumnToDestination(keyset.KeyColumn);

            foreach (var key in keyset.KeyValues)
            {
                var index = key;
                if (target_index.Equals("email_address"))
                {
                    index = hash_helper.GetHashAsString(DataSchemaTypeConverter.ConvertTo <string>(key)).ToLower();
                }

                try
                {
                    var result = helper.GetRequestAsJson($"{uriHelper.ListServiceUrl}/{ListId}/members/{index}");

                    var newRow = dt.NewRow();
                    var id     = ProcessRow(mapping, schema, included_columns, result, newRow);

                    if (dt.Rows.AddWithIdentifier(newRow, id) == DataTableStore.ABORT)
                    {
                        break;
                    }
                }
                catch (WebException e)
                {
                    var response = e.Response as HttpWebResponse;
                    if (response.StatusCode == HttpStatusCode.NotFound)
                    {
                        continue;
                    }

                    throw;
                }
            }


            return(dt);
        }
        public override DataTableStore GetDataTable(DataTableStore dt)
        {
            dt.AddIdentifierColumn(typeof(string));

            var uriHelper        = new MailChimpUriHelper(APIKey);
            var mapping          = new DataSchemaMapping(SchemaMap, Side);
            var schema           = MailChimpDataSchema.MailChimpMemberSchema();
            var included_columns = SchemaMap.GetIncludedColumns();

            int  total_items = 0;
            int  count       = 0;
            bool abort       = false;

            helper.SetAuthorizationHeader(APIKey);

            do
            {
                var result = helper.GetRequestAsJson($"{uriHelper.ListServiceUrl}/{ListId}/members?count={PageSize}&offset={count}");

                total_items = result["total_items"].ToObject <int>();

                if (result["members"] != null)
                {
                    foreach (var item_row in result["members"])
                    {
                        count++;

                        var newRow = dt.NewRow();
                        var id     = ProcessRow(mapping, schema, included_columns, item_row, newRow);

                        if (dt.Rows.AddWithIdentifier(newRow, id) == DataTableStore.ABORT)
                        {
                            abort = true;
                            break;
                        }
                    }
                }
            } while (!abort && count < total_items);

            return(dt);
        }
 public override DataSchema GetDefaultDataSchema()
 {
     return(MailChimpDataSchema.MailChimpDataSyncSchema(MailChimpDataSchema.MailChimpMemberSchema()));
 }