<commit_before>angular.module( "ngBattleNet", [ "httpi" ] )

.provider( "battleNetConfig", function battleNetConfig() {
	"use strict";

	var config = {
		apiKey: null,
		defaultRegion: "us"
	};

	this.setApiKey = function( apiKey ) {
		config.apiKey = apiKey;
	};

	this.getApiKey = function( apiKey ) {
		return config.apiKey;
	};

	this.setDefaultRegion = function( defaultRegion ) {
		config.defaultRegion = defaultRegion;
	};

	this.getDefaultRegion = function( defaultRegion ) {
		return config.defaultRegion;
	};

	this.$get = [function() {
		return this;
	}];

})

.factory( "battleNetApiRequest", [ "battleNetConfig", "httpi", function battleNetApiRequest( battleNetConfig, httpi ) {
	"use strict";

	// some endpoints have a "region" parameter, so we'll use "bnetRegion" internally to avoid conflicts.
	var host = "https://:bnetRegion.api.battle.net/",
		defaultParams = {
			apikey: battleNetConfig.getApiKey()
		},
		regionLocales = {
			us: "en_US",
			eu: "en_GB",
			sea: "en_US",
			kr: "ko_KR",
			tw: "zh_TW"
		};

	return function( path, params ) {

		var url = host + path;

		params = params || {};
		angular.extend( params, defaultParams );
		params.bnetRegion = params.bnetRegion || battleNetConfig.getDefaultRegion();
		params.locale = params.locale || regionLocales[ params.bnetRegion ];

		return httpi({
			method: "jsonp",
			url: url,
			params: params,
			keepTrailingSlash: true
		});

	};

}])

.factory( "battleNetApi", [ "d3Api", "sc2Api", "wowApi", function battleNetApi( d3Api, sc2Api, wowApi ) {
	"use strict";

	return {
		d3: d3Api,
		sc2: sc2Api,
		wow: wowApi
	};
}])

