<commit_before>﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using ONIT.VismaNetApi.Dynamic;
using ONIT.VismaNetApi.Exceptions;
using ONIT.VismaNetApi.Lib;
using ONIT.VismaNetApi.Lib.Data;
using ONIT.VismaNetApi.Models;

namespace ONIT.VismaNetApi
{
    [ComVisible(true)]
    public class VismaNet : VismaNetDynamicHandler
    {
        public readonly CashSaleData CashSales;
        public readonly CustomerDocumentData CustomerDocuments;
        public readonly CustomerInvoiceData CustomerInvoices;
        public readonly CustomerData Customers;
        public readonly DimensionData Dimensions;
        public readonly SupplierInvoiceData SupplierInvoices;
        public readonly SupplierData Suppliers;
        public readonly InventoryData Inventory;
        public readonly FinAccountData Accounts;
        public readonly EmployeeData Employee;
        public readonly CreditNoteData CreditNote;
        public readonly ShipmentData Shipments;
        public readonly ContactData Contacts;
        public readonly ProjectData Projects;
        public readonly SalesOrderData SalesOrder;
        public readonly JournalTransactionData JournalTransactions;
        public readonly PaymentData Payments;
        public readonly BranchData Branches;

        /// <summary>
        ///     Creates a connection using token.
        /// </summary>
        /// <param name="companyId">Company context</param>
        /// <param name="token">The predefined token from Visma.net</param>
        /// <param name="branchId">Branch ID to work with in the Visma.net Company (optional)</param>
        public VismaNet(int companyId, string token, int branchId = 0)
        {
            if (string.IsNullOrEmpty(token))
                throw new InvalidArgumentsException("Token is missing");

            Auth = new VismaNetAuthorization
            {
                Token = token,
                CompanyId = companyId,
                BranchId = branchId
            };
            Customers = new CustomerData(Auth);
            CustomerInvoices = new CustomerInvoiceData(Auth);
            Suppliers = new SupplierData(Auth);
            SupplierInvoices = new SupplierInvoiceData(Auth);
            CashSales = new CashSaleData(Auth);
            CustomerDocuments = new CustomerDocumentData(Auth);
            Dimensions = new DimensionData(Auth);
            Inventory = new InventoryData(Auth);
            JournalTransactions = new JournalTransactionData(Auth);
            Accounts = new FinAccountData(Auth);
            Employee = new EmployeeData(Auth);
            CreditNote = new CreditNoteData(Auth);
            Shipments = new ShipmentData(Auth);
            Contacts = new ContactData(Auth);
            Projects = new ProjectData(Auth);
            SalesOrder = new SalesOrderData(Auth);
            Payments = new PaymentData(Auth);
            Branches = new BranchData(Auth);
        }

        public static string Version { get; private set; }
        /// <summary>
        /// Provide a name for your application. This will make it easier for Visma to identify your integration in their logs.
        /// </summary>
        public static string ApplicationName { get; set; }
        static VismaNet()
        {
            Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }

        public async Task<bool> TestConnectionAsyncTask()
        {
            return await VismaNetApiHelper.TestConnection(Auth);
        }

        public bool TestConnection()
        {
            try
            {
                return TestConnectionAsyncTask().GetAwaiter().GetResult();
            }<commit_msg>Renamed all endpoints to be consistent with API<commit_after>﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using ONIT.VismaNetApi.Dynamic;
using ONIT.VismaNetApi.Exceptions;
using ONIT.VismaNetApi.Lib;
using ONIT.VismaNetApi.Lib.Data;
using ONIT.VismaNetApi.Models;

namespace ONIT.VismaNetApi
{
    [ComVisible(true)]
    public class VismaNet : VismaNetDynamicHandler
    {
        public readonly CashSaleData CashSale;
        public readonly CustomerDocumentData CustomerDocument;
        public readonly CustomerInvoiceData CustomerInvoice;
        public readonly CustomerData Customer;
        public readonly DimensionData Dimension;
        public readonly SupplierInvoiceData SupplierInvoice;
        public readonly SupplierData Supplier;
        public readonly InventoryData Inventory;
        public readonly FinAccountData Account;
        public readonly EmployeeData Employee;
        public readonly CreditNoteData CreditNote;
        public readonly ShipmentData Shipment;
        public readonly ContactData Contact;
        public readonly ProjectData Project;
        public readonly SalesOrderData SalesOrder;
        public readonly JournalTransactionData JournalTransaction;
        public readonly PaymentData Payment;
        public readonly BranchData Branch;

        /// <summary>
        ///     Creates a connection using token.
        /// </summary>
        /// <param name="companyId">Company context</param>
        /// <param name="token">The predefined token from Visma.net</param>
        /// <param name="branchId">Branch ID to work with in the Visma.net Company (optional)</param>
        public VismaNet(int companyId, string token, int branchId = 0)
        {
            if (string.IsNullOrEmpty(token))
                throw new InvalidArgumentsException("Token is missing");

            Auth = new VismaNetAuthorization
            {
                Token = token,
                CompanyId = companyId,
                BranchId = branchId
            };
            Customer = new CustomerData(Auth);
            CustomerInvoice = new CustomerInvoiceData(Auth);
            Supplier = new SupplierData(Auth);
            SupplierInvoice = new SupplierInvoiceData(Auth);
            CashSale = new CashSaleData(Auth);
            CustomerDocument = new CustomerDocumentData(Auth);
            Dimension = new DimensionData(Auth);
            Inventory = new InventoryData(Auth);
            JournalTransaction = new JournalTransactionData(Auth);
            Account = new FinAccountData(Auth);
            Employee = new EmployeeData(Auth);
            CreditNote = new CreditNoteData(Auth);
            Shipment = new ShipmentData(Auth);
            Contact = new ContactData(Auth);
            Project = new ProjectData(Auth);
            SalesOrder = new SalesOrderData(Auth);
            Payment = new PaymentData(Auth);
            Branch = new BranchData(Auth);
        }

        public static string Version { get; private set; }
        /// <summary>
        /// Provide a name for your application. This will make it easier for Visma to identify your integration in their logs.
        /// </summary>
        public static string ApplicationName { get; set; }
        static VismaNet()
        {
            Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }

        public async Task<bool> TestConnectionAsyncTask()
        {
            return await VismaNetApiHelper.TestConnection(Auth);
        }

        public bool TestConnection()
        {
            try
            {
                return TestConnectionAsyncTask().GetAwaiter().GetResult();
            }
{'fraction_non_alphanumeric': 0.07249466950959488, 'fraction_numerical': 0.00026652452025586353, 'mean_word_length': 2.3504464285714284, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '3187110', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1760, 'n_words': 519}