SmiteAPI.psm1


Function DNS-ForGodIds {
if($GodName -eq"Achilles"){$GodName = 3492}
if($GodName -eq"Agni"){$GodName = 1737}
if($GodName -eq"Ah Muzen Cab"){$GodName = 1956}
if($GodName -eq"Ah Puch"){$GodName = 2056}
if($GodName -eq"Amaterasu"){$GodName = 2110}
if($GodName -eq"Anhur"){$GodName = 1773}
if($GodName -eq"Anubis"){$GodName = 1668}
if($GodName -eq"Ao Kuang"){$GodName = 2034}
if($GodName -eq"Aphrodite"){$GodName = 1898}
if($GodName -eq"Apollo"){$GodName = 1899}
if($GodName -eq"Arachne"){$GodName = 1699}
if($GodName -eq"Ares"){$GodName = 1782}
if($GodName -eq"Artemis"){$GodName = 1748}
if($GodName -eq"Artio"){$GodName = 3336}
if($GodName -eq"Athena"){$GodName = 1919}
if($GodName -eq"Atlas"){$GodName = 4034}
if($GodName -eq"Awilix"){$GodName = 2037}
if($GodName -eq"Baba Yaga"){$GodName = 3925}
if($GodName -eq"Bacchus"){$GodName = 1809}
if($GodName -eq"Bakasura"){$GodName = 1755}
if($GodName -eq"Baron Samedi"){$GodName = 3518}
if($GodName -eq"Bastet"){$GodName = 1678}
if($GodName -eq"Bellona"){$GodName = 2047}
if($GodName -eq"Cabrakan"){$GodName = 2008}
if($GodName -eq"Camazotz"){$GodName = 2189}
if($GodName -eq"Cerberus"){$GodName = 3419}
if($GodName -eq"Cernunnos"){$GodName = 2268}
if($GodName -eq"Chaac"){$GodName = 1966}
if($GodName -eq"Change"){$GodName = 1921}
if($GodName -eq"Charybdis"){$GodName = 4010}
if($GodName -eq"Chernobog"){$GodName = 3509}
if($GodName -eq"Chiron"){$GodName = 2075}
if($GodName -eq"Chronos"){$GodName = 1920}
if($GodName -eq"Cliodhna"){$GodName = 4017}
if($GodName -eq"Cthulhu"){$GodName = 3945}
if($GodName -eq"Cu Chulainn"){$GodName = 2319}
if($GodName -eq"Cupid"){$GodName = 1778}
if($GodName -eq"Da Ji"){$GodName = 2270}
if($GodName -eq"Danzaburou"){$GodName = 3984}
if($GodName -eq"Discordia"){$GodName = 3377}
if($GodName -eq"Erlang Shen"){$GodName = 2138}
if($GodName -eq"Eset"){$GodName = 1918}
if($GodName -eq"Fafnir"){$GodName = 2136}
if($GodName -eq"Fenrir"){$GodName = 1843}
if($GodName -eq"Freya"){$GodName = 1784}
if($GodName -eq"Ganesha"){$GodName = 2269}
if($GodName -eq"Geb"){$GodName = 1978}
if($GodName -eq"Gilgamesh"){$GodName = 3997}
if($GodName -eq"Guan Yu"){$GodName = 1763}
if($GodName -eq"Hachiman"){$GodName = 3344}
if($GodName -eq"Hades"){$GodName = 1676}
if($GodName -eq"He Bo"){$GodName = 1674}
if($GodName -eq"Heimdallr"){$GodName = 3812}
if($GodName -eq"Hel"){$GodName = 1718}
if($GodName -eq"Hera"){$GodName = 3558}
if($GodName -eq"Hercules"){$GodName = 1848}
if($GodName -eq"Horus"){$GodName = 3611}
if($GodName -eq"Hou Yi"){$GodName = 2040}
if($GodName -eq"Hun Batz"){$GodName = 1673}
if($GodName -eq"Izanami"){$GodName = 2179}
if($GodName -eq"Janus"){$GodName = 1999}
if($GodName -eq"Jing Wei"){$GodName = 2122}
if($GodName -eq"Jormungandr"){$GodName = 3585}
if($GodName -eq"Kali"){$GodName = 1649}
if($GodName -eq"Khepri"){$GodName = 2066}
if($GodName -eq"King Arthur"){$GodName = 3565}
if($GodName -eq"Kukulkan"){$GodName = 1677}
if($GodName -eq"Kumbhakarna"){$GodName = 1993}
if($GodName -eq"Kuzenbo"){$GodName = 2260}
if($GodName -eq"Loki"){$GodName = 1797}
if($GodName -eq"Medusa"){$GodName = 2051}
if($GodName -eq"Mercury"){$GodName = 1941}
if($GodName -eq"Merlin"){$GodName = 3566}
if($GodName -eq"Morgan Le Fay"){$GodName = 4006}
if($GodName -eq"Mulan"){$GodName = 3881}
if($GodName -eq"Ne Zha"){$GodName = 1915}
if($GodName -eq"Neith"){$GodName = 1872}
if($GodName -eq"Nemesis"){$GodName = 1980}
if($GodName -eq"Nike"){$GodName = 2214}
if($GodName -eq"Nox"){$GodName = 2036}
if($GodName -eq"Nu Wa"){$GodName = 1958}
if($GodName -eq"Odin"){$GodName = 1669}
if($GodName -eq"Olorun"){$GodName = 3664}
if($GodName -eq"Osiris"){$GodName = 2000}
if($GodName -eq"Pele"){$GodName = 3543}
if($GodName -eq"Persephone"){$GodName = 3705}
if($GodName -eq"Poseidon"){$GodName = 1881}
if($GodName -eq"Ra"){$GodName = 1698}
if($GodName -eq"Raijin"){$GodName = 2113}
if($GodName -eq"Rama"){$GodName = 2002}
if($GodName -eq"Ratatoskr"){$GodName = 2063}
if($GodName -eq"Ravana"){$GodName = 2065}
if($GodName -eq"Scylla"){$GodName = 1988}
if($GodName -eq"Serqet"){$GodName = 2005}
if($GodName -eq"Set"){$GodName = 3612}
if($GodName -eq"Shiva"){$GodName = 4039}
if($GodName -eq"Skadi"){$GodName = 2107}
if($GodName -eq"Sobek"){$GodName = 1747}
if($GodName -eq"Sol"){$GodName = 2074}
if($GodName -eq"Sun Wukong"){$GodName = 1944}
if($GodName -eq"Susano"){$GodName = 2123}
if($GodName -eq"Sylvanus"){$GodName = 2030}
if($GodName -eq"Terra"){$GodName = 2147}
if($GodName -eq"Thanatos"){$GodName = 1943}
if($GodName -eq"The Morrigan"){$GodName = 2226}
if($GodName -eq"Thor"){$GodName = 1779}
if($GodName -eq"Thoth"){$GodName = 2203}
if($GodName -eq"Tiamat"){$GodName = 3990}
if($GodName -eq"Tsukuyomi"){$GodName = 3954}
if($GodName -eq"Tyr"){$GodName = 1924}
if($GodName -eq"Ullr"){$GodName = 1991}
if($GodName -eq"Vamana"){$GodName = 1723}
if($GodName -eq"Vulcan"){$GodName = 1869}
if($GodName -eq"Xbalanque"){$GodName = 1864}
if($GodName -eq"Xing Tian"){$GodName = 2072}
if($GodName -eq"Yemoja"){$GodName = 3811}
if($GodName -eq"Ymir"){$GodName = 1670}
if($GodName -eq"Zeus"){$GodName = 1672}
if($GodName -eq"Zhong Kui"){$GodName = 1926}
return $GodName
}



