Class/Orbit.Classes.psm1

# Module: Orbit
# Function: Classes
# Author: David Eberhardt
# Updated: 09-JUL 2023
# Status: Live

# to use, bind them with 'using Module Orbit' in individual scripts
# all sub-modules have this file and their own classes file linked in module psm1.


#region Classes used by all modules
# M365 License
class OrbitM365LicensePublished {
  [string]$ProductName
  [string]$SkuPartNumber
  [string]$LicenseType
  [string]$ParameterName
  [bool]$IncludesTeams
  [bool]$IncludesPhoneSystem
  [ValidatePattern('^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$')]
  [string]$SkuId
  [object]$ServicePlans

  OrbitM365LicensePublished(
    [string]$ProductName,
    [string]$SkuPartNumber,
    [string]$LicenseType,
    [string]$ParameterName,
    [bool]$IncludesTeams,
    [bool]$IncludesPhoneSystem,
    [string]$SkuId,
    [object]$ServicePlans
  ) {
    $this.ProductName = $ProductName
    $this.SkuPartNumber = $SkuPartNumber
    $this.LicenseType = $LicenseType
    $this.ParameterName = $ParameterName
    $this.IncludesTeams = $IncludesTeams
    $this.IncludesPhoneSystem = $IncludesPhoneSystem
    $this.SkuId = $SkuId
    $this.ServicePlans = $ServicePlans
  }
}

# M365 License in the tenant (includes utilisation)
class OrbitM365LicenseTenant : OrbitM365LicensePublished {
  [int]$Available
  [int]$Consumed
  [int]$Remaining
  [int]$Expiring

  OrbitM365LicenseTenant(
    [string]$ProductName,
    [string]$SkuPartNumber,
    [string]$LicenseType,
    [string]$ParameterName,
    [bool]$IncludesTeams,
    [bool]$IncludesPhoneSystem,
    [string]$SkuId,
    [object]$ServicePlans,
    [int]$Available,
    [int]$Consumed,
    [int]$Remaining,
    [int]$Expiring
  ) : base (
    $ProductName,
    $SkuPartNumber,
    $LicenseType,
    $ParameterName,
    $IncludesTeams,
    $IncludesPhoneSystem,
    $SkuId,
    $ServicePlans
  ) {
    $this.Available = $Available
    $this.Consumed = $Consumed
    $this.Remaining = $Remaining
    $this.Expiring = $Expiring
  }
}

# M365 License Service Plan (linked here to have all in one spot)
class OrbitM365LicenseServicePlan {
  [string]$ProductName
  [string]$ServicePlanName
  [ValidatePattern('^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$')]
  [string]$ServicePlanId
  [bool]$RelevantForTeams

  OrbitM365LicenseServicePlan(
    [string]$ProductName,
    [string]$ServicePlanName,
    [string]$ServicePlanId,
    [bool]$RelevantForTeams
  ) {
    $this.ProductName = $ProductName
    $this.ServicePlanName = $ServicePlanName
    $this.ServicePlanId = $ServicePlanId
    $this.RelevantForTeams = $RelevantForTeams
  }
}
#endregion

#region Orbit.Tools
# OrbitCountry
class OrbitCountry {
  [string]$Name
  [string]$TwoLetterCode
  [string]$ThreeLetterCode
  [string]$NumericCode
  [int]$DialCode
  [GeoRegion]$Region
  [string]$TimeZone

  OrbitCountry(
    [string]$Name,
    [string]$TwoLetterCode,
    [string]$ThreeLetterCode,
    [string]$NumericCode,
    [int]$DialCode,
    [GeoRegion]$Region,
    [string]$TimeZone

  ) {
    $this.Name = $Name
    $this.TwoLetterCode = $TwoLetterCode
    $this.ThreeLetterCode = $ThreeLetterCode
    $this.NumericCode = $NumericCode
    $this.DialCode = $DialCode
    $this.Region = $Region
    $this.TimeZone = $TimeZone
  }
}
#endregion

