<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml.Serialization;

namespace Bandwidth.Iris.Model
{
    [XmlType("LnpOrder")]
    public class PortIn: BaseModel
    {
        private const string PortInPath = "portins";
        private const string LoasPath = "loas";

        public async static Task<LnpOrderResponse> Create(Client client, PortIn order)
        {
            var item = await client.MakePostRequest<LnpOrderResponse>(client.ConcatAccountPath(PortInPath), order);
            item.Client = client;
            return item;
        }

#if !PCL
        public static Task<LnpOrderResponse> Create(PortIn order)
        {
            return Create(Client.GetInstance(), order);
        }
#endif

        public async Task<string> CreateFile(Stream stream, string mediaType)
        {
            using (var message = await Client.SendData(Client.ConcatAccountPath(string.Format("{0}/{1}/{2}", PortInPath, Id, LoasPath)), stream, mediaType))
            {
                return
                    XDocument.Parse(await message.Content.ReadAsStringAsync())
                        .Descendants("filename")
                        .FirstOrDefault()
                        .Value;
            }
        }

        public async Task<string> CreateFile(byte[] buffer, string mediaType)
        {
            using (var message = await Client.SendData(Client.ConcatAccountPath(string.Format("{0}/{1}/{2}", PortInPath, Id, LoasPath)), buffer, mediaType))
            {
                return
                    XDocument.Parse(await message.Content.ReadAsStringAsync())
                        .Descendants("filename")
                        .FirstOrDefault()
                        .Value;
            }
        }

        public Task UpdateFile(string fileName, Stream stream, string mediaType)
        {
            return Client.SendData(Client.ConcatAccountPath(string.Format("{0}/{1}/{3}/{2}", PortInPath, Id, fileName, LoasPath)), stream, mediaType, "PUT", true);
        }

        public Task UpdateFile(string fileName, byte[] buffer, string mediaType)
        {
            return Client.SendData(Client.ConcatAccountPath(string.Format("{0}/{1}/{3}/{2}", PortInPath, Id, fileName, LoasPath)), buffer, mediaType, "PUT", true);
        }

        public Task<FileMetadata> GetFileMetadata(string fileName)
        {
            return
                Client.MakeGetRequest<FileMetadata>(
                    Client.ConcatAccountPath(string.Format("{0}/{1}/{3}/{2}/metadata", PortInPath, Id, fileName, LoasPath)));
        }

        public Task DeleteFile(string fileName)
        {
            return
                Client.MakeDeleteRequest(
                    Client.ConcatAccountPath(string.Format("{0}/{1}/{3}/{2}", PortInPath, Id, fileName, LoasPath)));
        }

        public async Task<FileData[]> GetFiles(bool metadata = false)
        {
            var r = (await Client.MakeGetRequest<FileListResponse>(
                Client.ConcatAccountPath(string.Format("{0}/{1}/{2}", PortInPath, Id, LoasPath)),
                new Dictionary<string, object> {{"metadata", metadata.ToString().ToLowerInvariant()}}));
            return (r == null)?new FileData[0]: r.FileData.ToArray();
        }

        public async Task<FileContent> GetFile(string fileName, bool asStream = false)
        {
            if (fileName == null) throw new ArgumentNullException("fileName");

            var response = await Client.MakeGetRequest(
                    Client.ConcatAccountPath(string.Format("{0}/{1}/{2}/{3}", PortInPath, Id, LoasPath, fileName)));
            var content = new FileContent(response) { MediaType = response.Content.Headers.ContentType.MediaType };
            if (asStream)
            {
                content.Stream = await response.Content.ReadAsStreamAsync();
            }
            else
            {
                content.Buffer = await response.Content.ReadAsByteArrayAsync();
            }
            return content;
        }