Function Import-GodIds {
[cmdletbinding()]
    param()
        $global:Achilles = 3492
        $global:Agni = 1737
        $global:AhMuzenCab = 1956
        $global:AhPuch = 2056
        $global:Amaterasu = 2110
        $global:Anhur = 1773
        $global:Anubis = 1668
        $global:AoKuang = 2034
        $global:Aphrodite = 1898
        $global:Apollo = 1899
        $global:Arachne = 1699
        $global:Ares = 1782
        $global:Artemis = 1748
        $global:Artio = 3336
        $global:Athena = 1919
        $global:Atlas = 4034
        $global:Awilix = 2037
        $global:BabaYaga = 3925
        $global:Bacchus = 1809
        $global:Bakasura = 1755
        $global:BaronSamedi = 3518
        $global:Bastet = 1678
        $global:Bellona = 2047
        $global:Cabrakan = 2008
        $global:Camazotz = 2189
        $global:Cerberus = 3419
        $global:Cernunnos = 2268
        $global:Chaac = 1966
        $global:Change = 1921
        $global:Charybdis = 4010
        $global:Chernobog = 3509
        $global:Chiron = 2075
        $global:Chronos = 1920
        $global:Cliodhna = 4017
        $global:Cthulhu = 3945
        $global:CuChulainn = 2319
        $global:Cupid = 1778
        $global:DaJi = 2270
        $global:Danzaburou = 3984
        $global:Discordia = 3377
        $global:ErlangShen = 2138
        $global:Eset = 1918
        $global:Fafnir = 2136
        $global:Fenrir = 1843
        $global:Freya = 1784
        $global:Ganesha = 2269
        $global:Geb = 1978
        $global:Gilgamesh = 3997
        $global:GuanYu = 1763
        $global:Hachiman = 3344
        $global:Hades = 1676
        $global:HeBo = 1674
        $global:Heimdallr = 3812
        $global:Hel = 1718
        $global:Hera = 3558
        $global:Hercules = 1848
        $global:Horus = 3611
        $global:HouYi = 2040
        $global:HunBatz = 1673
        $global:Izanami = 2179
        $global:Janus = 1999
        $global:JingWei = 2122
        $global:Jormungandr = 3585
        $global:Kali = 1649
        $global:Khepri = 2066
        $global:KingArthur = 3565
        $global:Kukulkan = 1677
        $global:Kumbhakarna = 1993
        $global:Kuzenbo = 2260
        $global:Loki = 1797
        $global:Medusa = 2051
        $global:Mercury = 1941
        $global:Merlin = 3566
        $global:MorganLeFay = 4006
        $global:Mulan = 3881
        $global:NeZha = 1915
        $global:Neith = 1872
        $global:Nemesis = 1980
        $global:Nike = 2214
        $global:Nox = 2036
        $global:NuWa = 1958
        $global:Odin = 1669
        $global:Olorun = 3664
        $global:Osiris = 2000
        $global:Pele = 3543
        $global:Persephone = 3705
        $global:Poseidon = 1881
        $global:Ra = 1698
        $global:Raijin = 2113
        $global:Rama = 2002
        $global:Ratatoskr = 2063
        $global:Ravana = 2065
        $global:Scylla = 1988
        $global:Serqet = 2005
        $global:Set = 3612
        $global:Shiva = 4039
        $global:Skadi = 2107
        $global:Sobek = 1747
        $global:Sol = 2074
        $global:SunWukong = 1944
        $global:Susano = 2123
        $global:Sylvanus = 2030
        $global:Terra = 2147
        $global:Thanatos = 1943
        $global:TheMorrigan = 2226
        $global:Thor = 1779
        $global:Thoth = 2203
        $global:Tiamat = 3990
        $global:Tsukuyomi = 3954
        $global:Tyr = 1924
        $global:Ullr = 1991
        $global:Vamana = 1723
        $global:Vulcan = 1869
        $global:Xbalanque = 1864
        $global:XingTian = 2072
        $global:Yemoja = 3811
        $global:Ymir = 1670
        $global:Zeus = 1672
        $global:ZhongKui = 1926
}