#region Orbit.Teams
# Callable Entity
class OrbitCallableEntity {
  [string]$Entity
  [string]$Identity
  [string]$ObjectType
  [string]$Type

  OrbitCallableEntity(
    [string]$Entity,
    [string]$Identity,
    [string]$ObjectType,
    [string]$Type
  ) {
    $this.Entity = $Entity
    $this.Identity = $Identity
    $this.ObjectType = $ObjectType
    $this.Type = $Type
  }
}

# Callable Entity Connection (to CQ/AA)
class OrbitCallableEntityConnection {
  [string]$Identity
  [string]$LinkedAs
  [string]$Type
  [string]$Name
  [string]$ObjectId

  OrbitCallableEntityConnection(
    [string]$Identity,
    [string]$LinkedAs,
    [string]$Type,
    [string]$Name,
    [string]$ObjectId
  ) {
    $this.Identity = $Identity
    $this.LinkedAs = $LinkedAs
    $this.Type = $Type
    $this.Name = $Name
    $this.ObjectId = $ObjectId
  }
}

# Phone Number Object for Get-TeamsPhoneNumber
class OrbitPhoneNumber {
  [string]$PhoneNumber
  [ValidateSet('CallingPlan', 'OperatorConnect', 'DirectRouting')]
  [string]$NumberType
  [AllowNull()]
  [string]$LocationId
  [AllowNull()]
  [string]$LocationName
  [AllowNull()]
  [string]$City
  [AllowNull()]
  [string[]]$Capability
  [nullable[bool]]$Assigned
  [AllowNull()]
  [string]$AssignedTo
  [AllowNull()]
  [string]$AssignedToSIP
  [AllowNull()]
  [string]$AssignedToObjectType
  [AllowNull()]
  [string]$AssignedPstnTargetId
}

# Calling Settings
class OrbitCallingSettingsDelegate {
  [string]$Id
  [string]$Delegator
  [bool]$ReceiveCalls
  [bool]$MakeCalls
  [bool]$ManageSettings

  OrbitCallingSettingsDelegate(
    [string]$Id,
    [string]$Delegator,
    [bool]$ReceiveCalls,
    [bool]$MakeCalls,
    [bool]$ManageSettings
  ) {
    $this.Id = $Id
    $this.Delegator = $Delegator
    $this.ReceiveCalls = $ReceiveCalls
    $this.MakeCalls = $MakeCalls
    $this.ManageSettings = $ManageSettings
  }
}

class OrbitCallingSettingsDelegator {
  [string]$Id
  [string]$Delegate
  [bool]$ReceiveCalls
  [bool]$MakeCalls
  [bool]$ManageSettings

  OrbitCallingSettingsDelegator(
    [string]$Id,
    [string]$Delegate,
    [bool]$ReceiveCalls,
    [bool]$MakeCalls,
    [bool]$ManageSettings
  ) {
    $this.Id = $Id
    $this.Delegate = $Delegate
    $this.ReceiveCalls = $ReceiveCalls
    $this.MakeCalls = $MakeCalls
    $this.ManageSettings = $ManageSettings
  }
}

class OrbitCallingSettingsCallGroupTarget {
  [string]$CallGroupMemberId
  [string]$CallGroupOwnerId

  OrbitCallingSettingsCallGroupTarget(
    [string]$CallGroupMemberId,
    [string]$CallGroupOwnerId
  ) {
    $this.CallGroupMemberId = $CallGroupMemberId
    $this.CallGroupOwnerId = $CallGroupOwnerId
  }
}

class OrbitCallingSettingsGroupMembershipDetails {
  [string]$CallGroupOwnerId
  [string]$CallGroupMemberId
  [string]$NotificationSetting

  OrbitCallingSettingsGroupMembershipDetails(
    [string]$CallGroupOwnerId,
    [string]$CallGroupMemberId,
    [string]$NotificationSetting
  ) {
    $this.CallGroupOwnerId = $CallGroupOwnerId
    $this.CallGroupMemberId = $CallGroupMemberId
    $this.NotificationSetting = $NotificationSetting
  }
}