        public Task Update(LnpOrderSupp item)
        {
            return Client.MakePutRequest(Client.ConcatAccountPath(string.Format("{0}/{1}", PortInPath, Id)),
                item, true);
        }
        public Task Delete()
        {
            return
                Client.MakeDeleteRequest(
                    Client.ConcatAccountPath(string.Format("{0}/{1}", PortInPath, Id)));
        }
        public override string Id {
            get { return OrderId; }
            set { OrderId = value; } 
        }
        public string OrderId { get; set; }
        public string BillingTelephoneNumber { get; set; }
        public Subscriber Subscriber { get; set; }
        public string LoaAuthorizingPerson { get; set; }

        [XmlArrayItem("PhoneNumber")]
        public string[] ListOfPhoneNumbers { get; set; }
        public string SiteId { get; set; }
  
    }

   
    public class LnpOrderResponse : PortIn
    {
        public string ProcessingStatus { get; set; }
        public Status Status { get; set; }
        public bool Triggered { get; set; }
        public string BillingType { get; set; }
        [XmlElement("WirelessInfo")]
        public WirelessInfo[] WirelessInfo { get; set; }
    }

    public class LnpOrderSupp: PortIn
    {
        public DateTime RequestedFocDate { get; set; }
        [XmlElement("WirelessInfo")]
        public WirelessInfo[] WirelessInfo { get; set; }
        public string LosingCarrierName { get; set; }
        public DateTime LastModifiedDate { get; set; }
        [XmlElement("userId")]
        public string UserId { get; set; }
    }

    public class WirelessInfo
    {
        public string AccountNumber { get; set; }
        public string PinNumber { get; set; }
    }

    public class Subscriber
    {
        public string SubscriberType { get; set; }
        public string BusinessName { get; set; }
        public Address ServiceAddress { get; set; }
    }

    
    public class Status
    {
        public string Code { get; set; }
        public string Description { get; set; }
    }

    [XmlType("FileMetaData")]
    public class FileMetadata
    {
        public string DocumentType { get; set; }
        public string DocumentName { get; set; }
    }<commit_msg>Small fixes<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml.Serialization;

namespace Bandwidth.Iris.Model
{
    [XmlType("LnpOrder")]
    public class PortIn: BaseModel
    {
        private const string PortInPath = "portins";
        private const string LoasPath = "loas";

        public async static Task<LnpOrderResponse> Create(Client client, PortIn order)
        {
            var item = await client.MakePostRequest<LnpOrderResponse>(client.ConcatAccountPath(PortInPath), order);
            item.Client = client;
            return item;
        }

#if !PCL
        public static Task<LnpOrderResponse> Create(PortIn order)
        {
            return Create(Client.GetInstance(), order);
        }
#endif

        public async Task<string> CreateFile(Stream stream, string mediaType)
        {
            using (var message = await Client.SendData(Client.ConcatAccountPath(string.Format("{0}/{1}/{2}", PortInPath, Id, LoasPath)), stream, mediaType))
            {
                return
                    XDocument.Parse(await message.Content.ReadAsStringAsync())
                        .Descendants("filename")
                        .FirstOrDefault()
                        .Value;
            }
        }

        public async Task<string> CreateFile(byte[] buffer, string mediaType)
        {
            using (var message = await Client.SendData(Client.ConcatAccountPath(string.Format("{0}/{1}/{2}", PortInPath, Id, LoasPath)), buffer, mediaType))
            {
                return
                    XDocument.Parse(await message.Content.ReadAsStringAsync())
                        .Descendants("filename")
                        .FirstOrDefault()
                        .Value;
            }
        }

        public Task UpdateFile(string fileName, Stream stream, string mediaType)
        {
            return Client.SendData(Client.ConcatAccountPath(string.Format("{0}/{1}/{3}/{2}", PortInPath, Id, fileName, LoasPath)), stream, mediaType, "PUT", true);
        }

        public Task UpdateFile(string fileName, byte[] buffer, string mediaType)
        {
            return Client.SendData(Client.ConcatAccountPath(string.Format("{0}/{1}/{3}/{2}", PortInPath, Id, fileName, LoasPath)), buffer, mediaType, "PUT", true);
        }