function Create-Timestamp{
    $Timestamp = Get-Date
    $Timestamp -f "yyyyMMddHHmmss"
    $global:Timestamp = $Timestamp.ToUniversalTime().ToString("yyyyMMddHHmmss")
}

function Check-Sessionid {
    if($sessionid -eq $null) {
        create-session -Devid $devid -Authkey $authkey
                         }
    elseif($sessionid -eq ""){
        create-session -Devid $devid -Authkey $authkey
                             }
    else {
        $timedif = ((get-date) - ($sessiontimestamp))
            if ($timedif.Minutes -ge 15){
                create-session -Devid $devid -Authkey $authkey
                                        }
         }


}


Function Get-StringHash 
{ 
    param
    (
        [String] $String,
        $HashName = "MD5"
    )

    $bytes = [System.Text.Encoding]::UTF8.GetBytes($String)
    $algorithm = [System.Security.Cryptography.HashAlgorithm]::Create('MD5')
    $StringBuilder = New-Object System.Text.StringBuilder 
  
    $algorithm.ComputeHash($bytes) | 
    ForEach-Object { 
        $null = $StringBuilder.Append($_.ToString("x2")) 
    } 
  
    $StringBuilder.ToString()
    return 
}

#create session
function Create-Session{
[cmdletbinding()]

param(
        [Parameter(Mandatory=$False)]
        [string]$Devid,

        [Parameter(Mandatory=$False)]
        [string]$Authkey   
)

    create-timestamp
    $method = "createsession"
    $signature = "$devid" + "$method" + "$authkey" + "$Timestamp"
    $signature = get-stringhash -string "$signature"
    $signature = $signature.Replace("-","")

     $sessionid = invoke-restmethod -Uri "https://api.smitegame.com/smiteapi.svc/createsessionJson/$devid/$signature/$timestamp" -UseBasicParsing
     $sessionid
     $global:sessionid = $sessionid.session_id
     $global:sessiontimestamp = Get-Date
}


 #create signature