# OrbitVoiceRoutingChain
class OrbitVoiceRoutingChain {
  [string]$OnlineVoiceRoutingPolicy
  $OnlinePstnUsageList
  $OnlineVoiceRouteList
  $OnlinePstnGatewayList
  [String]$NumberPattern
  hidden [System.Collections.Generic.List[object]]$VoiceRoutingChain

  OrbitVoiceRoutingChain(
    [string]$OnlineVoiceRoutingPolicy,
    $OnlinePstnUsageList,
    $OnlineVoiceRouteList,
    $OnlinePstnGatewayList,
    $NumberPattern
  ) {
    $this.OnlineVoiceRoutingPolicy = $OnlineVoiceRoutingPolicy
    $this.OnlinePstnUsageList = $OnlinePstnUsageList
    $this.OnlineVoiceRouteList = $OnlineVoiceRouteList
    $this.OnlinePstnGatewayList = $OnlinePstnGatewayList
    $this.NumberPattern = $NumberPattern
  }
}

# OrbitVoiceNormalizationRule
class OrbitVoiceNormalizationRule {
  [string]$DialPlanName
  [string]$Name
  [string]$Description
  [string]$Pattern
  [string]$Translation
  [string]$IsInternalExtension

  OrbitVoiceNormalizationRule(
    [string]$DialPlanName,
    [string]$Name,
    [string]$Description,
    [string]$Pattern,
    [string]$Translation,
    [bool]$IsInternalExtension
  ) {
    $this.DialPlanName = $DialPlanName
    $this.Name = $Name
    $this.Description = $Description
    $this.Pattern = $Pattern
    $this.Translation = $Translation
    $this.IsInternalExtension = $IsInternalExtension
  }
}

# OrbitVoiceRoutingInfo
class OrbitVoiceRoutingInfo {
  [string]$UserPrincipalName
  [string]$TenantDialPlan
  [string]$DialedNumber
  [string]$EffectiveDialPlan
  [string]$MatchingRule
  [string]$MatchingPattern
  [string]$TranslatedNumber
  [string]$OnlineVoiceRoutingPolicy
  [string]$OnlinePstnUsage
  $MatchedVoiceRoutes #Can be a string or an Object
  [string]$OnlineVoiceRoute
  [string]$OnlinePstnGateway
  [string]$NumberPattern

  OrbitVoiceRoutingInfo(
    [string]$UserPrincipalName,
    [string]$TenantDialPlan,
    [string]$DialedNumber,
    [string]$EffectiveDialPlan,
    [string]$MatchingRule,
    [string]$MatchingPattern,
    [string]$TranslatedNumber,
    [string]$OnlineVoiceRoutingPolicy,
    [string]$OnlinePstnUsage,
    $MatchedVoiceRoutes,
    [string]$OnlineVoiceRoute,
    [string]$OnlinePstnGateway,
    [string]$NumberPattern
  ) {
    $this.UserPrincipalName = $UserPrincipalName
    $this.TenantDialPlan = $TenantDialPlan
    $this.DialedNumber = $DialedNumber
    $this.EffectiveDialPlan = $EffectiveDialPlan
    $this.MatchingRule = $MatchingRule
    $this.MatchingPattern = $MatchingPattern
    $this.TranslatedNumber = $TranslatedNumber
    $this.OnlineVoiceRoutingPolicy = $OnlineVoiceRoutingPolicy
    $this.OnlinePstnUsage = $OnlinePstnUsage
    $this.MatchedVoiceRoutes = $MatchedVoiceRoutes
    $this.OnlineVoiceRoute = $OnlineVoiceRoute
    $this.OnlinePstnGateway = $OnlinePstnGateway
    $this.NumberPattern = $NumberPattern
  }
}