        public Task<FileMetadata> GetFileMetadata(string fileName)
        {
            return
                Client.MakeGetRequest<FileMetadata>(
                    Client.ConcatAccountPath(string.Format("{0}/{1}/{3}/{2}/metadata", PortInPath, Id, fileName, LoasPath)));
        }

        public Task DeleteFile(string fileName)
        {
            return
                Client.MakeDeleteRequest(
                    Client.ConcatAccountPath(string.Format("{0}/{1}/{3}/{2}", PortInPath, Id, fileName, LoasPath)));
        }

        public async Task<FileData[]> GetFiles(bool metadata = false)
        {
            var r = (await Client.MakeGetRequest<FileListResponse>(
                Client.ConcatAccountPath(string.Format("{0}/{1}/{2}", PortInPath, Id, LoasPath)),
                new Dictionary<string, object> {{"metadata", metadata.ToString().ToLowerInvariant()}}));
            return (r == null)?new FileData[0]: r.FileData.ToArray();
        }

        public async Task<FileContent> GetFile(string fileName, bool asStream = false)
        {
            if (fileName == null) throw new ArgumentNullException("fileName");

            var response = await Client.MakeGetRequest(
                    Client.ConcatAccountPath(string.Format("{0}/{1}/{2}/{3}", PortInPath, Id, LoasPath, fileName)));
            var content = new FileContent(response) { MediaType = response.Content.Headers.ContentType.MediaType };
            if (asStream)
            {
                content.Stream = await response.Content.ReadAsStreamAsync();
            }
            else
            {
                content.Buffer = await response.Content.ReadAsByteArrayAsync();
            }
            return content;
        }

        public Task Update(LnpOrderSupp item)
        {
            return Client.MakePutRequest(Client.ConcatAccountPath(string.Format("{0}/{1}", PortInPath, Id)),
                item, true);
        }
        public Task Delete()
        {
            return
                Client.MakeDeleteRequest(
                    Client.ConcatAccountPath(string.Format("{0}/{1}", PortInPath, Id)));
        }
        public override string Id {
            get { return OrderId; }
            set { OrderId = value; } 
        }
        public string OrderId { get; set; }
        public string BillingTelephoneNumber { get; set; }
        public Subscriber Subscriber { get; set; }
        public string LoaAuthorizingPerson { get; set; }

        [XmlArrayItem("PhoneNumber")]
        public string[] ListOfPhoneNumbers { get; set; }
        public string SiteId { get; set; }
  
    }

   
    public class LnpOrderResponse : PortIn
    {
        public string ProcessingStatus { get; set; }
        public Status Status { get; set; }
        public bool Triggered { get; set; }
        public string BillingType { get; set; }
        [XmlElement("WirelessInfo")]
        public WirelessInfo[] WirelessInfo { get; set; }
        public string LosingCarrierName { get; set; }
        public DateTime LastModifiedDate { get; set; }
        [XmlElement("userId")]
        public string UserId { get; set; }

    }

    public class LnpOrderSupp: PortIn
    {
        public DateTime RequestedFocDate { get; set; }
        [XmlElement("WirelessInfo")]
        public WirelessInfo[] WirelessInfo { get; set; }
    }

    public class WirelessInfo
    {
        public string AccountNumber { get; set; }
        public string PinNumber { get; set; }
    }

    public class Subscriber
    {
        public string SubscriberType { get; set; }
        public string BusinessName { get; set; }
        public Address ServiceAddress { get; set; }
    }

    
    public class Status
    {
        public string Code { get; set; }
        public string Description { get; set; }
    }

    [XmlType("FileMetaData")]
    public class FileMetadata
    {
        public string DocumentType { get; set; }
        public string DocumentName { get; set; }
    }
{'fraction_non_alphanumeric': 0.10774675580023595, 'fraction_numerical': 0.005348014156508062, 'mean_word_length': 2.0486693838408057, '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': '3719690', 'n_tokens_mistral': 3404, 'n_tokens_neox': 3338, 'n_words': 811}