function Create-Signature($method){
    $signature = "$devid" + "$method" + "$authkey" + "$Timestamp"
    $signature = get-stringhash -string "$signature"
    $global:signature = $signature.Replace("-","")
                            }


function Get-PlayerStats{

[cmdletbinding()]

param(
        [Parameter(Mandatory=$true)]
        [string]$playername,

        [Parameter(Mandatory=$true)]
        [string]$Devid,

        [Parameter(Mandatory=$true)]
        [string]$Authkey,
        
        [string]$ResponseFormat = "json" 
)


    Check-Sessionid
    Create-timestamp
    Create-signature -method getplayer
    Invoke-restmethod "https://api.smitegame.com/smiteapi.svc/getplayer$responseformat/$devid/$signature/$sessionid/$timestamp/$playername" -UseBasicParsing -Verbose
    return
}


function Get-SmiteItems{
[cmdletbinding()]

param(
        [Parameter(Mandatory=$true)]
        [string]$Devid,

        [Parameter(Mandatory=$true)]
        [string]$Authkey,
        
        [string]$ResponseFormat = "json"  
)

    Check-Sessionid
    Create-Timestamp
    create-signature -method getitems
    Invoke-RestMethod  "https://api.smitegame.com/smiteapi.svc/getitems$ResponseFormat/$devid/$signature/$sessionid/$timestamp/1" -UseBasicParsing -Verbose
    return
}

function Get-Gods{
[cmdletbinding()]

param(
        [Parameter(Mandatory=$true)]
        [string]$Devid,

        [Parameter(Mandatory=$true)]
        [string]$Authkey,

        [string]$ResponseFormat = "json"

)

    Check-Sessionid
    Create-Timestamp
    create-signature -method getgods
    Invoke-restmethod  "https://api.smitegame.com/smiteapi.svc/getgods$responseformat/$devid/$signature/$sessionid/$timestamp/1" -UseBasicParsing -verbose
    return
}

function Check-SmiteConnection{
[cmdletbinding()]
    param()
Invoke-WebRequest  https://api.smitegame.com/smiteapi.svc/pingjson -UseBasicParsing
}


function Test-SmiteSession{
[cmdletbinding()]
    param()

        $apimethod = "testsession" + "json"
        Create-Timestamp
        Create-Signature -method testsession
        $results = Invoke-restmethod  "https://api.smitegame.com/smiteapi.svc/$apimethod/$devid/$signature/$sessionid/$timestamp" -UseBasicParsing -Verbose
        return $results
}

function Get-HirezServerStatus{
[cmdletbinding()]

param(
        [Parameter(Mandatory=$true)]
        [string]$Devid,

        [Parameter(Mandatory=$true)]
        [string]$Authkey,

        [string]$ResponseFormat = "json"

)

    Check-Sessionid
    Create-Timestamp
    Create-Signature -method gethirezserverstatus
    Invoke-restmethod  "https://api.smitegame.com/smiteapi.svc/gethirezserverstatus$ResponseFormat/$devid/$signature/$sessionid/$timestamp" -UseBasicParsing -verbose
    return
}

function Get-DataUsed{
[cmdletbinding()]

param(
        [Parameter(Mandatory=$true)]
        [string]$Devid,

        [Parameter(Mandatory=$true)]
        [string]$Authkey,

        [string]$ResponseFormat = "json"

)

    Check-Sessionid
    Create-Timestamp
    Create-Signature -method getdataused
    Invoke-restmethod  "https://api.smitegame.com/smiteapi.svc/getdataused$ResponseFormat/$devid/$signature/$sessionid/$timestamp" -UseBasicParsing -verbose
    return
}