# OrbitEmergencyVoiceRouting
class OrbitEmergencyVoiceRouting {
  [string]$DialedNumber
  [string]$TenantDialPlan
  [string]$EffectiveDialPlan
  [string]$MatchingRule
  [string]$MatchingPattern
  [string]$TranslatedNumber
  [string]$NetworkSite
  [string]$UserPrincipalName
  [string]$SiteEmergencyCallingPolicy
  [string]$UserEmergencyCallingPolicy
  [string]$EffectiveEmergencyCallingPolicy
  [string]$SiteEmergencyCallRoutingPolicy
  [string]$UserEmergencyCallRoutingPolicy
  [string]$EffectiveEmergencyCallRoutingPolicy
  [string]$OnlineVoiceRoutingPolicy
  [string]$EffectiveEmergencyDialString
  [string]$MatchedEmergencyDialMask
  [string]$NetworkPathTaken
  [string]$OnlinePstnUsage
  $MatchedVoiceRoutes #Can be a string or an Object
  [string]$OnlineVoiceRoute
  [string]$OnlinePstnGateway
  $OnlinePstnGatewayPidfLoSupported #Can be a string or an Object
  [string]$NumberPattern

  OrbitEmergencyVoiceRouting (
    [string]$DialedNumber,
    [string]$TenantDialPlan,
    [string]$EffectiveDialPlan,
    [string]$MatchingRule,
    [string]$MatchingPattern,
    [string]$TranslatedNumber,
    [string]$NetworkSite,
    [string]$UserPrincipalName,
    [string]$SiteEmergencyCallingPolicy,
    [string]$UserEmergencyCallingPolicy,
    [string]$EffectiveEmergencyCallingPolicy,
    [string]$SiteEmergencyCallRoutingPolicy,
    [string]$UserEmergencyCallRoutingPolicy,
    [string]$EffectiveEmergencyCallRoutingPolicy,
    [string]$OnlineVoiceRoutingPolicy,
    [string]$EffectiveEmergencyDialString,
    [string]$MatchedEmergencyDialMask,
    [string]$NetworkPathTaken,
    [string]$OnlinePstnUsage,
    $MatchedVoiceRoutes,
    [string]$OnlineVoiceRoute,
    [string]$OnlinePstnGateway,
    [bool]$OnlinePstnGatewayPidfLoSupported,
    [string]$NumberPattern

  ) {
    $this.DialedNumber = $DialedNumber
    $this.TenantDialPlan = $TenantDialPlan
    $this.EffectiveDialPlan = $EffectiveDialPlan
    $this.MatchingRule = $MatchingRule
    $this.MatchingPattern = $MatchingPattern
    $this.TranslatedNumber = $TranslatedNumber
    $this.NetworkSite = $NetworkSite
    $this.UserPrincipalName = $UserPrincipalName
    $this.SiteEmergencyCallingPolicy = $SiteEmergencyCallingPolicy
    $this.UserEmergencyCallingPolicy = $UserEmergencyCallingPolicy
    $this.EffectiveEmergencyCallingPolicy = $EffectiveEmergencyCallingPolicy
    $this.SiteEmergencyCallRoutingPolicy = $SiteEmergencyCallRoutingPolicy
    $this.UserEmergencyCallRoutingPolicy = $UserEmergencyCallRoutingPolicy
    $this.EffectiveEmergencyCallRoutingPolicy = $EffectiveEmergencyCallRoutingPolicy
    $this.OnlineVoiceRoutingPolicy = $OnlineVoiceRoutingPolicy
    $this.EffectiveEmergencyDialString = $EffectiveEmergencyDialString
    $this.MatchedEmergencyDialMask = $MatchedEmergencyDialMask
    $this.NetworkPathTaken = $NetworkPathTaken
    $this.OnlinePstnUsage = $OnlinePstnUsage
    $this.MatchedVoiceRoutes = $MatchedVoiceRoutes
    $this.OnlineVoiceRoute = $OnlineVoiceRoute
    $this.OnlinePstnGateway = $OnlinePstnGateway
    $this.OnlinePstnGatewayPidfLoSupported = $OnlinePstnGatewayPidfLoSupported
    $this.NumberPattern = $NumberPattern
  }
}
#endregion