<commit_before>/*
* Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.
*/

(function () {
	angular
		.module('app')
		.controller('MainController', MainController);

	/**
	 * The MainController code.
	 */
	MainController.$inject = ['$scope', '$q', 'adalAuthenticationService', 'commonFactory', 'usersFactory', 'groupsFactory', 'drivesFactory', 'contactsFactory'];
	function MainController($scope, $q, adalAuthenticationService, common, users, groups, drives, contacts) {
		var vm = this;
		
		// Snippet constructor from commonFactory.
		var Snippet = common.Snippet;
		
		/////////////////////////
		// Snippet             //
		// -------             //
		// Title               //
		// Description         //
		// Documenation URL    //
		// API URL             //
		// Require admin?      //
		// Snippet code        //
		/////////////////////////
		
		////////////////////////////////////////////////
		// All of the snippets that fall under the    //
		// 'users' tenant-level resource collection.  //
		////////////////////////////////////////////////
		var usersSnippets = {
			groupTitle: 'users',
			snippets: [
				///////////////////////////////
				//       USER SNIPPETS       // 
				///////////////////////////////				
				new Snippet(
					'GET myOrganization/users',
					'Gets all of the users in your tenant\'s directory.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_User',
					'https://graph.microsoft.com/beta/myOrganization/users',
					false,				
					function () {
						doSnippet(partial(users.getUsers, false));
					}),
				new Snippet(
					'GET myOrganization/users?$filter=country eq \'United States\'',
					'Gets all of the users in your tenant\'s directory who are from the United States, using $filter.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_User',
					'https://graph.microsoft.com/beta/myOrganization/users?$filter=country eq \'United States\'',
					false,
					function () {
						doSnippet(partial(users.getUsers, true));
					}),
				new Snippet(
					'POST myOrganization/users',
					'Adds a new user to the tenant\'s directory.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_User',
					'https://graph.microsoft.com/beta/myOrganization/users',
					true,					
					function () {
						doSnippet(partial(users.createUser, tenant));
					}),
				new Snippet(
					'GET me',
					'Gets information about the signed-in user.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_User',
					'https://graph.microsoft.com/beta/me',
					false,					
					function () {
						doSnippet(partial(users.getMe, false));
					}),
				new Snippet(
					'GET me?$select=AboutMe,Responsibilities,Tags',
					'Gets select information about the signed-in user, using $select.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_User',
					'https://graph.microsoft.com/beta/me?$select=AboutMe,Responsibilities,Tags',	
					false,				
					function () {
						doSnippet(partial(users.getMe, true));
					}),
				//////////////////////////////////////
				//        USER/DRIVE SNIPPETS       //
				//////////////////////////////////////								
				new Snippet(
					'GET me/drive',
					'Gets the signed-in user\'s drive.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_Drive',
					'https://graph.microsoft.com/beta/me/drive',
					false,					
					function () {
						doSnippet(users.getDrive);
					}),
				///////////////////////////////////////
				//        USER/EVENTS SNIPPETS       //
				///////////////////////////////////////
				new Snippet(
					'GET me/events',
					'Gets the signed-in user\'s calendar events.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_Event',
					'https://graph.microsoft.com/beta/me/events',	
					false,				
					function () {
						doSnippet(users.getEvents);
					}),
				new Snippet(
					'POST me/events',
					'Adds an event to the signed-in user\'s calendar.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_Event',
					'https://graph.microsoft.com/beta/me/events',	
					false,				
					function () {
						doSnippet(users.createEvent);
					}),
				new Snippet(
					'PATCH me/events/{Event.Id}',
					'Adds an event to the signed-in user\'s calendar, then updates the subject of the event.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_Event',
					'https://graph.microsoft.com/beta/me/events/{Event.Id}',
					false,					
					function () {
						doSnippet(users.updateEvent);
					}),
				new Snippet(
					'DELETE me/events/{Event.Id}',
					'Adds an event to the signed-in user\'s calendar, then deletes the event.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_Event',
					'https://graph.microsoft.com/beta/me/events/{Event.Id}',
					false,					
					function () {
						doSnippet(users.deleteEvent);
					}),
				//////////////////////////////////////////
				//        USER/MESSAGES SNIPPETS        //
				//////////////////////////////////////////
				new Snippet(
					'GET me/messages',
					'Gets the signed-in user\'s emails.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_relationship_Messages',
					'https://graph.microsoft.com/beta/me/messages',	
					false,				
					function () {
						doSnippet(users.getMessages);
					}),
				new Snippet(
					'POST me/messages/sendMail',
					'Sends an email as the signed-in user and saves a copy to their Sent Items folder.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_action_user_sendMail',
					'https://graph.microsoft.com/beta/me/messages/sendMail',
					false,					
					function () {
						doSnippet(partial(users.sendMessage, adalAuthenticationService.userInfo.userName));
					}),
				///////////////////////////////////////////////
				//        MISCELLANEOUS USER SNIPPETS        //
				///////////////////////////////////////////////
				new Snippet(
					'GET me/manager',
					'Gets the signed-in user\'s manager.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_relationship_manager',
					'https://graph.microsoft.com/beta/me/manager',
					false,					<commit_msg>Corrected snippet name in menu.<commit_after>/*
* Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.
*/

(function () {
	angular
		.module('app')
		.controller('MainController', MainController);

	/**
	 * The MainController code.
	 */
	MainController.$inject = ['$scope', '$q', 'adalAuthenticationService', 'commonFactory', 'usersFactory', 'groupsFactory', 'drivesFactory', 'contactsFactory'];
	function MainController($scope, $q, adalAuthenticationService, common, users, groups, drives, contacts) {
		var vm = this;
		
		// Snippet constructor from commonFactory.
		var Snippet = common.Snippet;
		
		/////////////////////////
		// Snippet             //
		// -------             //
		// Title               //
		// Description         //
		// Documenation URL    //
		// API URL             //
		// Require admin?      //
		// Snippet code        //
		/////////////////////////
		
		////////////////////////////////////////////////
		// All of the snippets that fall under the    //
		// 'users' tenant-level resource collection.  //
		////////////////////////////////////////////////
		var usersSnippets = {
			groupTitle: 'users',
			snippets: [
				///////////////////////////////
				//       USER SNIPPETS       // 
				///////////////////////////////				
				new Snippet(
					'GET myOrganization/users',
					'Gets all of the users in your tenant\'s directory.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_User',
					'https://graph.microsoft.com/beta/myOrganization/users',
					false,				
					function () {
						doSnippet(partial(users.getUsers, false));
					}),
				new Snippet(
					'GET myOrganization/users?$filter=country eq \'United States\'',
					'Gets all of the users in your tenant\'s directory who are from the United States, using $filter.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_User',
					'https://graph.microsoft.com/beta/myOrganization/users?$filter=country eq \'United States\'',
					false,
					function () {
						doSnippet(partial(users.getUsers, true));
					}),
				new Snippet(
					'POST myOrganization/users',
					'Adds a new user to the tenant\'s directory.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_User',
					'https://graph.microsoft.com/beta/myOrganization/users',
					true,					
					function () {
						doSnippet(partial(users.createUser, tenant));
					}),
				new Snippet(
					'GET me',
					'Gets information about the signed-in user.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_User',
					'https://graph.microsoft.com/beta/me',
					false,					
					function () {
						doSnippet(partial(users.getMe, false));
					}),
				new Snippet(
					'GET me?$select=AboutMe,Responsibilities,Tags',
					'Gets select information about the signed-in user, using $select.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_User',
					'https://graph.microsoft.com/beta/me?$select=AboutMe,Responsibilities,Tags',	
					false,				
					function () {
						doSnippet(partial(users.getMe, true));
					}),
				//////////////////////////////////////
				//        USER/DRIVE SNIPPETS       //
				//////////////////////////////////////								
				new Snippet(
					'GET me/drive',
					'Gets the signed-in user\'s drive.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_Drive',
					'https://graph.microsoft.com/beta/me/drive',
					false,					
					function () {
						doSnippet(users.getDrive);
					}),
				///////////////////////////////////////
				//        USER/EVENTS SNIPPETS       //
				///////////////////////////////////////
				new Snippet(
					'GET me/events',
					'Gets the signed-in user\'s calendar events.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_Event',
					'https://graph.microsoft.com/beta/me/events',	
					false,				
					function () {
						doSnippet(users.getEvents);
					}),
				new Snippet(
					'POST me/events',
					'Adds an event to the signed-in user\'s calendar.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_Event',
					'https://graph.microsoft.com/beta/me/events',	
					false,				
					function () {
						doSnippet(users.createEvent);
					}),
				new Snippet(
					'PATCH me/events/{Event.Id}',
					'Adds an event to the signed-in user\'s calendar, then updates the subject of the event.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_Event',
					'https://graph.microsoft.com/beta/me/events/{Event.Id}',
					false,					
					function () {
						doSnippet(users.updateEvent);
					}),
				new Snippet(
					'DELETE me/events/{Event.Id}',
					'Adds an event to the signed-in user\'s calendar, then deletes the event.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_entityType_Event',
					'https://graph.microsoft.com/beta/me/events/{Event.Id}',
					false,					
					function () {
						doSnippet(users.deleteEvent);
					}),
				//////////////////////////////////////////
				//        USER/MESSAGES SNIPPETS        //
				//////////////////////////////////////////
				new Snippet(
					'GET me/messages',
					'Gets the signed-in user\'s emails.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_relationship_Messages',
					'https://graph.microsoft.com/beta/me/messages',	
					false,				
					function () {
						doSnippet(users.getMessages);
					}),
				new Snippet(
					'POST me/sendMail',
					'Sends an email as the signed-in user and saves a copy to their Sent Items folder.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_action_user_sendMail',
					'https://graph.microsoft.com/beta/me/sendMail',
					false,					
					function () {
						doSnippet(partial(users.sendMessage, adalAuthenticationService.userInfo.userName));
					}),
				///////////////////////////////////////////////
				//        MISCELLANEOUS USER SNIPPETS        //
				///////////////////////////////////////////////
				new Snippet(
					'GET me/manager',
					'Gets the signed-in user\'s manager.',
					'https://msdn.microsoft.com/office/office365/HowTo/office-365-unified-api-reference#msg_ref_relationship_manager',
					'https://graph.microsoft.com/beta/me/manager',
					false,					
{'fraction_non_alphanumeric': 0.20949638162752918, 'fraction_numerical': 0.011519716437749225, 'mean_word_length': 1.9505446623093683, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 52, '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': '6629306', 'n_tokens_mistral': 5368, 'n_tokens_neox': 3916, 'n_words': 692}