#untested
function Get-DemoDetails{
[cmdletbinding()]

param(
        [Parameter(Mandatory=$true)]
        [string]$Devid,

        [Parameter(Mandatory=$true)]
        [string]$Authkey,

        [string]$ResponseFormat = "json",

        [Parameter(Mandatory=$true)]
        [string]$matchid

)

    Check-Sessionid
    Create-Timestamp
    Create-Signature -method getdemodetails
    Invoke-restmethod  "https://api.smitegame.com/smiteapi.svc/getdemodetails$ResponseFormat/$devid/$signature/$sessionid/$timestamp/$matchid" -UseBasicParsing -verbose
    return
}

function Get-EsportsProLeagueDetails{
[cmdletbinding()]

param(
        [Parameter(Mandatory=$true)]
        [string]$Devid,

        [Parameter(Mandatory=$true)]
        [string]$Authkey,

        [string]$ResponseFormat = "json"

)

    Check-Sessionid
    Create-Timestamp
    Create-Signature -method getesportsproleaguedetails
    Invoke-restmethod  "https://api.smitegame.com/smiteapi.svc/getesportsproleaguedetails$ResponseFormat/$devid/$signature/$sessionid/$timestamp" -UseBasicParsing -verbose
    return
}

function Get-Friends{
[cmdletbinding()]

param(
        [Parameter(Mandatory=$true)]
        [string]$PlayerName,

        [Parameter(Mandatory=$true)]
        [string]$Devid,

        [Parameter(Mandatory=$true)]
        [string]$Authkey,

        [string]$ResponseFormat = "json"

)

    Check-Sessionid
    Create-Timestamp
    Create-Signature -method getfriends
    Invoke-restmethod  "https://api.smitegame.com/smiteapi.svc/getfriends$ResponseFormat/$devid/$signature/$sessionid/$timestamp/$playername" -UseBasicParsing -verbose
    return
}

function Get-GodRanks{
[cmdletbinding()]

param(
        [Parameter(Mandatory=$true)]
        [string]$PlayerName,

        [Parameter(Mandatory=$true)]
        [string]$Devid,

        [Parameter(Mandatory=$true)]
        [string]$Authkey,

        [string]$ResponseFormat = "json"

)

    Check-Sessionid
    Create-Timestamp
    Create-Signature -method getgodranks
    Invoke-restmethod  "https://api.smitegame.com/smiteapi.svc/getgodranks$ResponseFormat/$devid/$signature/$sessionid/$timestamp/$playername" -UseBasicParsing -verbose
    return
}


function Get-GodSkins{
[cmdletbinding()]

param(
        [Parameter(Mandatory=$true)]
        [string]$Devid,

        [Parameter(Mandatory=$true)]
        [string]$Authkey,

        [Parameter(Mandatory=$true)]
        [string]$GodName,

        [string]$ResponseFormat = "json"

)
    $GodName = DNS-ForGodIds
    Check-Sessionid
    Create-Timestamp
    Create-Signature -method getgodskins
    Invoke-restmethod  "https://api.smitegame.com/smiteapi.svc/getgodskins$ResponseFormat/$devid/$signature/$sessionid/$timestamp/$GodName/1" -UseBasicParsing -verbose
    return
}









<#
parsing the get-gods json file to get all gods and their respective IDs
 
$files = Get-Content C:\cabs\players\gods.txt
foreach ($line in $files) {
if ($line.Contains("Name") -or $line.Contains("id") -and !$line.Contains("ability") -and !$line.Contains("Lore") -and $line.Contains(":") -and !$line.Contains("Title") `
-and !$line.Contains("\") -and !$line.Contains("Ability") -and !$line.Contains("/") -and !$line.Contains("URL") -and !$line.Contains("murder") )
{
    $line
    Add-Content C:\cabs\players\out.txt $line
    }
}
#>






#Function Template

<#
function Get-{
[cmdletbinding()]
 
param(
        [Parameter(Mandatory=$true)]
        [string]$Devid,
 
        [Parameter(Mandatory=$true)]
        [string]$Authkey,
 
        [string]$ResponseFormat = "json"
 
)
 
    Check-Sessionid
    Create-Timestamp
    Create-Signature -method
    Invoke-restmethod "https://api.smitegame.com/smiteapi.svc/$ResponseFormat/$devid/$signature/$sessionid/$timestamp" -UseBasicParsing -verbose
    return
}
 
 
 
#>