.factory( "d3Api", [ "battleNetApiRequest", function d3Api( battleNetApiRequest ) {
	"use strict";

	var service = {};

	function makeRequest( path, params ) {
		params = params || {};
		angular.extend( params, { callback: "JSON_CALLBACK" });
		return battleNetApiRequest( "d3/" + path, params );
	}

	// no hashes allowed, but people are going to try it anyway
	function convertBattleTag( battletag ) {
		return battletag.replace(/#/g, "-");
	}

	service.data = {
		artisan: function( params ) {
			return makeRequest( "data/artisan/:artisan", params );
		},
		follower: function( params ) {
			return makeRequest( "data/follower/:follower", params );
		},
		item: function( params ) {
			return makeRequest( "data/item/:data", params );
		}
	};


	service.profile = {
		career: function( params ) {
			params.battletag = convertBattleTag( params.battletag );
			return makeRequest( "profile/:battletag/", params );
		},
		hero: function( params ) {
			params.battletag = convertBattleTag( params.battletag );
			return makeRequest( "profile/:battletag/hero/:id", params );
		}
	};

	return service;

}])

.factory( "sc2Api", [ "battleNetApiRequest", function sc2Api( battleNetApiRequest ) {
	"use strict";

	var service = {};

	function makeRequest( path, params ) {
		params = params || {};
		angular.extend( params, { callback: "JSON_CALLBACK" });
		return battleNetApiRequest( "sc2/" + path, params );
	}

	service.data = {
		achievements: function( params ) {
			return makeRequest( "data/achievements", params );
		},
		rewards: function( params ) {
			return makeRequest( "data/rewards", params );
		}
	};


	service.ladder = function( params ) {
		return makeRequest( "ladder/:id", params );
	};


	service.profile = {
		profile: function( params ) {
			return makeRequest( "profile/:id/:region/:name/", params );
		},
		ladders: function( params ) {
			return makeRequest( "profile/:id/:region/:name/ladders", params );
		},
		matchHistory: function( params ) {
			return makeRequest( "profile/:id/:region/:name/matches", params );
		}
	};

	return service;

}])

.factory( "wowApi", [ "battleNetApiRequest", function wowApi( battleNetApiRequest ) {
	"use strict";

	var service = {},
		possibleGuildFields = [
			"members", "achievements", "news", "challenge"
		];

	function makeRequest( path, params ) {
		params = params || {};
		angular.extend( params, { jsonp: "JSON_CALLBACK" });
		return battleNetApiRequest( "wow/" + path, params );
	}

	// characters and guilds have a lot of endpoints that are basically the same with the
	// exception of adding &fields=foo to the URL. we can get rid of a lot of boilerplate
	// by using this method instead of writing it out for each endpoint.
	function withField( field, callback ) {
		return function( params ) {
			angular.extend( params, { fields: field });
			return callback( params );
		}
	}


	service.achievement = function( params ) {
		return makeRequest( "achievement/:id", params );
	};


	service.auction = function( params ) {
		return makeRequest( "auction/data/:realm", params );
	};

<commit_msg>Missed some extra code from the last commit.<commit_after>angular.module( "ngBattleNet", [ "httpi" ] )

.provider( "battleNetConfig", function battleNetConfig() {
	"use strict";

	var config = {
		apiKey: null,
		defaultRegion: "us"
	};

	this.setApiKey = function( apiKey ) {
		config.apiKey = apiKey;
	};

	this.getApiKey = function( apiKey ) {
		return config.apiKey;
	};

	this.setDefaultRegion = function( defaultRegion ) {
		config.defaultRegion = defaultRegion;
	};

	this.getDefaultRegion = function( defaultRegion ) {
		return config.defaultRegion;
	};

	this.$get = [function() {
		return this;
	}];

})

.factory( "battleNetApiRequest", [ "battleNetConfig", "httpi", function battleNetApiRequest( battleNetConfig, httpi ) {
	"use strict";

	// some endpoints have a "region" parameter, so we'll use "bnetRegion" internally to avoid conflicts.
	var host = "https://:bnetRegion.api.battle.net/",
		defaultParams = {
			apikey: battleNetConfig.getApiKey()
		},
		regionLocales = {
			us: "en_US",
			eu: "en_GB",
			sea: "en_US",
			kr: "ko_KR",
			tw: "zh_TW"
		};

	return function( path, params ) {

		var url = host + path;

		params = params || {};
		angular.extend( params, defaultParams );
		params.bnetRegion = params.bnetRegion || battleNetConfig.getDefaultRegion();
		params.locale = params.locale || regionLocales[ params.bnetRegion ];

		return httpi({
			method: "jsonp",
			url: url,
			params: params,
			keepTrailingSlash: true
		});

	};

}])

.factory( "battleNetApi", [ "d3Api", "sc2Api", "wowApi", function battleNetApi( d3Api, sc2Api, wowApi ) {
	"use strict";

	return {
		d3: d3Api,
		sc2: sc2Api,
		wow: wowApi
	};
}])

.factory( "d3Api", [ "battleNetApiRequest", function d3Api( battleNetApiRequest ) {
	"use strict";

	var service = {};

	function makeRequest( path, params ) {
		params = params || {};
		angular.extend( params, { callback: "JSON_CALLBACK" });
		return battleNetApiRequest( "d3/" + path, params );
	}

	// no hashes allowed, but people are going to try it anyway
	function convertBattleTag( battletag ) {
		return battletag.replace(/#/g, "-");
	}

	service.data = {
		artisan: function( params ) {
			return makeRequest( "data/artisan/:artisan", params );
		},
		follower: function( params ) {
			return makeRequest( "data/follower/:follower", params );
		},
		item: function( params ) {
			return makeRequest( "data/item/:data", params );
		}
	};


	service.profile = {
		career: function( params ) {
			params.battletag = convertBattleTag( params.battletag );
			return makeRequest( "profile/:battletag/", params );
		},
		hero: function( params ) {
			params.battletag = convertBattleTag( params.battletag );
			return makeRequest( "profile/:battletag/hero/:id", params );
		}
	};

	return service;

}])

.factory( "sc2Api", [ "battleNetApiRequest", function sc2Api( battleNetApiRequest ) {
	"use strict";

	var service = {};

	function makeRequest( path, params ) {
		params = params || {};
		angular.extend( params, { callback: "JSON_CALLBACK" });
		return battleNetApiRequest( "sc2/" + path, params );
	}

	service.data = {
		achievements: function( params ) {
			return makeRequest( "data/achievements", params );
		},
		rewards: function( params ) {
			return makeRequest( "data/rewards", params );
		}
	};


	service.ladder = function( params ) {
		return makeRequest( "ladder/:id", params );
	};


	service.profile = {
		profile: function( params ) {
			return makeRequest( "profile/:id/:region/:name/", params );
		},
		ladders: function( params ) {
			return makeRequest( "profile/:id/:region/:name/ladders", params );
		},
		matchHistory: function( params ) {
			return makeRequest( "profile/:id/:region/:name/matches", params );
		}
	};

	return service;

}])

.factory( "wowApi", [ "battleNetApiRequest", function wowApi( battleNetApiRequest ) {
	"use strict";

	var service = {};

	function makeRequest( path, params ) {
		params = params || {};
		angular.extend( params, { jsonp: "JSON_CALLBACK" });
		return battleNetApiRequest( "wow/" + path, params );
	}

	// characters and guilds have a lot of endpoints that are basically the same with the
	// exception of adding &fields=foo to the URL. we can get rid of a lot of boilerplate
	// by using this method instead of writing it out for each endpoint.
	function withField( field, callback ) {
		return function( params ) {
			angular.extend( params, { fields: field });
			return callback( params );
		}
	}


	service.achievement = function( params ) {
		return makeRequest( "achievement/:id", params );
	};


	service.auction = function( params ) {
		return makeRequest( "auction/data/:realm", params );
	};


{'fraction_non_alphanumeric': 0.14740008594757198, 'fraction_numerical': 0.0030081650193382035, 'mean_word_length': 3.7885802469135803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4184710', 'n_tokens_mistral': 3362, 'n_tokens_neox': 3094, 'n_words': 776}