<commit_before>﻿using System;
using System.IO;
using System.Linq;

using XeroApi.Model;
using XeroApi.Model.Reporting;

namespace XeroApi.ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Do you want to run as a public or private application?");
            Console.WriteLine(" Press 1 for a public application");
            Console.WriteLine(" Press 2 for a private application");
            Console.WriteLine(" Press 3 for a partner application");

            ConsoleKeyInfo keyInfo = Console.ReadKey(true);
            Console.WriteLine();

            if (keyInfo.KeyChar == '1')
            {
                Console.WriteLine("Running as a public application...");
                ExerciseOrganisation(PublicApplicationRunner.CreateRepository());
            }
            if (keyInfo.KeyChar == '2')
            {
                Console.WriteLine("Running as a private application...");
                ExerciseOrganisation(PrivateApplicationRunner.CreateRepository());
            }
            if (keyInfo.KeyChar == '3')
            {
                Console.WriteLine("Running as a partner application...");
                ExerciseOrganisation(PartnerApplicationRunner.CreateRepository());
            }

            Console.WriteLine("");
            Console.WriteLine(" Press Enter to Exit");
            Console.ReadLine();
        }

        static void ExerciseOrganisation(Repository repository)
        {
            if (repository == null)
            {
                return;
            }

            // Make a call to api.xero.com to check that we can use the access token.
            Organisation organisation = repository.Organisation;
            Console.WriteLine(string.Format("You have been authorised against organisation: {0}", organisation.Name));

            

            // Make a PUT call to the API - add a dummy contact
            Console.WriteLine("Please enter the name of a new contact to add to Xero");
            string contactName = Console.ReadLine();

            if (string.IsNullOrEmpty(contactName))
            {
                return;
            }
            
            Contact contact = new Contact { Name = contactName };
            
            contact = repository.UpdateOrCreate(contact);
            Console.WriteLine(string.Format("The contact '{0}' was created with id: {1}", contact.Name, contact.ContactID));
            Console.WriteLine(string.Format("The validation status was: {0}", contact.ValidationStatus));

            


            // Try to update the contact that's just been created, but this time use a POST method
            contact.EmailAddress = string.Format("{<EMAIL>", contact.Name.ToLower().Replace(" ", "."));
            
            contact = repository.UpdateOrCreate(contact);
            Console.WriteLine(string.Format("The contact '{0}' was updated with email address: {1}", contact.Name, contact.EmailAddress));

            <commit_msg>Add test for filter 'GET Accounts' on new ShowInExpenseClaims property<commit_after>﻿using System;
using System.IO;
using System.Linq;

using XeroApi.Model;
using XeroApi.Model.Reporting;

namespace XeroApi.ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Do you want to run as a public or private application?");
            Console.WriteLine(" Press 1 for a public application");
            Console.WriteLine(" Press 2 for a private application");
            Console.WriteLine(" Press 3 for a partner application");

            ConsoleKeyInfo keyInfo = Console.ReadKey(true);
            Console.WriteLine();

            if (keyInfo.KeyChar == '1')
            {
                Console.WriteLine("Running as a public application...");
                ExerciseOrganisation(PublicApplicationRunner.CreateRepository());
            }
            if (keyInfo.KeyChar == '2')
            {
                Console.WriteLine("Running as a private application...");
                ExerciseOrganisation(PrivateApplicationRunner.CreateRepository());
            }
            if (keyInfo.KeyChar == '3')
            {
                Console.WriteLine("Running as a partner application...");
                ExerciseOrganisation(PartnerApplicationRunner.CreateRepository());
            }

            Console.WriteLine("");
            Console.WriteLine(" Press Enter to Exit");
            Console.ReadLine();
        }

        static void ExerciseOrganisation(Repository repository)
        {
            if (repository == null)
            {
                return;
            }

            // Make a call to api.xero.com to check that we can use the access token.
            Organisation organisation = repository.Organisation;
            Console.WriteLine(string.Format("You have been authorised against organisation: {0}", organisation.Name));





            // API v2.15 Get a list of accounts that can be used when creating expense claims
            var expenseClaimAccounts = repository.Accounts.Where(a => a.ShowInExpenseClaims == true).ToList();
            Console.WriteLine("There are {0} accounts that can be used in expense claim line items", expenseClaimAccounts.Count);

            foreach (var account in expenseClaimAccounts)
                Console.WriteLine("Expense Account, name:{0} code:{1}", account.Name, account.Code);



            

            // Make a PUT call to the API - add a dummy contact
            Console.WriteLine("Please enter the name of a new contact to add to Xero");
            string contactName = Console.ReadLine();

            if (string.IsNullOrEmpty(contactName))
            {
                return;
            }
            
            Contact contact = new Contact { Name = contactName };
            
            contact = repository.UpdateOrCreate(contact);
            Console.WriteLine(string.Format("The contact '{0}' was created with id: {1}", contact.Name, contact.ContactID));
            Console.WriteLine(string.Format("The validation status was: {0}", contact.ValidationStatus));

            

            // Try to update the contact that's just been created, but this time use a POST method
            contact.EmailAddress = string.Format("{<EMAIL>", contact.Name.ToLower().Replace(" ", "."));
            
            contact = repository.UpdateOrCreate(contact);
            Console.WriteLine(string.Format("The contact '{0}' was updated with email address: {1}", contact.Name, contact.EmailAddress));

            
{'fraction_non_alphanumeric': 0.097479501973884, 'fraction_numerical': 0.004555116914667477, 'mean_word_length': 1.9832427536231885, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, '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': '4877313', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1477, 'n_words': 466}