diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml new file mode 100644 index 0000000..5955383 --- /dev/null +++ b/.github/workflows/dotnet-build.yml @@ -0,0 +1,37 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: Build & Test .NET + +on: + push: + branches: [ "master" ] + tags: [ "*" ] + pull_request: + branches: [ "master" ] + +env: + IS_PUSH_TAG: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Restore dependencies + run: dotnet restore ./src/SteamWebAPI2.sln + - name: Build (Debug) + run: dotnet build ./src/SteamWebAPI2.sln --no-restore + - name: Build (Release) + if: ${{ env.IS_PUSH_TAG == 'true' }} + run: dotnet build ./src/SteamWebAPI2.sln -c Release --no-restore + - name: Pack + if: ${{ env.IS_PUSH_TAG == 'true' }} + run: dotnet pack ./src/SteamWebAPI2/SteamWebAPI2.csproj -c Release --output . + - name: Publish + if: ${{ env.IS_PUSH_TAG == 'true' }} + run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json -n --skip-duplicate diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..42a47e0 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,27 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/src/Steam.UnitTests/bin/Debug/netcoreapp3.1/Steam.UnitTests.dll", + "args": [], + "cwd": "${workspaceFolder}/src/Steam.UnitTests", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..591a666 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/src/Steam.UnitTests/Steam.UnitTests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/Steam.UnitTests/Steam.UnitTests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/src/Steam.UnitTests/Steam.UnitTests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE index 20e6b3c..43671e8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Justin Skiles +Copyright (c) 2025 Justin Skiles Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 35a4370..9bcf902 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # SteamWebAPI2 -[![Build status](https://ci.appveyor.com/api/projects/status/cga6ck03o286sq80?svg=true)](https://ci.appveyor.com/project/JustinSkiles/steamwebapi2) +[![Build Status](https://github.com/babelshift/SteamWebAPI2/actions/workflows/dotnet-build.yml/badge.svg?branch=master)](https://github.com/babelshift/SteamWebAPI2/actions/workflows/dotnet-build.yml) [![NuGet](https://img.shields.io/nuget/v/SteamWebAPI2.svg)](https://www.nuget.org/packages/SteamWebAPI2) [![MyGet CI](https://img.shields.io/myget/babelshift-ci/v/SteamWebAPI2.svg)](https://www.myget.org/feed/babelshift-ci/package/nuget/SteamWebAPI2) @@ -7,6 +7,8 @@ This is a .NET library that makes it easy to use the Steam Web API. It convenien Please refer [here](http://steamwebapi.azurewebsites.net/) for details regarding the Steam Web API, its endpoints, and how this library consumes them. +Check this README and the [Wiki](https://github.com/babelshift/SteamWebAPI2/wiki/) for more details about [getting started](https://github.com/babelshift/SteamWebAPI2/wiki/1.-Getting-Started) and [common use cases](https://github.com/babelshift/SteamWebAPI2/wiki/Common-Use-Examples). + ## About this Library This library was created to address the (at times) awful nature of the Steam Web API. Many of the exposed endpoints have little to no documentation on the parameters and absolutely no documentation on any of the responses. In addition, many of the endpoints do not follow any type of coding convention as it appears that different developers created different endpoints without collaborating with one another. @@ -22,31 +24,37 @@ Instead of stressing about parsing the ugly JSON responses yourself, just use th * Clean up some of the more egregious JSON responses where JSON arrays should have been used but weren't. * Offer a sane way of handling the various representations and conversions of Steam ID by offering a SteamId class. * Handles legacy, modern, and 64-bit Steam Id representations + +**NOTE:** +Valve's [Steamworks documentation](https://partner.steamgames.com/doc/webapi) doesn't do a good job at explaining the difference between their public API and partner API. This library only works with the public-facing API located at: `api.steampowered.com`. Any endpoints from their documentation that are located at the `partner.steam-api.com` will not be accessible with this library. I am not a registered publisher and thus don't have access to any of the partner endpoints. ## Install the Library from NuGet -See the library in the NuGet gallery [here](https://www.nuget.org/packages/SteamWebAPI2). You can install the library into your project directly from the package manager. +See the library in the NuGet gallery [here](https://www.nuget.org/packages/SteamWebAPI2). +Package Manager: ``` Install-Package SteamWebAPI2 ``` -## How Valve's Steam Web API is Architected -Gain a basic understanding of how Valve's Steam Web API is laid out: please see [this helper site](http://steamwebapi.azurewebsites.net/) that I made to more easily describe the available endpoints. +.NET Core CLI: +``` +dotnet add package SteamWebAPI2 +``` ## How to Use the Library 1. Read the `About` section so you understand why this library exists 2. Install the library from NuGet - 3. Instantiate an object from any class that inherits from `SteamWebInterface` for whatever endpoint you want to use - 1. Requires a Steam Web API developer key. [Get one here](https://steamcommunity.com/dev/apikey). **KEEP THIS SECRET**. - 2. Some endpoints require an AppId (such as 440 for Team Fortress 2) - 4. Call the method with your parameters that you want to use + 3. Get a Steam Web API developer key. [Get one here](https://steamcommunity.com/dev/apikey). **KEEP THIS SECRET**. + 4. Instantiate a `SteamWebInterfaceFactory` to use as a helper to create objects for various endpoint calls. + 5. Use the factory to create endpoint interface classes. + 5. Use the interface class and call a method with your parameters. -The library is structured to mirror the endpoint structure. For example, the "DOTA2Econ" class will expose methods to communicate with the "IDOTA2Econ" endpoints. +The library is structured to mirror the Steam Web API endpoint structure. For example, the "DOTA2Econ" class will expose methods to communicate with the "IDOTA2Econ" endpoints. See [here](http://steamwebapi.azurewebsites.net/) for more endpoint details. Each method returns a SteamWebResponse object which contains the following: | Field | Type | Description | -|--------------------|-----------------|----------------------------------------------------| +| ------------------ | --------------- | -------------------------------------------------- | | Data | T | Maps to the payload returned by the Steam Web API. | | ContentLength | long? | Maps to the HTTP ContentLength header. | | ContentType | string | Maps to the HTTP ContentType header. | @@ -57,8 +65,12 @@ Each method returns a SteamWebResponse object which contains the following: ## Sample Usage ```cs +// factory to be used to generate various web interfaces +var webInterfaceFactory = new SteamWebInterfaceFactory(); + // this will map to the ISteamUser endpoint -var steamInterface = new SteamUser(""); +// note that you have full control over HttpClient lifecycle here +var steamInterface = webInterfaceFactory.CreateSteamWebInterface(new HttpClient()); // this will map to ISteamUser/GetPlayerSummaries method in the Steam Web API // see PlayerSummaryResultContainer.cs for response documentation @@ -71,10 +83,3 @@ var playerSummaryLastModified = playerSummaryResponse.LastModified; var friendsListResponse = await steamInterface.GetFriendsListAsync(); var friendsList = friendsListResponse.Data; ``` - -## Changes from 2.0 to 3.0 -In versions previous to 3.0, numerical types were treated as short, int, and long. This caused problems when interacting with the Steam Web API because Valve accepts and returns unsigned numerical types. Instead of constantly reacting to overflows when a specific endpoint would return something outside the bounds of a 32-bit int, I decided to switch all numerical types to their unsigned counterparts. - -## Changes from 3.0 to 4.0 - * .NET Core is now supported. - * All endpoints now return ISteamWebResponse where T is the response payload type. This allows more metadata to be returned with each end point such as HTTP headers and status messages in addition to the response payload. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 02981e3..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: '{build}' - -image: Visual Studio 2017 Preview - -pull_requests: - do_not_increment_build_number: true - -branches: - only: - - master - -nuget: - disable_publish_on_pr: true - -build_script: - - cmd: .\psake.bat ci - -test: off - -artifacts: - - path: .\artifacts\**\*.nupkg - name: NuGet - -cache: - - '%APPVEYOR_BUILD_FOLDER%\dotnet-sdk.exe' - -deploy: - - provider: NuGet - server: https://www.myget.org/F/babelshift-ci/api/v2/package - api_key: - secure: zI5gnqOnLVuIzNHVG1eiCpi5mEsT1i6AvwOHwIIm27NOURZFnCHhwG3SE49f0f88 - skip_symbols: true - on: - branch: master - - - provider: NuGet - name: production - api_key: - secure: vIHuOdB4aYJEqNACb3jjCg3m/qZLqpwYlruu8J0BOiX81lRrmussVEUqiWRBTrRQ - on: - branch: master - appveyor_repo_tag: true \ No newline at end of file diff --git a/build/dotnet/install.ps1 b/build/dotnet/install.ps1 deleted file mode 100644 index f863814..0000000 --- a/build/dotnet/install.ps1 +++ /dev/null @@ -1,358 +0,0 @@ -# -# Copyright (c) .NET Foundation and contributors. All rights reserved. -# Licensed under the MIT license. See LICENSE file in the project root for full license information. -# - -<# -.SYNOPSIS - Installs dotnet cli -.DESCRIPTION - Installs dotnet cli. If dotnet installation already exists in the given directory - it will update it only if the requested version differs from the one already installed. -.PARAMETER Channel - Default: preview - Channel is the way of reasoning about stability and quality of dotnet. This parameter takes one of the values: - - future - Possibly unstable, frequently changing, may contain new finished and unfinished features - - preview - Pre-release stable with known issues and feature gaps - - production - Most stable releases -.PARAMETER Version - Default: latest - Represents a build version on specific channel. Possible values: - - 4-part version in a format A.B.C.D - represents specific version of build - - latest - most latest build on specific channel - - lkg - last known good version on specific channel - Note: LKG work is in progress. Once the work is finished, this will become new default -.PARAMETER InstallDir - Default: %LocalAppData%\Microsoft\dotnet - Path to where to install dotnet. Note that binaries will be placed directly in a given directory. -.PARAMETER Architecture - Default: - this value represents currently running OS architecture - Architecture of dotnet binaries to be installed. - Possible values are: , x64 and x86 -.PARAMETER SharedRuntime - Default: false - Installs just the shared runtime bits, not the entire SDK -.PARAMETER DebugSymbols - If set the installer will include symbols in the installation. -.PARAMETER DryRun - If set it will not perform installation but instead display what command line to use to consistently install - currently requested version of dotnet cli. In example if you specify version 'latest' it will display a link - with specific version so that this command can be used deterministicly in a build script. - It also displays binaries location if you prefer to install or download it yourself. -.PARAMETER NoPath - By default this script will set environment variable PATH for the current process to the binaries folder inside installation folder. - If set it will display binaries location but not set any environment variable. -.PARAMETER Verbose - Displays diagnostics information. -.PARAMETER AzureFeed - Default: https://dotnetcli.blob.core.windows.net/dotnet - This parameter should not be usually changed by user. It allows to change URL for the Azure feed used by this installer. -#> -[cmdletbinding()] -param( - [string]$Channel="rel-1.0.0", - [string]$Version="Latest", - [string]$InstallDir="", - [string]$Architecture="", - [switch]$SharedRuntime, - [switch]$DebugSymbols, # TODO: Switch does not work yet. Symbols zip is not being uploaded yet. - [switch]$DryRun, - [switch]$NoPath, - [string]$AzureFeed="https://dotnetcli.blob.core.windows.net/dotnet" -) - -Set-StrictMode -Version Latest -$ErrorActionPreference="Stop" -$ProgressPreference="SilentlyContinue" - -$BinFolderRelativePath="" - -# example path with regex: shared/1.0.0-beta-12345/somepath -$VersionRegEx="/\d+\.\d+[^/]+/" -$OverrideNonVersionedFiles=$true - -function Say($str) { - Write-Host "dotnet-install: $str" -} - -function Say-Verbose($str) { - Write-Verbose "dotnet-install: $str" -} - -function Say-Invocation($Invocation) { - $command = $Invocation.MyCommand; - $args = (($Invocation.BoundParameters.Keys | foreach { "-$_ `"$($Invocation.BoundParameters[$_])`"" }) -join " ") - Say-Verbose "$command $args" -} - -function Get-Machine-Architecture() { - Say-Invocation $MyInvocation - - # possible values: AMD64, IA64, x86 - return $ENV:PROCESSOR_ARCHITECTURE -} - -# TODO: Architecture and CLIArchitecture should be unified -function Get-CLIArchitecture-From-Architecture([string]$Architecture) { - Say-Invocation $MyInvocation - - switch ($Architecture.ToLower()) { - { $_ -eq "" } { return Get-CLIArchitecture-From-Architecture $(Get-Machine-Architecture) } - { ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" } - { $_ -eq "x86" } { return "x86" } - default { throw "Architecture not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" } - } -} - -function Get-Version-Info-From-Version-Text([string]$VersionText) { - Say-Invocation $MyInvocation - - $Data = @($VersionText.Split([char[]]@(), [StringSplitOptions]::RemoveEmptyEntries)); - - $VersionInfo = @{} - $VersionInfo.CommitHash = $Data[0].Trim() - $VersionInfo.Version = $Data[1].Trim() - return $VersionInfo -} - -function Get-Latest-Version-Info([string]$AzureFeed, [string]$AzureChannel, [string]$CLIArchitecture) { - Say-Invocation $MyInvocation - - $VersionFileUrl = $null - if ($SharedRuntime) { - $VersionFileUrl = "$AzureFeed/$AzureChannel/dnvm/latest.sharedfx.win.$CLIArchitecture.version" - } - else { - $VersionFileUrl = "$AzureFeed/Sdk/$AzureChannel/latest.version" - } - - $Response = Invoke-WebRequest -UseBasicParsing $VersionFileUrl - - switch ($Response.Headers.'Content-Type'){ - { ($_ -eq "application/octet-stream") } { $VersionText = [Text.Encoding]::UTF8.GetString($Response.Content) } - { ($_ -eq "text/plain") } { $VersionText = $Response.Content } - default { throw "``$Response.Headers.'Content-Type'`` is an unknown .version file content type." } - } - - - $VersionInfo = Get-Version-Info-From-Version-Text $VersionText - - return $VersionInfo -} - -# TODO: AzureChannel and Channel should be unified -function Get-Azure-Channel-From-Channel([string]$Channel) { - Say-Invocation $MyInvocation - - # For compatibility with build scripts accept also directly Azure channels names - switch ($Channel.ToLower()) { - { ($_ -eq "future") -or ($_ -eq "dev") } { return "dev" } - { $_ -eq "production" } { throw "Production channel does not exist yet" } - default { return $_ } - } -} - -function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$AzureChannel, [string]$CLIArchitecture, [string]$Version) { - Say-Invocation $MyInvocation - - switch ($Version.ToLower()) { - { $_ -eq "latest" } { - $LatestVersionInfo = Get-Latest-Version-Info -AzureFeed $AzureFeed -AzureChannel $AzureChannel -CLIArchitecture $CLIArchitecture - return $LatestVersionInfo.Version - } - { $_ -eq "lkg" } { throw "``-Version LKG`` not supported yet." } - default { return $Version } - } -} - -function Get-Download-Links([string]$AzureFeed, [string]$AzureChannel, [string]$SpecificVersion, [string]$CLIArchitecture) { - Say-Invocation $MyInvocation - - $ret = @() - - if ($SharedRuntime) { - $PayloadURL = "$AzureFeed/$AzureChannel/Binaries/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip" - } - else { - $PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip" - } - - Say-Verbose "Constructed payload URL: $PayloadURL" - $ret += $PayloadURL - - return $ret -} - -function Get-User-Share-Path() { - Say-Invocation $MyInvocation - - $InstallRoot = $env:DOTNET_INSTALL_DIR - if (!$InstallRoot) { - $InstallRoot = "$env:LocalAppData\Microsoft\dotnet" - } - return $InstallRoot -} - -function Resolve-Installation-Path([string]$InstallDir) { - Say-Invocation $MyInvocation - - if ($InstallDir -eq "") { - return Get-User-Share-Path - } - return $InstallDir -} - -function Get-Version-Info-From-Version-File([string]$InstallRoot, [string]$RelativePathToVersionFile) { - Say-Invocation $MyInvocation - - $VersionFile = Join-Path -Path $InstallRoot -ChildPath $RelativePathToVersionFile - Say-Verbose "Local version file: $VersionFile" - - if (Test-Path $VersionFile) { - $VersionText = cat $VersionFile - Say-Verbose "Local version file text: $VersionText" - return Get-Version-Info-From-Version-Text $VersionText - } - - Say-Verbose "Local version file not found." - - return $null -} - -function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) { - Say-Invocation $MyInvocation - - $DotnetPackagePath = Join-Path -Path $InstallRoot -ChildPath $RelativePathToPackage | Join-Path -ChildPath $SpecificVersion - Say-Verbose "Is-Dotnet-Package-Installed: Path to a package: $DotnetPackagePath" - return Test-Path $DotnetPackagePath -PathType Container -} - -function Get-Absolute-Path([string]$RelativeOrAbsolutePath) { - # Too much spam - # Say-Invocation $MyInvocation - - return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($RelativeOrAbsolutePath) -} - -function Get-Path-Prefix-With-Version($path) { - $match = [regex]::match($path, $VersionRegEx) - if ($match.Success) { - return $entry.FullName.Substring(0, $match.Index + $match.Length) - } - - return $null -} - -function Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package([System.IO.Compression.ZipArchive]$Zip, [string]$OutPath) { - Say-Invocation $MyInvocation - - $ret = @() - foreach ($entry in $Zip.Entries) { - $dir = Get-Path-Prefix-With-Version $entry.FullName - if ($dir -ne $null) { - $path = Get-Absolute-Path $(Join-Path -Path $OutPath -ChildPath $dir) - if (-Not (Test-Path $path -PathType Container)) { - $ret += $dir - } - } - } - - $ret = $ret | Sort-Object | Get-Unique - - $values = ($ret | foreach { "$_" }) -join ";" - Say-Verbose "Directories to unpack: $values" - - return $ret -} - -# Example zip content and extraction algorithm: -# Rule: files if extracted are always being extracted to the same relative path locally -# .\ -# a.exe # file does not exist locally, extract -# b.dll # file exists locally, override only if $OverrideFiles set -# aaa\ # same rules as for files -# ... -# abc\1.0.0\ # directory contains version and exists locally -# ... # do not extract content under versioned part -# abc\asd\ # same rules as for files -# ... -# def\ghi\1.0.1\ # directory contains version and does not exist locally -# ... # extract content -function Extract-Dotnet-Package([string]$ZipPath, [string]$OutPath) { - Say-Invocation $MyInvocation - - Add-Type -Assembly System.IO.Compression.FileSystem | Out-Null - Set-Variable -Name Zip - try { - $Zip = [System.IO.Compression.ZipFile]::OpenRead($ZipPath) - - $DirectoriesToUnpack = Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package -Zip $Zip -OutPath $OutPath - - foreach ($entry in $Zip.Entries) { - $PathWithVersion = Get-Path-Prefix-With-Version $entry.FullName - if (($PathWithVersion -eq $null) -Or ($DirectoriesToUnpack -contains $PathWithVersion)) { - $DestinationPath = Get-Absolute-Path $(Join-Path -Path $OutPath -ChildPath $entry.FullName) - $DestinationDir = Split-Path -Parent $DestinationPath - $OverrideFiles=$OverrideNonVersionedFiles -Or (-Not (Test-Path $DestinationPath)) - if ((-Not $DestinationPath.EndsWith("\")) -And $OverrideFiles) { - New-Item -ItemType Directory -Force -Path $DestinationDir | Out-Null - [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $DestinationPath, $OverrideNonVersionedFiles) - } - } - } - } - finally { - if ($Zip -ne $null) { - $Zip.Dispose() - } - } -} - -$AzureChannel = Get-Azure-Channel-From-Channel -Channel $Channel -$CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture -$SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -AzureChannel $AzureChannel -CLIArchitecture $CLIArchitecture -Version $Version -$DownloadLinks = Get-Download-Links -AzureFeed $AzureFeed -AzureChannel $AzureChannel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture - -if ($DryRun) { - Say "Payload URLs:" - foreach ($DownloadLink in $DownloadLinks) { - Say "- $DownloadLink" - } - Say "Repeatable invocation: .\$($MyInvocation.MyCommand) -Version $SpecificVersion -Channel $Channel -Architecture $CLIArchitecture -InstallDir $InstallDir" - exit 0 -} - -$InstallRoot = Resolve-Installation-Path $InstallDir -Say-Verbose "InstallRoot: $InstallRoot" - -$IsSdkInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage "sdk" -SpecificVersion $SpecificVersion -Say-Verbose ".NET SDK installed? $IsSdkInstalled" -if ($IsSdkInstalled) { - Say ".NET SDK version $SpecificVersion is already installed." - exit 0 -} - -New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null - -foreach ($DownloadLink in $DownloadLinks) { - $ZipPath = [System.IO.Path]::GetTempFileName() - Say "Downloading $DownloadLink" - $resp = Invoke-WebRequest -UseBasicParsing $DownloadLink -OutFile $ZipPath - - Say "Extracting zip from $DownloadLink" - Extract-Dotnet-Package -ZipPath $ZipPath -OutPath $InstallRoot - - Remove-Item $ZipPath -} - -$BinPath = Get-Absolute-Path $(Join-Path -Path $InstallRoot -ChildPath $BinFolderRelativePath) -if (-Not $NoPath) { - Say "Adding to current process PATH: `"$BinPath`". Note: This change will not be visible if PowerShell was run as a child process." - $env:path = "$BinPath;" + $env:path -} -else { - Say "Binaries of dotnet can be found in $BinPath" -} - -Say "Installation finished" -exit 0 \ No newline at end of file diff --git a/build/psake/.gitattributes b/build/psake/.gitattributes deleted file mode 100644 index d7c444c..0000000 --- a/build/psake/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* -crlf \ No newline at end of file diff --git a/build/psake/.gitignore b/build/psake/.gitignore deleted file mode 100644 index 3bc8eba..0000000 --- a/build/psake/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -[B|b]in -*.nupkg -Thumbs.db \ No newline at end of file diff --git a/build/psake/NuGetPackageBuilder.ps1 b/build/psake/NuGetPackageBuilder.ps1 deleted file mode 100644 index ec8e2ed..0000000 --- a/build/psake/NuGetPackageBuilder.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -$scriptpath = $MyInvocation.MyCommand.Path -$dir = Split-Path $scriptpath -$manifestPath = Join-Path $dir psake.psd1 - -try -{ - $manifest = Test-ModuleManifest -Path $manifestPath -WarningAction SilentlyContinue -ErrorAction Stop - $version = $manifest.Version.ToString() -} -catch -{ - throw -} - -"Version number $version" - -$destDir = "$dir\bin" -if (Test-Path $destDir -PathType container) { - Remove-Item $destDir -Recurse -Force -} - -Copy-Item -Recurse $dir\nuget $destDir -Copy-Item -Recurse $dir\en-US $destDir\tools\en-US -Copy-Item -Recurse $dir\examples $destDir\tools\examples -@( "psake.cmd", "psake.ps1", "psake.psm1", "psake.psd1", "psake-config.ps1", "README.markdown", "license.txt") | - % { Copy-Item $dir\$_ $destDir\tools } - -.\nuget pack "$destDir\psake.nuspec" -Verbosity quiet -Version $version diff --git a/build/psake/README.markdown b/build/psake/README.markdown deleted file mode 100644 index 768ff0d..0000000 --- a/build/psake/README.markdown +++ /dev/null @@ -1,50 +0,0 @@ -Welcome to the psake project. -============================= - -[![Join the chat at https://gitter.im/psake/psake](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/psake/psake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -psake is a build automation tool written in PowerShell. It avoids the angle-bracket tax associated with executable XML by leveraging the PowerShell syntax in your build scripts. -psake has a syntax inspired by rake (aka make in Ruby) and bake (aka make in Boo), but is easier to script because it leverages your existing command-line knowledge. - -psake is pronounced sake – as in Japanese rice wine. It does NOT rhyme with make, bake, or rake. - -## How to get started: - -**Step 1:** Download and extract the project - -You will need to "unblock" the zip file before extracting - PowerShell by default does not run files downloaded from the internet. -Just right-click the zip and click on "properties" and click on the "unblock" button. - -**Step 2:** CD into the directory where you extracted the project (where the psake.psm1 file is) - -> Import-Module .\psake.psm1 - -If you encounter the following error "Import-Module : ...psake.psm1 cannot be loaded because the execution of scripts is disabled on this system." Please see "get-help about_signing" for more details. - -1. Run PowerShell as administrator -2. Set-ExecutionPolicy RemoteSigned - -> Get-Help Invoke-psake -Full -> - this will show you help and examples of how to use psake - -**Step 3:** Run some examples - -> CD .\examples -> -> Invoke-psake -> - This will execute the "default" task in the "default.ps1" -> -> Invoke-psake .\default.ps1 Clean -> - will execute the single task in the default.ps1 script - -## How To Contribute, Collaborate, Communicate - -If you'd like to get involved with psake, we have discussion groups over at google: **[psake-dev](http://groups.google.com/group/psake-dev)** **[psake-users](http://groups.google.com/group/psake-users)** - -Anyone can fork the main repository and submit patches, as well. And lastly, the [wiki](http://wiki.github.com/psake/psake/) and [issues list](http://github.com/psake/psake/issues) are also open for additions, edits, and discussion. - -Also check out the **[psake-contrib](http://github.com/psake/psake-contrib)** project for scripts, modules and functions to help you with a build. - -## License - -psake is released under the [MIT license](http://www.opensource.org/licenses/MIT). diff --git a/build/psake/docs/access-functions-in-another-file.md b/build/psake/docs/access-functions-in-another-file.md deleted file mode 100644 index adfb175..0000000 --- a/build/psake/docs/access-functions-in-another-file.md +++ /dev/null @@ -1,22 +0,0 @@ -

-Use the *include* function to access functions that are in another script file. - -The following is an example: -

-
-Include ".\build_utils.ps1"
-
-Task default -depends Test
-
-Task Test -depends Compile, Clean {
-}
-
-Task Compile -depends Clean {
-}
-
-Task Clean {
-}
-
-

-You can have more than 1 include file in your script if you need to include multiple script files. -

\ No newline at end of file diff --git a/build/psake/docs/build-script-resilience.md b/build/psake/docs/build-script-resilience.md deleted file mode 100644 index 8834787..0000000 --- a/build/psake/docs/build-script-resilience.md +++ /dev/null @@ -1,52 +0,0 @@ -

-The *Task* function has a switch parameter called "ContinueOnError" that you can set if you want the build to continue running if that particular task throws an exception. - -Here's an example script that uses the "ContinueOnError" switch: -

-
-Task default -Depends TaskA
-
-Task TaskA -Depends TaskB {
-	"Task - A"
-}
-
-Task TaskB -Depends TaskC -ContinueOnError {
-	"Task - B"
-	throw "I failed on purpose!"
-}
-
-Task TaskC {
-	"Task - C"
-}
-
-

-When you run the above build script, you should get this output: -

-
-Executing task: TaskC
-Task - C
-Executing task: TaskB
-Task - B
-----------------------------------------------------------------------
-Error in Task [TaskB] I failed on purpose!
-----------------------------------------------------------------------
-Executing task: TaskA
-Task - A
-
-Build Succeeded!
-
-----------------------------------------------------------------------
-Build Time Report
-----------------------------------------------------------------------
-Name   Duration
-----   --------
-TaskC  00:00:00.0053110
-TaskB  00:00:00.0256725
-TaskA  00:00:00.0350228
-Total: 00:00:00.1032888
-
-

-when psake processes a task that throws an exception (TaskB in this example) and the "ContinueOnError" is set, then psake displays a message to the console indicating that the task had an error and continues processing the rest of the build script. - -Note: The dependent tasks of the task that threw the exception still execute -

\ No newline at end of file diff --git a/build/psake/docs/conditional-task.md b/build/psake/docs/conditional-task.md deleted file mode 100644 index a7b5596..0000000 --- a/build/psake/docs/conditional-task.md +++ /dev/null @@ -1,45 +0,0 @@ -

-You can conditionally run a task by using the "precondition" parameter of the "task" function. The "precondition" parameter expects a scriptblock as its value and that scriptblock should return a $true or $false. - -The following is an example build script that uses the "precondition" parameter of the task function: -

-
-task default -depends A,B,C
-
-task A {
-  "TaskA"
-}
-
-task B -precondition { return $false } {
-  "TaskB"
-}
-
-task C -precondition { return $true } {
-  "TaskC"
-}
-
-

-The output from running the above build script looks like the following: -

-
-Executing task: A
-TaskA
-Precondition was false not executing B
-Executing task: C
-TaskC
-
-Build Succeeded!
-
-----------------------------------------------------------------------
-Build Time Report
-----------------------------------------------------------------------
-Name   Duration
-----   --------
-A      00:00:00.0231283
-B      0
-C      00:00:00.0043444
-Total: 00:00:00.1405840
-
-

-Notice how task "B" was not executed and its run-time duration was 0 secs. -

\ No newline at end of file diff --git a/build/psake/docs/cruise-control.md b/build/psake/docs/cruise-control.md deleted file mode 100644 index 22de81b..0000000 --- a/build/psake/docs/cruise-control.md +++ /dev/null @@ -1,47 +0,0 @@ -Below are some sample tasks that worked for me (fschwiet), though I'm new to cruise control. Note that using a single apostrophe in the properties was necessary, double quotes would not work. - -Note that to make this work on older versions of psake, I needed to add a line to psake.ps1. Older versions may be missing a call to "exit $lasterrorcode" as the last line. - -For this example, the source control provider has been configured to put the code at c:\build\ProjectName.git. - -``` - - - - - c:\build\ProjectName.git - powershell.exe - .\default.ps1 -properties @{ - buildDirectory = 'c:\build\ProjectName.msbuild\'; - tempPath = 'c:\build\ProjectName.TestDatabases'; - sqlConnectionString = 'Database=''MyDB'';Data Source=.\;Integrated Security=True' - } - - 0 - Run psake script - - -``` - -The build output is hard to read and I don't think any of Cruise Control's built in view templates address that. I created a minimalistic stylesheet so the result is somewhat readable: - -``` - - - - - - - - - - -
- -
- - -
\
-
-
-``` \ No newline at end of file diff --git a/build/psake/docs/debug-script.md b/build/psake/docs/debug-script.md deleted file mode 100644 index 4e42729..0000000 --- a/build/psake/docs/debug-script.md +++ /dev/null @@ -1,52 +0,0 @@ -

-You can debug your psake build script in a couple of ways: -# Using *Set-PSBreakpoint*, *Get-PSBreakpoint* and *Remove-PSBreakpoint* -# Use the *PowerShell Integrated Scripting Environment (ISE)* - -With *Set-PSBreakpoint* you need to know what line number you want to set a breakpoint on, but the syntax is pretty simple: -

-``` -Set-PSBreakpoint [-Script] [-Line] [[-Column] ] [-Action ] [] -ex. -Set-PSBreakPoint -script default.ps1 -line 25 -``` -

-Once the breakpoint is set then you call the invoke-psake function on your script as normal and you should get a prompt from the command window: -

-``` -Entering debug mode. Use h or ? for help. - -Hit Line breakpoint on 'C:\Users\Daddy\Documents\Projects\psake\default.ps1:9' - -default.ps1:9 "TaskA is executing" -[DBG]: PS C:\Users\Daddy\Documents\Projects\psake>>> -``` -

-if you type "h" you will get the following options that will allow you to debug your script: -

-``` - s, stepInto Single step (step into functions, scripts, etc.) - v, stepOver Step to next statement (step over functions, scripts, etc.) - o, stepOut Step out of the current function, script, etc. - - c, continue Continue execution - q, quit Stop execution and exit the debugger - - k, Get-PSCallStack Display call stack - - l, list List source code for the current script. - Use "list" to start from the current line, "list " - to start from line , and "list " to list - lines starting from line - - Repeat last command if it was stepInto, stepOver or list - - ?, h Displays this help message -``` -

-While debugging you are able to inspect the values of your variables by just typing them at the prompt and hitting the [Enter] key - -Once you are done debugging you can call *Remove-PSBreakpoint* to remove the breakpoints you've added, you can use *Get-PSBreakpoint* to get a list of all the current breakpoints in the current session. - -With the *PowerShell Integrated Scripting Environment* all you need to do is to load your build script and click on the left margin to set a breakpoint, then run the invoke-psake function from the command window that is within the ISE (its in the bottom pane of the ISE). Then you can use the functions keys to debug your build script (F10, F11, etc.. they are under the "Debug" menu). -

\ No newline at end of file diff --git a/build/psake/docs/dot-net-solution.md b/build/psake/docs/dot-net-solution.md deleted file mode 100644 index b467b86..0000000 --- a/build/psake/docs/dot-net-solution.md +++ /dev/null @@ -1,95 +0,0 @@ -Here's an example of a basic script you can write to build a Visual Studio.Net solution: - -
-Task Default -depends Build
-
-Task Build {
-   Exec { msbuild "helloworld.sln" }
-}
-
-

-Builds tend to be more complex than what's shown in the example above. Most builds will need to know what the current directory is relative to where the build script was executed or where to look for code, where to deploy build artifacts or svn settings, etc... - -If you haven't guessed already, I'm referring to build properties. - -Here's a script that uses properties: -

-
-#This build assumes the following directory structure
-#
-#  \Build          - This is where the project build code lives
-#  \BuildArtifacts - This folder is created if it is missing and contains output of the build
-#  \Code           - This folder contains the source code or solutions you want to build
-#
-Properties {
-	$build_dir = Split-Path $psake.build_script_file	
-	$build_artifacts_dir = "$build_dir\..\BuildArtifacts\"
-	$code_dir = "$build_dir\..\Code"
-}
-
-FormatTaskName (("-"*25) + "[{0}]" + ("-"*25))
-
-Task Default -Depends BuildHelloWorld
-
-Task BuildHelloWorld -Depends Clean, Build
-
-Task Build -Depends Clean {	
-	Write-Host "Building helloworld.sln" -ForegroundColor Green
-	Exec { msbuild "$code_dir\helloworld\helloworld.sln" /t:Build /p:Configuration=Release /v:quiet /p:OutDir=$build_artifacts_dir } 
-}
-
-Task Clean {
-	Write-Host "Creating BuildArtifacts directory" -ForegroundColor Green
-	if (Test-Path $build_artifacts_dir) 
-	{	
-		rd $build_artifacts_dir -rec -force | out-null
-	}
-	
-	mkdir $build_artifacts_dir | out-null
-	
-	Write-Host "Cleaning helloworld.sln" -ForegroundColor Green
-	Exec { msbuild "$code_dir\helloworld\helloworld.sln" /t:Clean /p:Configuration=Release /v:quiet } 
-}
-
-

-Here's a helper script "run-build.ps1" that I use to load the psake module and execute the build: -

-
-$scriptPath = Split-Path $MyInvocation.InvocationName
-Import-Module (join-path $scriptPath psake.psm1)
-invoke-psake -framework '4.0'
-
-

I run the build in powershell by just running the script:

-
-PS > .\run-build.ps1
-
-

-The output from running the above build: -

-
--------------------------[Clean]-------------------------
-Creating BuildArtifacts directory
-Cleaning helloworld.sln
-Microsoft (R) Build Engine Version 4.0.30319.1
-[Microsoft .NET Framework, Version 4.0.30319.1]
-Copyright (C) Microsoft Corporation 2007. All rights reserved.
-
--------------------------[Build]-------------------------
-Building helloworld.sln
-Microsoft (R) Build Engine Version 4.0.30319.1
-[Microsoft .NET Framework, Version 4.0.30319.1]
-Copyright (C) Microsoft Corporation 2007. All rights reserved.
-
-
-Build Succeeded!
-
-----------------------------------------------------------------------
-Build Time Report
-----------------------------------------------------------------------
-Name            Duration
-----            --------
-Clean           00:00:09.4624557
-Build           00:00:12.2191711
-BuildHelloWorld 00:00:21.6931903
-Total:          00:00:21.8308190
-
\ No newline at end of file diff --git a/build/psake/docs/getting-help.md b/build/psake/docs/getting-help.md deleted file mode 100644 index d2d7fcf..0000000 --- a/build/psake/docs/getting-help.md +++ /dev/null @@ -1,60 +0,0 @@ -You can read this faq for help on how to use psake. - -You can also use the powershell command-let get-help on the *Invoke-psake* function to get more detailed help. - -
-# First import the psake.psm1 file 
-
-Import-Module .\psake.psm1
-
-Get-Help Invoke-psake -full
-
- -To list functions available in the psake module: - -
-C:\Software\psake> Get-Command -module psake
-
-CommandType     Name                                                          Definition
------------     ----                                                          ----------
-Function        Assert                                                        ...
-Function        Exec                                                          ...
-Function        FormatTaskName                                                ...
-Function        Include                                                       ...
-Function        Invoke-psake                                                  ...
-Function        Properties                                                    ...
-Function        Task                                                          ...
-Function        TaskSetup                                                     ...
-Function        TaskTearDown                                                  ...
-
-
- -To Get example usage for individual functions in the psake powershell module, use Get-Help, For example: - -
-
-C:\Software\psake> Get-Help Assert -examples
-
-NAME
-    Assert
-
-SYNOPSIS
-    Helper function for "Design by Contract" assertion checking.
-
-    -------------------------- EXAMPLE 1 --------------------------
-
-    C:\PS>Assert $false "This always throws an exception"
-
-
-    This example always throws an exception
-
-
-
-
-    -------------------------- EXAMPLE 2 --------------------------
-
-    C:\PS>Assert ( ($i % 2) -eq 0 ) "%i is not an even number"
-
-
-    This exmaple may throw an exception if $i is not an even number
-
\ No newline at end of file diff --git a/build/psake/docs/how-does-psake-work.md b/build/psake/docs/how-does-psake-work.md deleted file mode 100644 index 94bc5a2..0000000 --- a/build/psake/docs/how-does-psake-work.md +++ /dev/null @@ -1,22 +0,0 @@ -

**psake** is a domain specific language to create builds using a dependency pattern just like Ant, NAnt, Rake or MSBuild. - -You create a build script using PowerShell that consists of _Tasks_ which are simply function calls. Each _Task_ function can define dependencies on other _Task_ functions. - -In the example script below, Task _Compile_ depends on Tasks _Clean_ and _Init_, which means that before Task _Compile_ can execute, both tasks _Clean_ and _Init_ have to execute. psake ensures that this is done. -

-
-Task Compile -Depends Init,Clean {
-   "compile"
-}
-
-Task Clean -Depends Init {
-   "clean"
-}
-
-Task Init {
-   "init"
-}
-
-

-psake reads in your build script and executes the _Task_ functions that are defined within it and enforces the dependencies between tasks. The great thing about psake is that it is written in PowerShell and that means you have the power of .NET and all the features of PowerShell at your disposal within your build script. Not to mention that you don't have to pay the *XML* bracket tax anymore. -

diff --git a/build/psake/docs/how-to-fail-a-build.md b/build/psake/docs/how-to-fail-a-build.md deleted file mode 100644 index 549da3a..0000000 --- a/build/psake/docs/how-to-fail-a-build.md +++ /dev/null @@ -1,56 +0,0 @@ -

-When you run a command-line program, you need to check the $lastexitcode PowerShell variable to determine if the command-line program failed. If the $lastexitcode is non-zero that usually indicates a failure condition and you should throw a PowerShell exception so that your build script will fail appropriately. - -Here is an example: -

-
-task default -depends TaskA
-
-task TaskA {
-  #use cmd.exe and the DOS exit() function to simulate a failed command-line execution
-  "Executing command-line program"
-  cmd /c exit (1) 
-}
-
-

-The output from the above build script: -

-
-Executing task: TaskA
-Executing command-line program
-
-Build Succeeded!
-
-----------------------------------------------------------------------
-Build Time Report
-----------------------------------------------------------------------
-Name   Duration
-----   --------
-TaskA  00:00:00.1059589
-Total: 00:00:00.2233691
-
-

-The above build script will always succeed, even though we know the build should have failed - -Here is an example that does fail correctly: -

-
-task default -depends TaskA
-
-task TaskA {
-  #use cmd.exe and the DOS exit() function to simulate a failed command-line execution
-  "Executing command-line program"
-  cmd /c exit (1) 
-  if ($lastexitcode -ne 0)
-  {
-    throw "Comand-line program failed"
-  }
-}
-
-

-A simpler option is to use the psake "exec" function to execute command-line programs - -The following is an example: -

-
-task default -depends TaskA
diff --git a/build/psake/docs/hudson.md b/build/psake/docs/hudson.md
deleted file mode 100644
index 6c7d411..0000000
--- a/build/psake/docs/hudson.md
+++ /dev/null
@@ -1,45 +0,0 @@
-

-"Hudson":http://hudson-ci.org/ is a popular continuous integration server, it can be used to run pretty much any kind of build. To have Hudson run your psake build script you just need to create a Hudson job that will launch PowerShell with a parameter that is a PowerShell helper script that will in turn load the psake.psm1 module and then call the Invoke-psake function. You can use the psake.ps1 helper script but you will need to modify it so that the $psake.use_exit_on_error is set to $true. - -Here's the modified psake.ps1 file -

-
-# Helper script for those who want to run psake without importing the module.
-# Example:
-# .\psake.ps1 "default.ps1" "BuildHelloWord" "4.0" 
-
-# Must match parameter definitions for psake.psm1/invoke-psake 
-# otherwise named parameter binding fails
-param(
-  [Parameter(Position=0,Mandatory=0)]
-  [string]$buildFile = 'default.ps1',
-  [Parameter(Position=1,Mandatory=0)]
-  [string[]]$taskList = @(),
-  [Parameter(Position=2,Mandatory=0)]
-  [string]$framework = '3.5',
-  [Parameter(Position=3,Mandatory=0)]
-  [switch]$docs = $false,
-  [Parameter(Position=4,Mandatory=0)]
-  [System.Collections.Hashtable]$parameters = @{},
-  [Parameter(Position=5, Mandatory=0)]
-  [System.Collections.Hashtable]$properties = @{}
-)
-
-try {
-  $scriptPath = Split-Path $script:MyInvocation.MyCommand.Path
-  import-module (join-path $scriptPath psake.psm1)
-  $psake.use_exit_on_error = $true
-  invoke-psake $buildFile $taskList $framework $docs $parameters $properties
-} finally {
-  remove-module psake -ea 'SilentlyContinue'
-}
-
-

-Configure Hudson to call PowerShell passing in the helper script as a parameter: -

-
-powershell.exe "& 'psake.ps1 default.ps1'"
-
-

-I've written a blog "post":http://matosjorge.spaces.live.com/blog/cns!2E0DA1D30B684DA8!710.entry that shows how to do this without using a helper script. It uses a Hudson PowerShell plug-in that allows you to enter PowerShell commands directly into the Hudson job configuration. -

\ No newline at end of file diff --git a/build/psake/docs/index.md b/build/psake/docs/index.md deleted file mode 100644 index 7d8613d..0000000 --- a/build/psake/docs/index.md +++ /dev/null @@ -1,3 +0,0 @@ -*psake* is a build automation tool written in PowerShell. It avoids the angle-bracket tax associated with executable XML by leveraging the PowerShell syntax in your build scripts. psake has a syntax inspired by rake (aka make in Ruby) and bake (aka make in Boo), but is easier to script because it leverages your existent command-line knowledge. - -psake is pronounced sake - as in Japanese rice wine. It does NOT rhyme with make, bake, or rake. diff --git a/build/psake/docs/logging-errors.md b/build/psake/docs/logging-errors.md deleted file mode 100644 index e231002..0000000 --- a/build/psake/docs/logging-errors.md +++ /dev/null @@ -1,72 +0,0 @@ -

-The latest version of *psake* no longer provides a way to log errors to a file. Most builds are executed by a continuous integration server which already logs all console output so it's redundant to provide that same functionality in psake. If an error does occur detailed error information is emitted to the console so that it will get saved by whatever CI server is running psake. - -Here is an example of an error from a psake build script: -

-
-----------------------------------------------------------------------
-4/25/2010 2:36:21 PM: An Error Occurred. See Error Details Below: 
-----------------------------------------------------------------------
-ErrorRecord
-PSMessageDetails      : 
-Exception             : System.Management.Automation.RuntimeException: This is a test
-TargetObject          : This is a test
-CategoryInfo          : OperationStopped: (This is a test:String) [], RuntimeException
-FullyQualifiedErrorId : This is a test
-ErrorDetails          : 
-InvocationInfo        : System.Management.Automation.InvocationInfo
-PipelineIterationInfo : {}
-
-ErrorRecord.InvocationInfo
-MyCommand        : 
-BoundParameters  : {}
-UnboundArguments : {}
-ScriptLineNumber : 4
-OffsetInLine     : 7
-HistoryId        : 34
-ScriptName       : C:\Users\Daddy\Documents\Projects\helloworld\Build\LogError.ps1
-Line             :     throw "This is a test"
-PositionMessage  : 
-                   At C:\Users\Daddy\Documents\Projects\helloworld\Build\LogError.ps1:4 char:7
-                   +     throw <<<<  "This is a test"
-InvocationName   : throw
-PipelineLength   : 0
-PipelinePosition : 0
-ExpectingInput   : False
-CommandOrigin    : Internal
-
-Exception
-0000000000000000000000000000000000000000000000000000000000000000000000
-ErrorRecord                 : This is a test
-StackTrace                  : 
-WasThrownFromThrowStatement : True
-Message                     : This is a test
-Data                        : {}
-InnerException              : 
-TargetSite                  : 
-HelpLink                    : 
-Source                      : 
-
-----------------------------------------------------------------------
-Script Variables
-----------------------------------------------------------------------
-
-Name                           Value                                                                                                         
-----                           -----                                                                                                         
-_                                                                                                                                            
-args                           {}                                                                                                            
-context                        {System.Collections.Hashtable}                                                                                
-Error                          {}                                                                                                            
-false                          False                                                                                                         
-input                          System.Collections.ArrayList+ArrayListEnumeratorSimple                                                        
-MaximumAliasCount              4096                                                                                                          
-MaximumDriveCount              4096                                                                                                          
-MaximumErrorCount              256                                                                                                           
-MaximumFunctionCount           4096                                                                                                          
-MaximumVariableCount           4096                                                                                                          
-MyInvocation                   System.Management.Automation.InvocationInfo                                                                   
-null                                                                                                                                         
-psake                          {build_script_file, version, default_build_file_name, use_exit_on_error...}                                   
-this                                                                                                                                         
-true                           True              
-
\ No newline at end of file diff --git a/build/psake/docs/nested-build.md b/build/psake/docs/nested-build.md deleted file mode 100644 index 040f940..0000000 --- a/build/psake/docs/nested-build.md +++ /dev/null @@ -1,24 +0,0 @@ -

-Yes, the Invoke-psake function can be called recursively from within a "task" function - -The following is an example build script that has tasks that call the invoke-psake function to run other build scripts. -

-
-Properties {
-	$x = 1
-}
-
-Task default -Depends RunNested1, RunNested2, CheckX
-
-Task RunNested1 {
-	Invoke-psake .\nested\nested1.ps1
-}
-
-Task RunNested2 {
-	Invoke-psake .\nested\nested2.ps1
-}
-
-Task CheckX{
-	Assert ($x -eq 1) '$x was not 1' 
-}
-
\ No newline at end of file diff --git a/build/psake/docs/pass-parameters.md b/build/psake/docs/pass-parameters.md deleted file mode 100644 index a3fccd6..0000000 --- a/build/psake/docs/pass-parameters.md +++ /dev/null @@ -1,20 +0,0 @@ -

You can pass parameters to your build script using the "parameters" parameter of the Invoke-psake function. The following is an example:

-
- C:\PS>Invoke-psake .\parameters.ps1 -parameters @{"p1"="v1";"p2"="v2"}
-
-

-The example above runs the build script called "parameters.ps1" and passes in parameters 'p1' and 'p2' with values 'v1' and 'v2'. The parameter value for the "parameters" parameter (say that 10 times really fast!) is a PowerShell hashtable where the name and value of each parameter is specified. Note: You don't need to use the "$" character when specifying the parameter names in the hashtable. - -The "parameters.ps1" build script looks like this: -

-
-properties {
-  $my_property = $p1 + $p2
-}
-
-task default -depends TestParams
-
-task TestParams { 
-  Assert ($my_property -ne $null) '$my_property should not be null'  
-}
-
\ No newline at end of file diff --git a/build/psake/docs/print-psake-task-name.md b/build/psake/docs/print-psake-task-name.md deleted file mode 100644 index 133a997..0000000 --- a/build/psake/docs/print-psake-task-name.md +++ /dev/null @@ -1,73 +0,0 @@ -

-Use the psake *FormatTaskName* function. This function takes either a string which represents a format string (formats using the -f format operator see "help about_operators") or it can accept a script block that has a single parameter that is the name of the task that will be executed. - -Here is an example using the format string parameter of the *FormatTaskName* parameter: -

-
-Task default -depends TaskA, TaskB, TaskC
-
-FormatTaskName "-------- {0} --------"
-
-Task TaskA {
-  "TaskA is executing"  
-}
-
-Task TaskB {
-  "TaskB is executing"  
-}
-
-Task TaskC {
-  "TaskC is executing"  
-}
-
-

-The output looks like the following: -

-
--------- TaskA --------
-TaskA is executing
--------- TaskB --------
-TaskB is executing
--------- TaskC --------
-TaskC is executing
-
-Build Succeeded!
-
-----------------------------------------------------------------------
-Build Time Report
-----------------------------------------------------------------------
-Name   Duration
-----   --------
-TaskA  00:00:00.0058887
-TaskB  00:00:00.0057582
-TaskC  00:00:00.0043072
-Total: 00:00:00.1919297
-
-

-The following example uses the scriptblock parameter of the *FormatTaskName* function: -

-
-Task default -depends TaskA, TaskB, TaskC
-
-FormatTaskName {
-   param($taskName)
-   write-host "Executing Task: $taskName" -foregroundcolor blue
-}
-
-Task TaskA {
-  "TaskA is executing"  
-}
-
-Task TaskB {
-  "TaskB is executing"  
-}
-
-Task TaskC {
-  "TaskC is executing"  
-}
-
-

-The preceding example uses the scriptblock parameter to the FormatTaskName function to render each task name in the color blue. - -Note: the $taskName parameter is arbitrary it could be named anything -

\ No newline at end of file diff --git a/build/psake/docs/property-overrides.md b/build/psake/docs/property-overrides.md deleted file mode 100644 index 20020c8..0000000 --- a/build/psake/docs/property-overrides.md +++ /dev/null @@ -1,34 +0,0 @@ -

You can override a property in your build script using the "properties" parameter of the Invoke-psake function. The following is an example:

-
-C:\PS>Invoke-psake .\properties.ps1 -properties @{"x"="1";"y"="2"}
-
-

-The example above runs the build script called "properties.ps1" and passes in parameters 'x' and 'y' with values '1' and '2'. The parameter value for the "properties" parameter is a PowerShell hashtable where the name and value of each property is specified. Note: You don't need to use the "$" character when specifying the property names in the hashtable. - -The "properties.ps1" build script looks like this: -

-
-properties {
-	$x = $null
-	$y = $null
-	$z = $null
-}
-
-task default -depends TestProperties
-
-task TestProperties { 
-  Assert ($x -ne $null) "x should not be null"
-  Assert ($y -ne $null) "y should not be null"
-  Assert ($z -eq $null) "z should be null"
-}
-
-

-The value of $x should be 1 and $y should be 2 by the time the "TestProperties" task is executed. The value of $z was not over-ridden so it should still be $null. -

-

-To summarize the differences between passing parameters and properties to the Invoke-psake function: -

-
    -
  • Parameters and "properties" can both be passed to the Invoke-psake function simultaneously
  • -
  • Parameters are set before any "properties" blocks are run
  • -
  • Properties are set after all "properties" blocks have run
  • \ No newline at end of file diff --git a/build/psake/docs/retry-rules.md b/build/psake/docs/retry-rules.md deleted file mode 100644 index a9d1a5a..0000000 --- a/build/psake/docs/retry-rules.md +++ /dev/null @@ -1,15 +0,0 @@ -You can set retry rules for a ~~task~~ exec function by using the **maxRetries** parameter. For example, to have your ~~task~~ exec retry 3 times due to **any** unhandled exception: - -~~task MyTask -maxRetries 3~~ - - exec -maxRetries 3 - -You can also optionally specify a ~~task~~ exec to be retried only when a certain error message occurs using the **retryTriggerErrorPattern** parameter in conjunction with **maxRetries**: - -~~task MyTask -maxRetries 3 -retryTriggerErrorPattern "Service is not currently available."~~ - - exec -maxRetries 3 -retryTriggerErrorPattern "Service is not currently available." - -### Notes -1. psake will wait 1 second between retries. -2. The default for the maxRetries parameter if not specified is 0, i.e. the task will not be retried. \ No newline at end of file diff --git a/build/psake/docs/run-psake.md b/build/psake/docs/run-psake.md deleted file mode 100644 index 02dcc51..0000000 --- a/build/psake/docs/run-psake.md +++ /dev/null @@ -1,39 +0,0 @@ -

    -*psake* is a PowerShell module and is contained in a file named psake.psm1. - -There are 2 ways to run psake: - -1) Import the psake.psm1 module and call the Invoke-psake function -2) Call the psake.ps1 helper script - -Following is the first option: -

    -
    -Import-Module .\psake.psml
    -Invoke-psake .\default.ps1
    -
    -

    -Second option: -

    -
    -# call the psake.ps1 file directly
    -.\psake.ps1 .\default.ps1
    -
    -

    -When you call the psake.ps1 script, it forwards the parameters on to the Invoke-psake function. - -The benefit of option 1 is that you can get detailed help on the Invoke-psake function: -

    -
    -Import-Module .\psake.psml
    -Get-Help Invoke-psake -full
    -
    -

    -You may also consider making a helper script for your builds so that you can configure any psake options (-framework, etc) - -The following is an example helper script that configures psake to use the .NET 4.0 framework. -

    -
    -Import-Module (join-path $PSScriptRoot psake.psm1) -force
    -Invoke-psake -framework '4.0'
    -
    \ No newline at end of file diff --git a/build/psake/docs/structure-of-a-psake-build-script.md b/build/psake/docs/structure-of-a-psake-build-script.md deleted file mode 100644 index b4dc281..0000000 --- a/build/psake/docs/structure-of-a-psake-build-script.md +++ /dev/null @@ -1,59 +0,0 @@ -A psake build script contains calls to functions that the psake build engine will execute. - -The functions are the following: - -|Function|Description|Required| -|_Include()_|Call this function to have psake include the functions of another file into your script|no| -|_Properties()_|Call this function to set your properties|no| -|_Task()_|This is the main function that you write to execute a step in your build script. NOTE: There can be only one task function that is named "default" in your psake script and it cannot contain any code. psake will throw an exception if it finds more than one default task function or if the default task function contains code|yes| -|_Exec()_|Call a command-line program and throw an exception if it returns a non-zero DOS exit code|no| -|_Assert()_|Use to simplify writing conditional statements|no| -|_FormatTaskName()_|Allows you to reformat how psake displays the currently running task|no| -|_TaskSetup()_|A function that will run before each task is executed|no| -|_TaskTearDown()_|A function that will run after each task|no| - -An example psake script: -
    - -``` -Task default -Depends Test - -Task Test -Depends Compile, Clean { - "This is a test" - } - -Task Compile -Depends Clean { - "Compile" - } - -Task Clean { - "Clean" - } -``` -
    -

    The following is a BNF for a psake build script:

    - -pre. ::= - | - | - | - | - | - ::= Include | - ::= Properties | - ::= FormatTaskName - ::= TaskSetup - ::= TaskTearDown - ::= Task | - ::= -Name - | -Action - | -PreAction - | -PostAction - | -PreCondition - | -PostCondition - | -ContinueOnError - | -Depends - | -Description - ::= , | - ::= { } - ::= $true | $false \ No newline at end of file diff --git a/build/psake/docs/team-city.md b/build/psake/docs/team-city.md deleted file mode 100644 index b88c723..0000000 --- a/build/psake/docs/team-city.md +++ /dev/null @@ -1,31 +0,0 @@ -h3. PowerShell runner or Command Line runner - -TeamCity 6.5 has a bundled PowerShell runner, which can be used to run psake builds. For older versions of TeamCity, the "PowerShell runner plug-in":http://confluence.jetbrains.net/display/TW/PowerShell will do the job; you can download the plug-in's binaries "here":http://teamcity.jetbrains.net/repository/download/bt268/50151:id/teamcity-powershell.zip. See "Installing Additional Plugins":http://confluence.jetbrains.net/display/TCD6/Installing+Additional+Plugins for general help on installing plug-ins for TeamCity. - -Alternatively you can just run PowerShell.exe from Command Line Runner and then run psake. See example in "psake.cmd":https://github.com/psake/psake/blob/master/psake.cmd. - -h3. Setup of PowerShell runner - -Add a new build step and select *PowerShell* runner. - -# Set your run mode (x86 or x64) -# Set your working directory (typically the directory where your build scripts are located) -# Select *Source code* mode in Script input -# Insert into Script Source -``` -Import-Module 'PATH_TO_PSAKE_ROOT_FOLDER\psake.psm1' -Invoke-psake .\PSAKE_BUILD_FILENAME.ps1 RunTests -``` -# For 4.0.0: Make sure you have added **$psake.use_exit_on_error = $true** somewhere before the Invoke-psake call (e.g., amend the psake.ps1 file) -# For 4.0.1 unofficial realease on NuGet no additional steps are required -# For current development version append to & .\psake.ps1 also ; if ($psake.build_success -eq $false) { exit 1 } else { exit 0 }" to notify TeamCity about build failure - -Now you are ready. - -h3. Parameters - -If you need parameterize your build script, you can use the predefined "TeamCity parameters and variables":http://confluence.jetbrains.net/display/TCD6/Defining+and+Using+Build+Parameters+in+Build+Configuration. Pass in the parameters as a hash table using the following syntax: -
    & .\psake.ps1 -parameters @{build_number=%build.number%}
    - -You can pass multiple parameters by separating them with semicolons: -
    & .\psake.ps1 -parameters @{build_number=%build.number%; personal_build=%build.is.personal%}
    diff --git a/build/psake/docs/variable-referencing.md b/build/psake/docs/variable-referencing.md deleted file mode 100644 index 4332cee..0000000 --- a/build/psake/docs/variable-referencing.md +++ /dev/null @@ -1,120 +0,0 @@ -

    -Since *psake* is written in PowerShell, all variables follow the PowerShell scoping rules (PS> help about_scope). All the variables declared in the "properties" function have the "script" level scope and any variables declared within a "task" function are local variables. - -This means you can reference the "properties" variables from any "task" function but all variables declared within "task" function are not accessible from other "task" functions in the build script. - -The following is an example build script that uses a property variable from 2 different task functions: -

    -
    -properties {
    -  $x = 1
    -}
    -
    -task default -depends TaskA, TaskB
    -
    -task TaskA {
    -  '$x = ' + $x
    -}
    -
    -task TaskB {
    - '$x = ' + $x
    -}
    -
    -

    -The output from running the above build is: -

    -
    -Executing task: TaskA
    -$x = 1
    -Executing task: TaskB
    -$x = 1
    -
    -Build Succeeded!
    -
    -----------------------------------------------------------------------
    -Build Time Report
    -----------------------------------------------------------------------
    -Name   Duration
    -----   --------
    -TaskA  00:00:00.0086706
    -TaskB  00:00:00.0056644
    -Total: 00:00:00.0801045
    -
    -

    -Sometimes you may want/need to set a variable or update a property within a task and then refer to that variable/property from another task. - -The following example build script shows how to do that using the "script" scope modifier -

    -
    -properties {
    -  $x = 1
    -}
    -
    -task default -depends TaskA, TaskB
    -
    -task TaskA {
    -  $script:x = 100
    -  '$x = ' + $script:x
    -}
    -
    -task TaskB {
    - '$x = ' + $script:x
    -}
    -
    -

    -The output from the above script: -

    -
    -Executing task: TaskA
    -$x = 100
    -Executing task: TaskB
    -$x = 100
    -
    -Build Succeeded!
    -
    -----------------------------------------------------------------------
    -Build Time Report
    -----------------------------------------------------------------------
    -Name   Duration
    -----   --------
    -TaskA  00:00:00.0057736
    -TaskB  00:00:00.0054096
    -Total: 00:00:00.0820067
    -
    -

    -The following example does not update a property, it sets a "script" level variable ("y") within one task and references it in another task. -

    -
    -task default -depends TaskA, TaskB
    -
    -task TaskA {
    -  $script:y = 100
    -  '$y = ' + $script:y
    -}
    -
    -task TaskB {
    - '$y = ' + $script:y
    -}
    -
    -

    -The output from the above build script: -

    -
    -Executing task: TaskA
    -$y = 100
    -Executing task: TaskB
    -$y = 100
    -
    -Build Succeeded!
    -
    -----------------------------------------------------------------------
    -Build Time Report
    -----------------------------------------------------------------------
    -Name   Duration
    -----   --------
    -TaskA  00:00:00.0047757
    -TaskB  00:00:00.0048073
    -Total: 00:00:00.1244049
    -
    - -

    In case you create a variable with script scope, the variable is kept inside the psake module. This means, that if you run Invoke-Psake again, the variable is available. That’s why variables with script scope should be used carefully. Consider them as global variables accessible for all scripts running in psake.

    \ No newline at end of file diff --git a/build/psake/docs/what-can-i-use-psake-for.md b/build/psake/docs/what-can-i-use-psake-for.md deleted file mode 100644 index 90631de..0000000 --- a/build/psake/docs/what-can-i-use-psake-for.md +++ /dev/null @@ -1,2 +0,0 @@ -You can use **psake** for many things, building software, deploying software, back-end processing, etc... -psake is written in PowerShell, so you have access to the entire .NET framework. \ No newline at end of file diff --git a/build/psake/docs/where-can-i-get-psake.md b/build/psake/docs/where-can-i-get-psake.md deleted file mode 100644 index 855587c..0000000 --- a/build/psake/docs/where-can-i-get-psake.md +++ /dev/null @@ -1,7 +0,0 @@ -The source code has moved to GitHub: - * https://github.com/psake/psake.git - * git://github.com/psake/psake.git - -You can also download ZIP files of the project "binaries" from GitHub by selecting the appropriate tag and clicking the Download link: - -[[https://github.com/psake/psake]] \ No newline at end of file diff --git a/build/psake/docs/who-is-using-psake.md b/build/psake/docs/who-is-using-psake.md deleted file mode 100644 index fee0e10..0000000 --- a/build/psake/docs/who-is-using-psake.md +++ /dev/null @@ -1,6 +0,0 @@ -The following is a list (at the time of writing) of projects who are using psake to orchestrate their build process. - -* [ChocolateyGUI](https://github.com/chocolatey/ChocolateyGUI) -* [BoxStarter](https://github.com/mwrock/boxstarter) -* [ravendb](https://github.com/ravendb/ravendb) -* [Hangfire](https://github.com/HangfireIO/Hangfire) \ No newline at end of file diff --git a/build/psake/en-US/psake.psm1-help.xml b/build/psake/en-US/psake.psm1-help.xml deleted file mode 100644 index a7f5265..0000000 --- a/build/psake/en-US/psake.psm1-help.xml +++ /dev/null @@ -1,2265 +0,0 @@ - - - - - Invoke-psake - - Runs a psake build script. - - - - - Invoke - psake - - - - This function runs a psake build script - - - - Invoke-psake - - buildFile - String - - - taskList - String[] - - - framework - String - - - docs - SwitchParameter - - - parameters - Hashtable - - - properties - Hashtable - - - nologo - SwitchParameter - - - notr - SwitchParameter - - - - - - buildFile - - The path to the psake build script to execute - - String - - String - - - 'default.ps1' - - - taskList - - A comma-separated list of task names to execute - - String[] - - String[] - - - - - - framework - - The version of the .NET framework you want to use during build. You can append x86 or x64 to force a specific framework. If not specified, x86 or x64 will be detected based on the bitness of the PowerShell process. -Possible values: '1.0', '1.1', '2.0', '2.0x86', '2.0x64', '3.0', '3.0x86', '3.0x64', '3.5', '3.5x86', '3.5x64', '4.0', '4.0x86', '4.0x64', '4.5', '4.5x86', '4.5x64', '4.5.1', '4.5.1x86', '4.5.1x64' - - String - - String - - - '3.5' - - - docs - - Prints a list of tasks and their descriptions - - SwitchParameter - - SwitchParameter - - - - - - parameters - - A hashtable containing parameters to be passed into the current build script. These parameters will be processed before the 'Properties' function of the script is processed. This means you can access parameters from within the 'Properties' function! - - - Hashtable - - Hashtable - - - - - - properties - - A hashtable containing properties to be passed into the current build script. These properties will override matching properties that are found in the 'Properties' function of the script. - - Hashtable - - Hashtable - - - - - - nologo - - Do not display the startup banner and copyright message. - - SwitchParameter - - SwitchParameter - - - - - - notr - - Do not display the time report. - - SwitchParameter - - SwitchParameter - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - ---- Exceptions ---- - If there is an exception thrown during the running of a build script psake will set the '$psake.build_success' variable to $false. To detect failue outside PowerShell (for example by build server), finish PowerShell process with non-zero exit code when '$psake.build_success' is $false. Calling psake from 'cmd.exe' with 'psake.cmd' will give you that behaviour. - - - - ---- $psake variable ---- - When the psake module is loaded a variable called $psake is created which is a hashtable -containing some variables: - -$psake.version # contains the current version of psake -$psake.context # holds onto the current state of all variables -$psake.run_by_psake_build_tester # indicates that build is being run by psake-BuildTester -$psake.config_default # contains default configuration - # can be overriden in psake-config.ps1 in directory with psake.psm1 or in directory with current build script -$psake.build_success # indicates that the current build was successful -$psake.build_script_file # contains a System.IO.FileInfo for the current build script -$psake.build_script_dir # contains the fully qualified path to the current build script - -You should see the following when you display the contents of the $psake variable right after importing psake - -PS projects:\psake> Import-Module .\psake.psm1 -PS projects:\psake> $psake - -Name Value ----- ----- -run_by_psake_build_tester False -version 4.2 -build_success False -build_script_file -build_script_dir -config_default @{framework=3.5; ... -context {} - -After a build is executed the following $psake values are updated: build_script_file, build_script_dir, build_success - -PS projects:\psake> Invoke-psake .\examples\default.ps1 -Executing task: Clean -Executed Clean! -Executing task: Compile -Executed Compile! -Executing task: Test -Executed Test! - -Build Succeeded! - ----------------------------------------------------------------------- -Build Time Report ----------------------------------------------------------------------- -Name Duration ----- -------- -Clean 00:00:00.0798486 -Compile 00:00:00.0869948 -Test 00:00:00.0958225 -Total: 00:00:00.2712414 - -PS projects:\psake> $psake - -Name Value ----- ----- -build_script_file YOUR_PATH\examples\default.ps1 -run_by_psake_build_tester False -build_script_dir YOUR_PATH\examples -context {} -version 4.2 -build_success True -config_default @{framework=3.5; ... - - - - - - - - -------------- EXAMPLE 1 -------------- - - C:\PS> - - Invoke-psake - - Description - ----------- - Runs the 'default' task in the '.build.ps1' build script - - - - - - - - - - - - -------------- EXAMPLE 2 -------------- - - C:\PS> - - Invoke-psake '.\build.ps1' Tests,Package - - Description - ----------- - Runs the 'Tests' and 'Package' tasks in the '.build.ps1' build script - - - - - - - - - - - - -------------- EXAMPLE 3 -------------- - - C:\PS> - - Invoke-psake Tests - - Description - ----------- - This example will run the 'Tests' tasks in the 'default.ps1' build script. The 'default.ps1' is assumed to be in the current directory. - - - - - - - - - - - - -------------- EXAMPLE 4 -------------- - - C:\PS> - - Invoke-psake 'Tests, Package' - - Description - ----------- - This example will run the 'Tests' and 'Package' tasks in the 'default.ps1' build script. The 'default.ps1' is assumed to be in the current directory. - NOTE: The quotes around the list of tasks to execute is required if you want to execute more than 1 task. - - - - - - - - - - - -------------- EXAMPLE 5 -------------- - - C:\PS> - - Invoke-psake .\build.ps1 -docs - - Description - ----------- - Prints a report of all the tasks and their dependencies and descriptions and then exits - - - - - - - - - - - - -------------- EXAMPLE 6 -------------- - - C:\PS> - - Invoke-psake .\parameters.ps1 -parameters @{"p1"="v1";"p2"="v2"} - - Description - ----------- - Runs the build script called 'parameters.ps1' and passes in parameters 'p1' and 'p2' with values 'v1' and 'v2' - Here's the .\parameters.ps1 build script: - - - properties { - $my_property = $p1 + $p2 -} - -task default -depends TestParams - -task TestParams { - Assert ($my_property -ne $null) '$my_property should not be null' -} - - Notice how you can refer to the parameters that were passed into the script from within the “properties” function. The value of the $p1 variable should be the string “v1” and the value of the $p2 variable should be “v2”. - - - - - - - - - - -------------- EXAMPLE 7 -------------- - - C:\PS> - - Invoke-psake .\properties.ps1 -properties @{"x"="1";"y"="2"} - - Description - ----------- - Runs the build script called 'properties.ps1' and passes in parameters 'x' and 'y' with values '1' and '2' - This feature allows you to over-ride existing properties in your build script. - - Here's the .\properties.ps1 build script - properties { - $x = $null - $y = $null - $z = $null -} - -task default -depends TestProperties - -task TestProperties { - Assert ($x -ne $null) "x should not be null" - Assert ($y -ne $null) "y should not be null" - Assert ($z -eq $null) "z should be null" -} - - - - - - - - - - - - - Task - - - - Include - - - - Properties - - - - FormatTaskName - - - - TaskSetup - - - - TaskTearDown - - - - Assert - - - - Framework - - - - - - - - TaskTearDown - - Adds a scriptblock to the build that will be executed after each task - - - - - - - - - - This function will accept a scriptblock that will be executed after each -task in the build script. - - - - TaskTearDown - - teardown - ScriptBlock - - - - - - teardown - - A scriptblock to execute - - ScriptBlock - - ScriptBlock - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------- EXAMPLE 1 -------------- - - C:\PS> - - A sample build script is shown below: - -Task default -depends Test - -Task Test -depends Compile, Clean { -} - -Task Compile -depends Clean { -} - -Task Clean { -} - -TaskTearDown { - "Running 'TaskTearDown' for task $context.Peek().currentTaskName" -} - - Description - ----------- - The script above produces the following output: - Executing task, Clean... -Running 'TaskTearDown' for task Clean -Executing task, Compile... -Running 'TaskTearDown' for task Compile -Executing task, Test... -Running 'TaskTearDown' for task Test - -Build Succeeded - - - - - - - - - - - - Task - - - - Include - - - - Properties - - - - Invoke-psake - - - - TaskSetup - - - - TaskTearDown - - - - Assert - - - - Framework - - - - - - - - TaskSetup - - Adds a scriptblock that will be executed before each task - - - - - - - - - - This function will accept a scriptblock that will be executed before each -task in the build script. - - - - TaskSetup - - setup - ScriptBlock - - - - - - setup - - A scriptblock to execute - - ScriptBlock - - ScriptBlock - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------- EXAMPLE 1 -------------- - - C:\PS> - - A sample build script is shown below: - -Task default -depends Test - -Task Test -depends Compile, Clean { -} - -Task Compile -depends Clean { -} - -Task Clean { -} - -TaskSetup { - "Running 'TaskSetup' for task $context.Peek().currentTaskName" -} - - Description - ----------- - The script above produces the following output: - Running 'TaskSetup' for task Clean -Executing task, Clean... -Running 'TaskSetup' for task Compile -Executing task, Compile... -Running 'TaskSetup' for task Test -Executing task, Test... - -Build Succeeded - - - - - - - - - - - - Task - - - - Include - - - - Properties - - - - Invoke-psake - - - - FormatTaskName - - - - TaskTearDown - - - - Assert - - - - Framework - - - - - - - - Framework - - Sets the version of the .NET framework you want to use during build. - - - - - - - - - - This function will accept a string containing version of the .NET framework to use during build. Possible values: '1.0', '1.1', '2.0', '2.0x86', '2.0x64', '3.0', '3.0x86', '3.0x64', '3.5', '3.5x86', '3.5x64', '4.0', '4.0x86', '4.0x64', '4.5', '4.5x86', '4.5x64', '4.5.1', '4.5.1x86', '4.5.1x64'. Default is '3.5*', where x86 or x64 will be detected based on the bitness of the PowerShell process. - - - - Framework - - framework - string - - - - - - framework - - Version of the .NET framework to use during build. - - string - - string - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------- EXAMPLE 1 -------------- - -Framework "4.0" - -Task default -depends Compile - -Task Compile -depends Clean { - msbuild /version -} - - Description - ----------- - The script above will output detailed version of msbuid v4 - - - - - - - - - - - - Task - - - - Include - - - - Properties - - - - Invoke-psake - - - - FormatTaskName - - - - TaskSetup - - - - TaskTearDown - - - - Assert - - - - - - - - FormatTaskName - - This function allows you to change how psake renders the task name during a build. - - - - - - - - - - This function takes either a string which represents a format string (formats using the -f format operator see “help about_operators”) or it can accept a script block that has a single parameter that is the name of the task that will be executed. - - - - FormatTaskName - - format - String or ScriptBlock - - - - - - format - - A format string or a scriptblock to execute - - String or ScriptBlock - - String or ScriptBlock - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------- EXAMPLE 1 -------------- - - C:\PS> - - A sample build script that uses a format string is shown below: - -Task default -depends TaskA, TaskB, TaskC - -FormatTaskName "-------- {0} --------" - -Task TaskA { - "TaskA is executing" -} - -Task TaskB { - "TaskB is executing" -} - -Task TaskC { - "TaskC is executing" -} - - Description - ----------- - The script above produces the following output: - -------- TaskA -------- -TaskA is executing --------- TaskB -------- -TaskB is executing --------- TaskC -------- -TaskC is executing - -Build Succeeded! - - - - - - - - - - -------------- EXAMPLE 2 -------------- - - C:\PS> - - A sample build script that uses a ScriptBlock is shown below: - -Task default -depends TaskA, TaskB, TaskC - -FormatTaskName { - param($taskName) - write-host "Executing Task: $taskName" -foregroundcolor blue -} - -Task TaskA { - "TaskA is executing" -} - -Task TaskB { - "TaskB is executing" -} - -Task TaskC { - "TaskC is executing" -} - - Description - ----------- - The preceding example uses the scriptblock parameter to the FormatTaskName function to render each task name in the color blue. - Note: the $taskName parameter is arbitrary it could be named anything - - - - - - - - - - - - Task - - - - Include - - - - Properties - - - - Invoke-psake - - - - TaskSetup - - - - TaskTearDown - - - - Assert - - - - Framework - - - - - - - - - Get-PSakeScriptTasks - - Returns meta data about all the tasks defined in the provided psake script. - - - - - Get - PSakeScriptTasks - - - - Returns meta data about all the tasks defined in the provided psake script. - - - - Get-PSakeScriptTasks - - buildFile - - The path to the psake build script to read the tasks from. - - String - - - InformationAction - - - - ActionPreference - - - InformationVariable - - - - String - - - - - - buildFile - - The path to the psake build script to read the tasks from. - - String - - String - - - 'default.ps1' - - - InformationAction - - - - ActionPreference - - ActionPreference - - - - - - InformationVariable - - - - String - - String - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Include - - Include the functions or code of another powershell script file into the current build script's scope - - - - - - - - - - A build script may declare an "includes" function which allows you to define a file containing powershell code to be included and added to the scope of the currently running build script. Code from such file will be executed after code from build script. - - - - Include - - fileNamePathToInclude - String - - - - - - fileNamePathToInclude - - A string containing the path and name of the powershell file to include - - String - - String - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------- EXAMPLE 1 -------------- - - C:\PS> - - A sample build script is shown below: - -Include ".\build_utils.ps1" - -Task default -depends Test - -Task Test -depends Compile, Clean { -} - -Task Compile -depends Clean { -} - -Task Clean { -} - - Description - ----------- - The script above includes all the functions and variables defined in the ".\build_utils.ps1" script into the current build script's scope - Note: You can have more than 1 "Include" function defined in the build script - - - - - - - - - - - - Task - - - - FormatTaskName - - - - Properties - - - - Invoke-psake - - - - TaskSetup - - - - TaskTearDown - - - - Assert - - - - Framework - - - - - - - - Properties - - Define a scriptblock that contains assignments to variables that will be available to all tasks in the build script - - - - - - - - - - A build script may declare a "Properies" function which allows you to define variables that will be available to all the "Task" functions in the build script. - - - - Properties - - properties - ScriptBlock - - - - - - properties - - The script block containing all the variable assignment statements - - ScriptBlock - - ScriptBlock - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------- EXAMPLE 1 -------------- - - C:\PS> - - A sample build script is shown below: - -Properties { - $build_dir = "c:\build" - $connection_string = "datasource=localhost;initial catalog=northwind;integrated security=sspi" -} - -Task default -depends Test - -Task Test -depends Compile, Clean { -} - -Task Compile -depends Clean { -} - -Task Clean { -} - - Description - ----------- - Note: You can have more than 1 "Properties" function defined in the build script - - - - - - - - - - - - - - - Task - - - - FormatTaskName - - - - Include - - - - Invoke-psake - - - - TaskSetup - - - - TaskTearDown - - - - Assert - - - - Framework - - - - - - - - Task - - Defines a build task to be executed by psake - - - - - - - - - - This function creates a 'task' object that will be used by the psake engine to execute a build task. Note: There must be at least one task called 'default' in the build script - - - - Task - - Name - String - - - Action - ScriptBlock - - - PreAction - ScriptBlock - - - PostAction - ScriptBlock - - - Precondition - ScriptBlock - - - Postcondition - ScriptBlock - - - ContinueOnError - Boolean - - - Depends - String[] - - - RequiredVariables - String[] - - - Description - String[] - - - - - - Name - - The name of the task - - String - - String - - - - - - Action - - A scriptblock containing the statements to execute for the task. - - ScriptBlock - - ScriptBlock - - - - - - PreAction - - A scriptblock to be executed before the 'Action' scriptblock. Note: This parameter is ignored if the 'Action' scriptblock is not defined. - - ScriptBlock - - ScriptBlock - - - - - - PostAction - - A scriptblock to be executed after the 'Action' scriptblock. Note: This parameter is ignored if the 'Action' scriptblock is not defined. - - ScriptBlock - - ScriptBlock - - - - - - Precondition - - A scriptblock that is executed to determine if the task is executed or skipped. This scriptblock should return $true or $false - - ScriptBlock - - ScriptBlock - - - - - - Postcondition - - A scriptblock that is executed to determine if the task completed its job correctly. An exception is thrown if the scriptblock returns $false. - - ScriptBlock - - ScriptBlock - - - - - - ContinueOnError - - If this switch parameter is set then the task will not cause the build to fail when an exception is thrown by the task - - SwitchParameter - - SwitchParameter - - - - - - Depends - - An array of task names that this task depends on. These tasks will be executed before the current task is executed. - - String[] - - String[] - - - - - - RequiredVariables - - An array of names of variables that must be set to run this task. - - String[] - - String[] - - - - - - Description - - A description of the task. - - String - - String - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------- EXAMPLE 1 -------------- - - C:\PS> - - A sample build script is shown below: - -Task default -Depends Test - -Task Test -Depends Compile, Clean { - "This is a test" -} - -Task Compile -Depends Clean { - "Compile" -} - -Task Clean { - "Clean" -} - -The 'default' task is required and should not contain an 'Action' parameter. -It uses the 'Depends' parameter to specify that 'Test' is a dependency - -The 'Test' task uses the 'Depends' parameter to specify that 'Compile' and 'Clean' are dependencies -The 'Compile' task depends on the 'Clean' task. - -Note: -The 'Action' parameter is defaulted to the script block following the 'Clean' task. - -An equivalent 'Test' task is shown below: - -Task Test -Depends Compile, Clean -Action { - $testMessage -} - -The output for the above sample build script is shown below: -Executing task, Clean... -Clean -Executing task, Compile... -Compile -Executing task, Test... -This is a test - -Build Succeeded! - ----------------------------------------------------------------------- -Build Time Report ----------------------------------------------------------------------- -Name Duration ----- -------- -Clean 00:00:00.0065614 -Compile 00:00:00.0133268 -Test 00:00:00.0225964 -Total: 00:00:00.0782496 - - - - - - - - - - - - - - - - Properties - - - - FormatTaskName - - - - Include - - - - Invoke-psake - - - - TaskSetup - - - - TaskTearDown - - - - Assert - - - - Framework - - - - - - - - Assert - - Helper function for "Design by Contract" assertion checking. - - - - - - - - - - This is a helper function that makes the code less noisy by eliminating many of the "if" statements that are normally required to verify assumptions in the code. - - - - Assert - - conditionToCheck - Boolean - - - failureMessage - String - - - - - - conditionToCheck - - The boolean condition to evaluate - - Boolean - - Boolean - - - - - - failureMessage - - The error message used for the exception if the conditionToCheck parameter is false - - String - - String - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------- EXAMPLE 1 -------------- - - C:\PS> - - Assert $false "This always throws an exception" - - - - - - - - - - - - - -------------- EXAMPLE 2 -------------- - - C:\PS> - - Assert ( ($i % 2) -eq 0 ) "$i is not an even number" - - Description - ----------- - This exmaple may throw an exception if $i is not an even number - - Note: - It might be necessary to wrap the condition with paranthesis to force PS to evaluate the condition -so that a boolean value is calculated and passed into the 'conditionToCheck' parameter. - -Example: - Assert 1 -eq 2 "1 doesn't equal 2" - -PS will pass 1 into the condtionToCheck variable and PS will look for a parameter called "eq" and -throw an exception with the following message "A parameter cannot be found that matches parameter name 'eq'" - -The solution is to wrap the condition in () so that PS will evaluate it first. - - Assert (1 -eq 2) "1 doesn't equal 2" - - - - - - - - - - - - - Task - - - - FormatTaskName - - - - Include - - - - Invoke-psake - - - - TaskSetup - - - - TaskTearDown - - - - Properties - - - - - Framework - - - - - - - Exec - - Helper function for executing command-line programs. - - - - - - - - - - This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode to see if an error occcured. If an error is detected then an exception is thrown. This function allows you to run command-line programs without having to explicitly check fthe $lastexitcode variable. - - - - Exec - - cmd - ScriptBlock - - - errorMessage - String - - - - - - cmd - - The scriptblock to execute. This scriptblock will typically contain the command-line invocation. - - ScriptBlock - - Boolean - - - - - - failureMessage - - The error message used for the exception that is thrown. - - String - - String - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------- EXAMPLE 1 -------------- - - C:\PS> - - exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed" - - This example calls the svn command-line client. - - - - - - - - - - - - - - Assert - - - - FormatTaskName - - - - Include - - - - Invoke-psake - - - - Properties - - - - Task - - - - TaskSetup - - - - TaskTearDown - - - - - Framework - - - - - - - Invoke-Task - - Executes another task in the current build script. - - - - - - - - - - This is a function that will allow you to invoke a Task from within another Task in the current build script. - - - - Invoke-Task - - taskName - String - - - - - - taskName - - The name of the task to execute. - - String - - String - - - - - - - - - None - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - -------------- EXAMPLE 1 -------------- - - C:\PS> - - Invoke-Task "Compile" - - This example calls the "Compile" task. - - - - - - - - - - - - - - Assert - - - - Exec - - - - FormatTaskName - - - - Include - - - - Invoke-psake - - - - Properties - - - - Task - - - - TaskSetup - - - - TaskTearDown - - - - Framework - - - - - diff --git a/build/psake/examples/checkvariables.ps1 b/build/psake/examples/checkvariables.ps1 deleted file mode 100644 index 0d6b0b1..0000000 --- a/build/psake/examples/checkvariables.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -Properties { - $x = 1 - $y = 2 -} - -FormatTaskName "[{0}]" - -Task default -Depends Verify - -Task Verify -Description "This task verifies psake's variables" { - - Assert (Test-Path 'variable:\psake') "psake variable was not exported from module" - - Assert ($psake.ContainsKey("version")) "psake variable does not contain 'version'" - Assert ($psake.ContainsKey("context")) "psake variable does not contain 'context'" - Assert ($psake.ContainsKey("build_success")) "psake variable does not contain 'build_success'" - Assert ($psake.ContainsKey("build_script_file")) "psake variable does not contain 'build_script_file'" - Assert ($psake.ContainsKey("build_script_dir")) "psake variable does not contain 'build_script_dir'" - - Assert (![string]::IsNullOrEmpty($psake.version)) '$psake.version was null or empty' - Assert ($psake.context -ne $null) '$psake.context was null' - Assert (!$psake.build_success) '$psake.build_success should be $false' - Assert ($psake.build_script_file -ne $null) '$psake.build_script_file was null' - Assert ($psake.build_script_file.Name -eq "checkvariables.ps1") ("psake variable: {0} was not equal to 'checkvariables.ps1'" -f $psake.build_script_file.Name) - Assert (![string]::IsNullOrEmpty($psake.build_script_dir)) '$psake.build_script_dir was null or empty' - - Assert ($psake.context.Peek().tasks.Count -ne 0) "psake context variable 'tasks' had length zero" - Assert ($psake.context.Peek().properties.Count -ne 0) "psake context variable 'properties' had length zero" - Assert ($psake.context.Peek().includes.Count -eq 0) "psake context variable 'includes' should have had length zero" - Assert ($psake.context.Peek().config -ne $null) "psake context variable 'config' was null" - - Assert ($psake.context.Peek().currentTaskName -eq "Verify") 'psake variable: $currentTaskName was not set correctly' -} \ No newline at end of file diff --git a/build/psake/examples/continueonerror.ps1 b/build/psake/examples/continueonerror.ps1 deleted file mode 100644 index c8a633f..0000000 --- a/build/psake/examples/continueonerror.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -Task default -Depends TaskA - -Task TaskA -Depends TaskB { - "Task - A" -} - -Task TaskB -Depends TaskC -ContinueOnError { - "Task - B" - throw "I failed on purpose!" -} - -Task TaskC { - "Task - C" -} \ No newline at end of file diff --git a/build/psake/examples/default.ps1 b/build/psake/examples/default.ps1 deleted file mode 100644 index 4aca358..0000000 --- a/build/psake/examples/default.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -properties { - $testMessage = 'Executed Test!' - $compileMessage = 'Executed Compile!' - $cleanMessage = 'Executed Clean!' -} - -task default -depends Test - -task Test -depends Compile, Clean { - $testMessage -} - -task Compile -depends Clean { - $compileMessage -} - -task Clean { - $cleanMessage -} - -task ? -Description "Helper to display task info" { - Write-Documentation -} \ No newline at end of file diff --git a/build/psake/examples/formattaskname_scriptblock.ps1 b/build/psake/examples/formattaskname_scriptblock.ps1 deleted file mode 100644 index e4919b9..0000000 --- a/build/psake/examples/formattaskname_scriptblock.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -properties { - $testMessage = 'Executed Test!' - $compileMessage = 'Executed Compile!' - $cleanMessage = 'Executed Clean!' -} - -task default -depends Test - -formatTaskName { - param($taskName) - write-host $taskName -foregroundcolor Green -} - -task Test -depends Compile, Clean { - $testMessage -} - -task Compile -depends Clean { - $compileMessage -} - -task Clean { - $cleanMessage -} \ No newline at end of file diff --git a/build/psake/examples/formattaskname_string.ps1 b/build/psake/examples/formattaskname_string.ps1 deleted file mode 100644 index 6687490..0000000 --- a/build/psake/examples/formattaskname_string.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -properties { - $testMessage = 'Executed Test!' - $compileMessage = 'Executed Compile!' - $cleanMessage = 'Executed Clean!' -} - -task default -depends Test - -formatTaskName "-------{0}-------" - -task Test -depends Compile, Clean { - $testMessage -} - -task Compile -depends Clean { - $compileMessage -} - -task Clean { - $cleanMessage -} \ No newline at end of file diff --git a/build/psake/examples/msbuild40.ps1 b/build/psake/examples/msbuild40.ps1 deleted file mode 100644 index 2298e42..0000000 --- a/build/psake/examples/msbuild40.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -Framework "4.0" -# Framework "4.0x64" - -task default -depends ShowMsBuildVersion - -task ShowMsBuildVersion { - msbuild /version -} \ No newline at end of file diff --git a/build/psake/examples/nested.ps1 b/build/psake/examples/nested.ps1 deleted file mode 100644 index 36fc830..0000000 --- a/build/psake/examples/nested.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -Properties { - $x = 1 -} - -Task default -Depends RunNested1, RunNested2, CheckX - -Task RunNested1 { - Invoke-psake .\nested\nested1.ps1 -} - -Task RunNested2 { - Invoke-psake .\nested\nested2.ps1 -} - -Task CheckX{ - Assert ($x -eq 1) '$x was not 1' -} \ No newline at end of file diff --git a/build/psake/examples/nested/nested1.ps1 b/build/psake/examples/nested/nested1.ps1 deleted file mode 100644 index 81790ec..0000000 --- a/build/psake/examples/nested/nested1.ps1 +++ /dev/null @@ -1 +0,0 @@ -Properties { $x = 100 } Task default -Depends Nested1CheckX Task Nested1CheckX{ Assert ($x -eq 100) '$x was not 100' } \ No newline at end of file diff --git a/build/psake/examples/nested/nested2.ps1 b/build/psake/examples/nested/nested2.ps1 deleted file mode 100644 index 7a4a2b8..0000000 --- a/build/psake/examples/nested/nested2.ps1 +++ /dev/null @@ -1 +0,0 @@ -Properties { $x = 200 } Task default -Depends Nested2CheckX Task Nested2CheckX{ Assert ($x -eq 200) '$x was not 200' } \ No newline at end of file diff --git a/build/psake/examples/paralleltasks.ps1 b/build/psake/examples/paralleltasks.ps1 deleted file mode 100644 index 24a401f..0000000 --- a/build/psake/examples/paralleltasks.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -Task ParallelTask1 { - "ParallelTask1" -} - -Task ParallelTask2 { - "ParallelTask2" -} - -Task ParallelNested1andNested2 { - $jobArray = @() - @("ParallelTask1", "ParallelTask2") | ForEach-Object { - $jobArray += Start-Job { - param($scriptFile, $taskName) - Invoke-psake $scriptFile -taskList $taskName - } -ArgumentList $psake.build_script_file.FullName, $_ - } - Wait-Job $jobArray | Receive-Job -} - -Task default -depends ParallelNested1andNested2 \ No newline at end of file diff --git a/build/psake/examples/parameters.ps1 b/build/psake/examples/parameters.ps1 deleted file mode 100644 index 0a902b7..0000000 --- a/build/psake/examples/parameters.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -properties { - $my_property = $p1 + $p2 -} - -task default -depends TestParams - -task TestParams { - Assert ($my_property -ne $null) "`$my_property should not be null. Run with -parameters @{'p1' = 'v1'; 'p2' = 'v2'}" -} \ No newline at end of file diff --git a/build/psake/examples/passingParametersString/build.Release.Version.bat b/build/psake/examples/passingParametersString/build.Release.Version.bat deleted file mode 100644 index a48c126..0000000 --- a/build/psake/examples/passingParametersString/build.Release.Version.bat +++ /dev/null @@ -1,3 +0,0 @@ -powershell -Command "& {Import-Module .\..\..\psake.psm1; Invoke-psake .\parameters.ps1 -parameters @{"buildConfiguration"='Release';} }" - -Pause \ No newline at end of file diff --git a/build/psake/examples/passingParametersString/parameters.ps1 b/build/psake/examples/passingParametersString/parameters.ps1 deleted file mode 100644 index 4850975..0000000 --- a/build/psake/examples/passingParametersString/parameters.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -properties { - $buildOutputPath = ".\bin\$buildConfiguration" -} - -task default -depends DoRelease - -task DoRelease { - Assert ("$buildConfiguration" -ne $null) "buildConfiguration should not have been null" - Assert ("$buildConfiguration" -eq 'Release') "buildConfiguration=[$buildConfiguration] should have been 'Release'" - - Write-Host "" - Write-Host "" - Write-Host "" - Write-Host -NoNewline "Would build output into path " - Write-Host -NoNewline -ForegroundColor Green "$buildOutputPath" - Write-Host -NoNewline " for build configuration " - Write-Host -ForegroundColor Green "$buildConfiguration" - Write-Host -NoNewline "." - Write-Host "" - Write-Host "" - Write-Host "" -} diff --git a/build/psake/examples/preandpostaction.ps1 b/build/psake/examples/preandpostaction.ps1 deleted file mode 100644 index fcb36e6..0000000 --- a/build/psake/examples/preandpostaction.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -task default -depends Test - -task Test -depends Compile, Clean -PreAction {"Pre-Test"} -Action { - "Test" -} -PostAction {"Post-Test"} - -task Compile -depends Clean { - "Compile" -} - -task Clean { - "Clean" -} \ No newline at end of file diff --git a/build/psake/examples/preandpostcondition.ps1 b/build/psake/examples/preandpostcondition.ps1 deleted file mode 100644 index ce855fb..0000000 --- a/build/psake/examples/preandpostcondition.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -properties { - $runTaskA = $false - $taskBSucceded = $true -} - -task default -depends TaskC - -task TaskA -precondition { $runTaskA -eq $true } { - "TaskA executed" -} - -task TaskB -postcondition { $taskBSucceded -eq $true } { - "TaskB executed" -} - -task TaskC -depends TaskA,TaskB { - "TaskC executed." -} \ No newline at end of file diff --git a/build/psake/examples/properties.ps1 b/build/psake/examples/properties.ps1 deleted file mode 100644 index ccbb3ec..0000000 --- a/build/psake/examples/properties.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -properties { - $x = $null - $y = $null - $z = $null -} - -task default -depends TestProperties - -task TestProperties { - Assert ($x -ne $null) "x should not be null. Run with -properties @{'x' = '1'; 'y' = '2'}" - Assert ($y -ne $null) "y should not be null. Run with -properties @{'x' = '1'; 'y' = '2'}" - Assert ($z -eq $null) "z should be null" -} \ No newline at end of file diff --git a/build/psake/examples/requiredvariables.ps1 b/build/psake/examples/requiredvariables.ps1 deleted file mode 100644 index d9922bb..0000000 --- a/build/psake/examples/requiredvariables.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -properties { - $x = $null - $y = $null - $z = $null -} - -task default -depends TestRequiredVariables - -# you can put arguments to task in multiple lines using ` -task TestRequiredVariables ` - -description "This task shows how to make a variable required to run task. Run this script with -properties @{x = 1; y = 2; z = 3}" ` - -requiredVariables x, y, z ` -{ -} diff --git a/build/psake/examples/tasksetupandteardown.ps1 b/build/psake/examples/tasksetupandteardown.ps1 deleted file mode 100644 index be0834a..0000000 --- a/build/psake/examples/tasksetupandteardown.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -TaskSetup { - "Executing task setup" -} - -TaskTearDown { - "Executing task tear down" -} - -Task default -depends TaskB - -Task TaskA { - "TaskA executed" -} - -Task TaskB -depends TaskA { - "TaskB executed" -} diff --git a/build/psake/images/SakeBottle.jpg b/build/psake/images/SakeBottle.jpg deleted file mode 100644 index a3f6692..0000000 Binary files a/build/psake/images/SakeBottle.jpg and /dev/null differ diff --git a/build/psake/images/SakeBottleLicense.txt b/build/psake/images/SakeBottleLicense.txt deleted file mode 100644 index 7563976..0000000 --- a/build/psake/images/SakeBottleLicense.txt +++ /dev/null @@ -1,4 +0,0 @@ -SakeBottle.jpg -An American produced bottle of Ginjo Sake. -Shawn Clark Lazyeights Photography http://lazyeights.net/cpg/displayimage.php?pos=-122 -This work is licensed under the Creative Commons Attribution 2.5 License (http://creativecommons.org/licenses/by/2.5/). \ No newline at end of file diff --git a/build/psake/images/psake.pdn b/build/psake/images/psake.pdn deleted file mode 100644 index 8bd0bef..0000000 Binary files a/build/psake/images/psake.pdn and /dev/null differ diff --git a/build/psake/images/psake.png b/build/psake/images/psake.png deleted file mode 100644 index 8ce869f..0000000 Binary files a/build/psake/images/psake.png and /dev/null differ diff --git a/build/psake/license.txt b/build/psake/license.txt deleted file mode 100644 index 1d446c5..0000000 --- a/build/psake/license.txt +++ /dev/null @@ -1,20 +0,0 @@ -psake -Copyright (c) 2012-13 James Kovacs, Damian Hickey and Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/build/psake/mkdocs.yml b/build/psake/mkdocs.yml deleted file mode 100644 index ca28cb4..0000000 --- a/build/psake/mkdocs.yml +++ /dev/null @@ -1,29 +0,0 @@ -site_name: psake -theme: readthedocs -repo_url: https://github.com/psake/psake - -pages: -- What is psake?: index.md -- How does psake work?: how-does-psake-work.md -- Where can I get psake?: where-can-i-get-psake.md -- What can I use psake for?: what-can-i-use-psake-for.md -- What is the structure of a psake build script?: structure-of-a-psake-build-script.md -- How can I get help on how to use psake?: getting-help.md -- How do I run psake?: run-psake.md -- How can I debug my psake script?: debug-script.md -- How can I use psake to build a VS.NET solution?: dot-net-solution.md -- How can I change the way psake prints out the name of each task?: print-psake-task-name.md -- How can I pass parameters to my psake script?: pass-parameters.md -- How can I override a property defined in my psake script?: property-overrides.md -- How can I conditionally run a task?: conditional-task.md -- How can I set a variable in one task and reference it in another?: variable-referencing.md -- How can I access functions that are in other script files from within psake?: access-functions-in-another-file.md -- How can I force the build to fail if a command-line program I run from a task fails?: how-to-fail-a-build.md -- How can I ensure my build script keeps running even if one of my tasks throws an exception?: build-script-resilience.md -- Can I run a nested build?: nested-build.md -- How can I log any errors from my build to a file?: logging-errors.md -- How can I integrate psake with Hudson?: hudson.md -- How can I integrate psake with Team City?: team-city.md -- How can I integrate psake with Cruise Control.NET?: cruise-control.md -- How can I set retry rules for a task?: retry-rules.md -- Who is using psake?: who-is-using-psake.md \ No newline at end of file diff --git a/build/psake/nuget/psake.nuspec b/build/psake/nuget/psake.nuspec deleted file mode 100644 index 4b85b86..0000000 --- a/build/psake/nuget/psake.nuspec +++ /dev/null @@ -1,15 +0,0 @@ - - - - psake - 0.0.0 - James Kovacs - James Kovacs, Damian Hickey - https://github.com/psake/psake - false - psake is a build automation tool written in PowerShell - psake is a build automation tool written in PowerShell. It avoids the angle-bracket tax associated with executable XML by leveraging the PowerShell syntax in your build scripts. psake has a syntax inspired by rake (aka make in Ruby) and bake (aka make in Boo), but is easier to script because it leverages your existent command-line knowledge. psake is pronounced sake - as in Japanese rice wine. It does NOT rhyme with make, bake, or rake. You can also install with chocolatey (http://nuget.org/List/Packages/chocolatey) and have global psake. - en-US - build powershell - - diff --git a/build/psake/nuget/tools/chocolateyInstall.ps1 b/build/psake/nuget/tools/chocolateyInstall.ps1 deleted file mode 100644 index 1f6449d..0000000 --- a/build/psake/nuget/tools/chocolateyInstall.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -$nugetPath = $env:ChocolateyInstall -$nugetExePath = Join-Path $nuGetPath 'bin' -$packageBatchFileName = Join-Path $nugetExePath "psake.bat" - -$psakeDir = (Split-Path -parent $MyInvocation.MyCommand.Definition) -#$path = ($psakeDir | Split-Path | Join-Path -ChildPath 'psake.cmd') -$path = Join-Path $psakeDir 'psake.cmd' -Write-Host "Adding $packageBatchFileName and pointing to $path" -"@echo off -""$path"" %*" | Out-File $packageBatchFileName -encoding ASCII - -Write-Host "PSake is now ready. You can type 'psake' from any command line at any path. Get started by typing 'psake /?'" diff --git a/build/psake/nuget/tools/init.ps1 b/build/psake/nuget/tools/init.ps1 deleted file mode 100644 index 82631da..0000000 --- a/build/psake/nuget/tools/init.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -param($installPath, $toolsPath, $package) - -$psakeModule = Join-Path $toolsPath psake.psm1 -import-module $psakeModule diff --git a/build/psake/psake-buildTester.ps1 b/build/psake/psake-buildTester.ps1 deleted file mode 100644 index 0bbc707..0000000 --- a/build/psake/psake-buildTester.ps1 +++ /dev/null @@ -1,84 +0,0 @@ -function Main() -{ - write-host "Running psake build tests" -ForeGroundColor GREEN - remove-module psake -ea SilentlyContinue - import-module .\psake.psm1 - $psake.run_by_psake_build_tester = $true - $results = runBuilds - remove-module psake - - "" - $results | Sort 'Name' | % { if ($_.Result -eq "Passed") { write-host ($_.Name + " (Passed)") -ForeGroundColor 'GREEN'} else { write-host ($_.Name + " (Failed)") -ForeGroundColor 'RED'}} - "" - - $failed = $results | ? { $_.Result -eq "Failed" } - if ($failed) - { - write-host "One or more of the build files failed" -ForeGroundColor RED - exit 1 - } - else - { - write-host "All Builds Passed" -ForeGroundColor GREEN - exit 0 - } -} - -function runBuilds() -{ - $buildFiles = ls specs\*.ps1 - $testResults = @() - - #Add a fake build file to the $buildFiles array so that we can verify - #that Invoke-psake fails - $non_existant_buildfile = "" | select Name, FullName - $non_existant_buildfile.Name = "specifying_a_non_existant_buildfile_should_fail.ps1" - $non_existant_buildfile.FullName = "c:\specifying_a_non_existant_buildfile_should_fail.ps1" - $buildFiles += $non_existant_buildfile - - foreach($buildFile in $buildFiles) - { - $testResult = "" | select Name, Result - $testResult.Name = $buildFile.Name - invoke-psake $buildFile.FullName -Parameters @{'p1'='v1'; 'p2'='v2'} -Properties @{'x'='1'; 'y'='2'} -Initialization { if(!$container) { $container = @{}; } $container.bar = "bar"; $container.baz = "baz"; $bar = 2; $baz = 3 } | Out-Null - $testResult.Result = (getResult $buildFile.Name $psake.build_success) - $testResults += $testResult - if ($testResult.Result -eq "Passed") - { - write-host "." -ForeGroundColor GREEN -NoNewLine - } - else - { - write-host "F" -ForeGroundColor RED -NoNewLine - } - } - - return $testResults -} - -function getResult([string]$fileName, [bool]$buildSucceeded) -{ - $shouldSucceed = $null - if ($fileName.EndsWith("_should_pass.ps1")) - { - $shouldSucceed = $true - } - elseif ($fileName.EndsWith("_should_fail.ps1")) - { - $shouldSucceed = $false - } - else - { - throw "Invalid specification syntax. Specs should end with _should_pass or _should_fail. $fileName" - } - if ($buildSucceeded -eq $shouldSucceed) - { - "Passed" - } - else - { - "Failed" - } -} - -main \ No newline at end of file diff --git a/build/psake/psake-config.ps1 b/build/psake/psake-config.ps1 deleted file mode 100644 index 5458701..0000000 --- a/build/psake/psake-config.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -<# -------------------------------------------------------------------- -Defaults -------------------------------------------------------------------- -$config.buildFileName="default.ps1" -$config.framework = "4.0" -$config.taskNameFormat="Executing {0}" -$config.verboseError=$false -$config.coloredOutput = $true -$config.modules=$null - -------------------------------------------------------------------- -Load modules from .\modules folder and from file my_module.psm1 -------------------------------------------------------------------- -$config.modules=(".\modules\*.psm1",".\my_module.psm1") - -------------------------------------------------------------------- -Use scriptblock for taskNameFormat -------------------------------------------------------------------- -$config.taskNameFormat= { param($taskName) "Executing $taskName at $(get-date)" } -#> diff --git a/build/psake/psake.cmd b/build/psake/psake.cmd deleted file mode 100644 index f1aadc4..0000000 --- a/build/psake/psake.cmd +++ /dev/null @@ -1,14 +0,0 @@ -@echo off -rem Helper script for those who want to run psake from cmd.exe -rem Example run from cmd.exe: -rem psake "default.ps1" "BuildHelloWord" "4.0" - -if '%1'=='/?' goto help -if '%1'=='-help' goto help -if '%1'=='-h' goto help - -powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\psake.ps1' %*; if ($psake.build_success -eq $false) { exit 1 } else { exit 0 }" -exit /B %errorlevel% - -:help -powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\psake.ps1' -help" diff --git a/build/psake/psake.ps1 b/build/psake/psake.ps1 deleted file mode 100644 index 23c6f2d..0000000 --- a/build/psake/psake.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -# Helper script for those who want to run psake without importing the module. -# Example run from PowerShell: -# .\psake.ps1 "default.ps1" "BuildHelloWord" "4.0" - -# Must match parameter definitions for psake.psm1/invoke-psake -# otherwise named parameter binding fails -param( - [Parameter(Position=0,Mandatory=0)] - [string]$buildFile, - [Parameter(Position=1,Mandatory=0)] - [string[]]$taskList = @(), - [Parameter(Position=2,Mandatory=0)] - [string]$framework, - [Parameter(Position=3,Mandatory=0)] - [switch]$docs = $false, - [Parameter(Position=4,Mandatory=0)] - [System.Collections.Hashtable]$parameters = @{}, - [Parameter(Position=5, Mandatory=0)] - [System.Collections.Hashtable]$properties = @{}, - [Parameter(Position=6, Mandatory=0)] - [alias("init")] - [scriptblock]$initialization = {}, - [Parameter(Position=7, Mandatory=0)] - [switch]$nologo = $false, - [Parameter(Position=8, Mandatory=0)] - [switch]$help = $false, - [Parameter(Position=9, Mandatory=0)] - [string]$scriptPath, - [Parameter(Position=10,Mandatory=0)] - [switch]$detailedDocs = $false -) - -# setting $scriptPath here, not as default argument, to support calling as "powershell -File psake.ps1" -if (!$scriptPath) { - $scriptPath = $(Split-Path -parent $MyInvocation.MyCommand.path) -} - -# '[p]sake' is the same as 'psake' but $Error is not polluted -remove-module [p]sake -import-module (join-path $scriptPath psake.psm1) -if ($help) { - Get-Help Invoke-psake -full - return -} - -if ($buildFile -and (-not(test-path $buildFile))) { - $absoluteBuildFile = (join-path $scriptPath $buildFile) - if (test-path $absoluteBuildFile) { - $buildFile = $absoluteBuildFile - } -} - -Invoke-psake $buildFile $taskList $framework $docs $parameters $properties $initialization $nologo $detailedDocs diff --git a/build/psake/psake.psd1 b/build/psake/psake.psd1 deleted file mode 100644 index 3d01672..0000000 --- a/build/psake/psake.psd1 +++ /dev/null @@ -1,31 +0,0 @@ -@{ - ModuleToProcess = 'psake.psm1' - ModuleVersion = '4.6.0' - GUID = 'cfb53216-072f-4a46-8975-ff7e6bda05a5' - Author = 'James Kovacs' - Copyright = 'Copyright (c) 2012-16 James Kovacs, Damian Hickey and Contributors' - PowerShellVersion = '2.0' - Description = 'psake is a build automation tool written in PowerShell.' - FunctionsToExport = @('Invoke-psake', - 'Invoke-Task', - 'Get-PSakeScriptTasks', - 'Task', - 'Properties', - 'Include', - 'FormatTaskName', - 'TaskSetup', - 'TaskTearDown', - 'Framework', - 'Assert', - 'Exec') - VariablesToExport = 'psake' - - PrivateData = @{ - PSData = @{ - LicenseUri = 'https://github.com/psake/psake/blob/master/license.txt' - ProjectUri = 'https://github.com/psake/psake' - Tags = @('Build', 'Task') - IconUri = 'https://raw.githubusercontent.com/psake/graphics/master/png/psake-single-icon-teal-bg-256x256.png' - } - } -} diff --git a/build/psake/psake.psm1 b/build/psake/psake.psm1 deleted file mode 100644 index e5f8f3c..0000000 --- a/build/psake/psake.psm1 +++ /dev/null @@ -1,925 +0,0 @@ -# psake -# Copyright (c) 2012 James Kovacs -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -#Requires -Version 2.0 - -if ($PSVersionTable.PSVersion.Major -ge 3) -{ - $script:IgnoreError = 'Ignore' -} -else -{ - $script:IgnoreError = 'SilentlyContinue' -} - -#-- Public Module Functions --# - -# .ExternalHelp psake.psm1-help.xml -function Invoke-Task -{ - [CmdletBinding()] - param( - [Parameter(Position=0,Mandatory=1)] [string]$taskName - ) - - Assert $taskName ($msgs.error_invalid_task_name) - - $taskKey = $taskName.ToLower() - - if ($currentContext.aliases.Contains($taskKey)) { - $taskName = $currentContext.aliases.$taskKey.Name - $taskKey = $taskName.ToLower() - } - - $currentContext = $psake.context.Peek() - - Assert ($currentContext.tasks.Contains($taskKey)) ($msgs.error_task_name_does_not_exist -f $taskName) - - if ($currentContext.executedTasks.Contains($taskKey)) { return } - - Assert (!$currentContext.callStack.Contains($taskKey)) ($msgs.error_circular_reference -f $taskName) - - $currentContext.callStack.Push($taskKey) - - $task = $currentContext.tasks.$taskKey - - $precondition_is_valid = & $task.Precondition - - if (!$precondition_is_valid) { - WriteColoredOutput ($msgs.precondition_was_false -f $taskName) -foregroundcolor Cyan - } else { - if ($taskKey -ne 'default') { - - if ($task.PreAction -or $task.PostAction) { - Assert ($task.Action -ne $null) ($msgs.error_missing_action_parameter -f $taskName) - } - - if ($task.Action) { - try { - foreach($childTask in $task.DependsOn) { - Invoke-Task $childTask - } - - $stopwatch = [System.Diagnostics.Stopwatch]::StartNew() - $currentContext.currentTaskName = $taskName - - & $currentContext.taskSetupScriptBlock - - if ($task.PreAction) { - & $task.PreAction - } - - if ($currentContext.config.taskNameFormat -is [ScriptBlock]) { - & $currentContext.config.taskNameFormat $taskName - } else { - WriteColoredOutput ($currentContext.config.taskNameFormat -f $taskName) -foregroundcolor Cyan - } - - foreach ($variable in $task.requiredVariables) { - Assert ((test-path "variable:$variable") -and ((get-variable $variable).Value -ne $null)) ($msgs.required_variable_not_set -f $variable, $taskName) - } - - & $task.Action - - if ($task.PostAction) { - & $task.PostAction - } - - & $currentContext.taskTearDownScriptBlock - $task.Duration = $stopwatch.Elapsed - } catch { - if ($task.ContinueOnError) { - "-"*70 - WriteColoredOutput ($msgs.continue_on_error -f $taskName,$_) -foregroundcolor Yellow - "-"*70 - $task.Duration = $stopwatch.Elapsed - } else { - throw $_ - } - } - } else { - # no action was specified but we still execute all the dependencies - foreach($childTask in $task.DependsOn) { - Invoke-Task $childTask - } - } - } else { - foreach($childTask in $task.DependsOn) { - Invoke-Task $childTask - } - } - - Assert (& $task.Postcondition) ($msgs.postcondition_failed -f $taskName) - } - - $poppedTaskKey = $currentContext.callStack.Pop() - Assert ($poppedTaskKey -eq $taskKey) ($msgs.error_corrupt_callstack -f $taskKey,$poppedTaskKey) - - $currentContext.executedTasks.Push($taskKey) -} - -# .ExternalHelp psake.psm1-help.xml -function Exec -{ - [CmdletBinding()] - param( - [Parameter(Position=0,Mandatory=1)][scriptblock]$cmd, - [Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd), - [Parameter(Position=2,Mandatory=0)][int]$maxRetries = 0, - [Parameter(Position=3,Mandatory=0)][string]$retryTriggerErrorPattern = $null - ) - - $tryCount = 1 - - do { - try { - $global:lastexitcode = 0 - & $cmd - if ($lastexitcode -ne 0) { - throw ("Exec: " + $errorMessage) - } - break - } - catch [Exception] - { - if ($tryCount -gt $maxRetries) { - throw $_ - } - - if ($retryTriggerErrorPattern -ne $null) { - $isMatch = [regex]::IsMatch($_.Exception.Message, $retryTriggerErrorPattern) - - if ($isMatch -eq $false) { - throw $_ - } - } - - Write-Host "Try $tryCount failed, retrying again in 1 second..." - - $tryCount++ - - [System.Threading.Thread]::Sleep([System.TimeSpan]::FromSeconds(1)) - } - } - while ($true) -} - -# .ExternalHelp psake.psm1-help.xml -function Assert -{ - [CmdletBinding()] - param( - [Parameter(Position=0,Mandatory=1)]$conditionToCheck, - [Parameter(Position=1,Mandatory=1)]$failureMessage - ) - if (!$conditionToCheck) { - throw ("Assert: " + $failureMessage) - } -} - -# .ExternalHelp psake.psm1-help.xml -function Task -{ - [CmdletBinding()] - param( - [Parameter(Position=0,Mandatory=1)][string]$name = $null, - [Parameter(Position=1,Mandatory=0)][scriptblock]$action = $null, - [Parameter(Position=2,Mandatory=0)][scriptblock]$preaction = $null, - [Parameter(Position=3,Mandatory=0)][scriptblock]$postaction = $null, - [Parameter(Position=4,Mandatory=0)][scriptblock]$precondition = {$true}, - [Parameter(Position=5,Mandatory=0)][scriptblock]$postcondition = {$true}, - [Parameter(Position=6,Mandatory=0)][switch]$continueOnError = $false, - [Parameter(Position=7,Mandatory=0)][string[]]$depends = @(), - [Parameter(Position=8,Mandatory=0)][string[]]$requiredVariables = @(), - [Parameter(Position=9,Mandatory=0)][string]$description = $null, - [Parameter(Position=10,Mandatory=0)][string]$alias = $null - ) - if ($name -eq 'default') { - Assert (!$action) ($msgs.error_default_task_cannot_have_action) - } - - $newTask = @{ - Name = $name - DependsOn = $depends - PreAction = $preaction - Action = $action - PostAction = $postaction - Precondition = $precondition - Postcondition = $postcondition - ContinueOnError = $continueOnError - Description = $description - Duration = [System.TimeSpan]::Zero - RequiredVariables = $requiredVariables - Alias = $alias - } - - $taskKey = $name.ToLower() - - $currentContext = $psake.context.Peek() - - Assert (!$currentContext.tasks.ContainsKey($taskKey)) ($msgs.error_duplicate_task_name -f $name) - - $currentContext.tasks.$taskKey = $newTask - - if($alias) - { - $aliasKey = $alias.ToLower() - - Assert (!$currentContext.aliases.ContainsKey($aliasKey)) ($msgs.error_duplicate_alias_name -f $alias) - - $currentContext.aliases.$aliasKey = $newTask - } -} - -# .ExternalHelp psake.psm1-help.xml -function Properties { - [CmdletBinding()] - param( - [Parameter(Position=0,Mandatory=1)][scriptblock]$properties - ) - $psake.context.Peek().properties += $properties -} - -# .ExternalHelp psake.psm1-help.xml -function Include { - [CmdletBinding()] - param( - [Parameter(Position=0,Mandatory=1)][string]$fileNamePathToInclude - ) - Assert (test-path $fileNamePathToInclude -pathType Leaf) ($msgs.error_invalid_include_path -f $fileNamePathToInclude) - $psake.context.Peek().includes.Enqueue((Resolve-Path $fileNamePathToInclude)); -} - -# .ExternalHelp psake.psm1-help.xml -function FormatTaskName { - [CmdletBinding()] - param( - [Parameter(Position=0,Mandatory=1)]$format - ) - $psake.context.Peek().config.taskNameFormat = $format -} - -# .ExternalHelp psake.psm1-help.xml -function TaskSetup { - [CmdletBinding()] - param( - [Parameter(Position=0,Mandatory=1)][scriptblock]$setup - ) - $psake.context.Peek().taskSetupScriptBlock = $setup -} - -# .ExternalHelp psake.psm1-help.xml -function TaskTearDown { - [CmdletBinding()] - param( - [Parameter(Position=0,Mandatory=1)][scriptblock]$teardown - ) - $psake.context.Peek().taskTearDownScriptBlock = $teardown -} - -# .ExternalHelp psake.psm1-help.xml -function Framework { - [CmdletBinding()] - param( - [Parameter(Position=0,Mandatory=1)][string]$framework - ) - $psake.context.Peek().config.framework = $framework - ConfigureBuildEnvironment -} - -# .ExternalHelp psake.psm1-help.xml -function Get-PSakeScriptTasks { - [CmdletBinding()] - param( - [Parameter(Position = 0, Mandatory = 0)][string] $buildFile - ) - - if (!$buildFile) { - $buildFile = $psake.config_default.buildFileName - } - - try - { - ExecuteInBuildFileScope $buildFile $MyInvocation.MyCommand.Module { - param($currentContext, $module) - return GetTasksFromContext $currentContext - } - - } finally { - - CleanupEnvironment - } -} - -# .ExternalHelp psake.psm1-help.xml -function Invoke-psake { - [CmdletBinding()] - param( - [Parameter(Position = 0, Mandatory = 0)][string] $buildFile, - [Parameter(Position = 1, Mandatory = 0)][string[]] $taskList = @(), - [Parameter(Position = 2, Mandatory = 0)][string] $framework, - [Parameter(Position = 3, Mandatory = 0)][switch] $docs = $false, - [Parameter(Position = 4, Mandatory = 0)][hashtable] $parameters = @{}, - [Parameter(Position = 5, Mandatory = 0)][hashtable] $properties = @{}, - [Parameter(Position = 6, Mandatory = 0)][alias("init")][scriptblock] $initialization = {}, - [Parameter(Position = 7, Mandatory = 0)][switch] $nologo = $false, - [Parameter(Position = 8, Mandatory = 0)][switch] $detailedDocs = $false, - [Parameter(Position = 9, Mandatory = 0)][switch] $notr = $false # disable time report - ) - try { - if (-not $nologo) { - "psake version {0}`nCopyright (c) 2010-2014 James Kovacs & Contributors`n" -f $psake.version - } - - if (!$buildFile) { - $buildFile = $psake.config_default.buildFileName - } - elseif (!(test-path $buildFile -pathType Leaf) -and (test-path $psake.config_default.buildFileName -pathType Leaf)) { - # If the $config.buildFileName file exists and the given "buildfile" isn 't found assume that the given - # $buildFile is actually the target Tasks to execute in the $config.buildFileName script. - $taskList = $buildFile.Split(', ') - $buildFile = $psake.config_default.buildFileName - } - - ExecuteInBuildFileScope $buildFile $MyInvocation.MyCommand.Module { - param($currentContext, $module) - - $stopwatch = [System.Diagnostics.Stopwatch]::StartNew() - - if ($docs -or $detailedDocs) { - WriteDocumentation($detailedDocs) - return - } - - foreach ($key in $parameters.keys) { - if (test-path "variable:\$key") { - set-item -path "variable:\$key" -value $parameters.$key -WhatIf:$false -Confirm:$false | out-null - } else { - new-item -path "variable:\$key" -value $parameters.$key -WhatIf:$false -Confirm:$false | out-null - } - } - - # The initial dot (.) indicates that variables initialized/modified in the propertyBlock are available in the parent scope. - foreach ($propertyBlock in $currentContext.properties) { - . $propertyBlock - } - - foreach ($key in $properties.keys) { - if (test-path "variable:\$key") { - set-item -path "variable:\$key" -value $properties.$key -WhatIf:$false -Confirm:$false | out-null - } - } - - # Simple dot sourcing will not work. We have to force the script block into our - # module's scope in order to initialize variables properly. - . $module $initialization - - # Execute the list of tasks or the default task - if ($taskList) { - foreach ($task in $taskList) { - invoke-task $task - } - } elseif ($currentContext.tasks.default) { - invoke-task default - } else { - throw $msgs.error_no_default_task - } - - WriteColoredOutput ("`n" + $msgs.build_success + "`n") -foregroundcolor Green - - $stopwatch.Stop() - if (-not $notr) { - WriteTaskTimeSummary $stopwatch.Elapsed - } - } - - $psake.build_success = $true - - } catch { - $currentConfig = GetCurrentConfigurationOrDefault - if ($currentConfig.verboseError) { - $error_message = "{0}: An Error Occurred. See Error Details Below: `n" -f (Get-Date) - $error_message += ("-" * 70) + "`n" - $error_message += "Error: {0}`n" -f (ResolveError $_ -Short) - $error_message += ("-" * 70) + "`n" - $error_message += ResolveError $_ - $error_message += ("-" * 70) + "`n" - $error_message += "Script Variables" + "`n" - $error_message += ("-" * 70) + "`n" - $error_message += get-variable -scope script | format-table | out-string - } else { - # ($_ | Out-String) gets error messages with source information included. - $error_message = "Error: {0}: `n{1}" -f (Get-Date), (ResolveError $_ -Short) - } - - $psake.build_success = $false - - # if we are running in a nested scope (i.e. running a psake script from a psake script) then we need to re-throw the exception - # so that the parent script will fail otherwise the parent script will report a successful build - $inNestedScope = ($psake.context.count -gt 1) - if ( $inNestedScope ) { - throw $_ - } else { - if (!$psake.run_by_psake_build_tester) { - WriteColoredOutput $error_message -foregroundcolor Red - } - } - } finally { - CleanupEnvironment - } -} - -#-- Private Module Functions --# -function WriteColoredOutput { - param( - [string] $message, - [System.ConsoleColor] $foregroundcolor - ) - - $currentConfig = GetCurrentConfigurationOrDefault - if ($currentConfig.coloredOutput -eq $true) { - if (($Host.UI -ne $null) -and ($Host.UI.RawUI -ne $null) -and ($Host.UI.RawUI.ForegroundColor -ne $null)) { - $previousColor = $Host.UI.RawUI.ForegroundColor - $Host.UI.RawUI.ForegroundColor = $foregroundcolor - } - } - - $message - - if ($previousColor -ne $null) { - $Host.UI.RawUI.ForegroundColor = $previousColor - } -} - -function LoadModules { - $currentConfig = $psake.context.peek().config - if ($currentConfig.modules) { - - $scope = $currentConfig.moduleScope - - $global = [string]::Equals($scope, "global", [StringComparison]::CurrentCultureIgnoreCase) - - $currentConfig.modules | foreach { - resolve-path $_ | foreach { - "Loading module: $_" - $module = import-module $_ -passthru -DisableNameChecking -global:$global - if (!$module) { - throw ($msgs.error_loading_module -f $_.Name) - } - } - } - "" - } -} - -function LoadConfiguration { - param( - [string] $configdir = $PSScriptRoot - ) - - $psakeConfigFilePath = (join-path $configdir "psake-config.ps1") - - if (test-path $psakeConfigFilePath -pathType Leaf) { - try { - $config = GetCurrentConfigurationOrDefault - . $psakeConfigFilePath - } catch { - throw "Error Loading Configuration from psake-config.ps1: " + $_ - } - } -} - -function GetCurrentConfigurationOrDefault() { - if ($psake.context.count -gt 0) { - return $psake.context.peek().config - } else { - return $psake.config_default - } -} - -function CreateConfigurationForNewContext { - param( - [string] $buildFile, - [string] $framework - ) - - $previousConfig = GetCurrentConfigurationOrDefault - - $config = new-object psobject -property @{ - buildFileName = $previousConfig.buildFileName; - framework = $previousConfig.framework; - taskNameFormat = $previousConfig.taskNameFormat; - verboseError = $previousConfig.verboseError; - coloredOutput = $previousConfig.coloredOutput; - modules = $previousConfig.modules; - moduleScope = $previousConfig.moduleScope; - } - - if ($framework) { - $config.framework = $framework; - } - - if ($buildFile) { - $config.buildFileName = $buildFile; - } - - return $config -} - -function ConfigureBuildEnvironment { - $framework = $psake.context.peek().config.framework - if ($framework -cmatch '^((?:\d+\.\d+)(?:\.\d+){0,1})(x86|x64){0,1}$') { - $versionPart = $matches[1] - $bitnessPart = $matches[2] - } else { - throw ($msgs.error_invalid_framework -f $framework) - } - $versions = $null - $buildToolsVersions = $null - switch ($versionPart) { - '1.0' { - $versions = @('v1.0.3705') - } - '1.1' { - $versions = @('v1.1.4322') - } - '2.0' { - $versions = @('v2.0.50727') - } - '3.0' { - $versions = @('v2.0.50727') - } - '3.5' { - $versions = @('v3.5', 'v2.0.50727') - } - '4.0' { - $versions = @('v4.0.30319') - } - {($_ -eq '4.5.1') -or ($_ -eq '4.5.2')} { - $versions = @('v4.0.30319') - $buildToolsVersions = @('14.0', '12.0') - } - {($_ -eq '4.6') -or ($_ -eq '4.6.1')} { - $versions = @('v4.0.30319') - $buildToolsVersions = @('14.0') - } - - default { - throw ($msgs.error_unknown_framework -f $versionPart, $framework) - } - } - - $bitness = 'Framework' - if ($versionPart -ne '1.0' -and $versionPart -ne '1.1') { - switch ($bitnessPart) { - 'x86' { - $bitness = 'Framework' - $buildToolsKey = 'MSBuildToolsPath32' - } - 'x64' { - $bitness = 'Framework64' - $buildToolsKey = 'MSBuildToolsPath' - } - { [string]::IsNullOrEmpty($_) } { - $ptrSize = [System.IntPtr]::Size - switch ($ptrSize) { - 4 { - $bitness = 'Framework' - $buildToolsKey = 'MSBuildToolsPath32' - } - 8 { - $bitness = 'Framework64' - $buildToolsKey = 'MSBuildToolsPath' - } - default { - throw ($msgs.error_unknown_pointersize -f $ptrSize) - } - } - } - default { - throw ($msgs.error_unknown_bitnesspart -f $bitnessPart, $framework) - } - } - } - $frameworkDirs = @() - if ($buildToolsVersions -ne $null) { - foreach($ver in $buildToolsVersions) { - if (Test-Path "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$ver") { - $frameworkDirs += (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$ver" -Name $buildToolsKey).$buildToolsKey - } - } - } - $frameworkDirs = $frameworkDirs + @($versions | foreach { "$env:windir\Microsoft.NET\$bitness\$_\" }) - - for ($i = 0; $i -lt $frameworkDirs.Count; $i++) { - $dir = $frameworkDirs[$i] - if ($dir -Match "\$\(Registry:HKEY_LOCAL_MACHINE(.*?)@(.*)\)") { - $key = "HKLM:" + $matches[1] - $name = $matches[2] - $dir = (Get-ItemProperty -Path $key -Name $name).$name - $frameworkDirs[$i] = $dir - } - } - - $frameworkDirs | foreach { Assert (test-path $_ -pathType Container) ($msgs.error_no_framework_install_dir_found -f $_)} - - $env:path = ($frameworkDirs -join ";") + ";$env:path" - # if any error occurs in a PS function then "stop" processing immediately - # this does not effect any external programs that return a non-zero exit code - $global:ErrorActionPreference = "Stop" -} - -function ExecuteInBuildFileScope { - param([string]$buildFile, $module, [scriptblock]$sb) - - # Execute the build file to set up the tasks and defaults - Assert (test-path $buildFile -pathType Leaf) ($msgs.error_build_file_not_found -f $buildFile) - - $psake.build_script_file = get-item $buildFile - $psake.build_script_dir = $psake.build_script_file.DirectoryName - $psake.build_success = $false - - $psake.context.push(@{ - "taskSetupScriptBlock" = {}; - "taskTearDownScriptBlock" = {}; - "executedTasks" = new-object System.Collections.Stack; - "callStack" = new-object System.Collections.Stack; - "originalEnvPath" = $env:path; - "originalDirectory" = get-location; - "originalErrorActionPreference" = $global:ErrorActionPreference; - "tasks" = @{}; - "aliases" = @{}; - "properties" = @(); - "includes" = new-object System.Collections.Queue; - "config" = CreateConfigurationForNewContext $buildFile $framework - }) - - LoadConfiguration $psake.build_script_dir - - set-location $psake.build_script_dir - - LoadModules - - $frameworkOldValue = $framework - . $psake.build_script_file.FullName - - $currentContext = $psake.context.Peek() - - if ($framework -ne $frameworkOldValue) { - writecoloredoutput $msgs.warning_deprecated_framework_variable -foregroundcolor Yellow - $currentContext.config.framework = $framework - } - - ConfigureBuildEnvironment - - while ($currentContext.includes.Count -gt 0) { - $includeFilename = $currentContext.includes.Dequeue() - . $includeFilename - } - - & $sb $currentContext $module -} - -function CleanupEnvironment { - if ($psake.context.Count -gt 0) { - $currentContext = $psake.context.Peek() - $env:path = $currentContext.originalEnvPath - Set-Location $currentContext.originalDirectory - $global:ErrorActionPreference = $currentContext.originalErrorActionPreference - [void] $psake.context.Pop() - } -} - -function SelectObjectWithDefault -{ - [CmdletBinding()] - param( - [Parameter(ValueFromPipeline=$true)] - [PSObject] - $InputObject, - [string] - $Name, - $Value - ) - - process { - if ($_ -eq $null) { $Value } - elseif ($_ | Get-Member -Name $Name) { - $_.$Name - } - elseif (($_ -is [Hashtable]) -and ($_.Keys -contains $Name)) { - $_.$Name - } - else { $Value } - } -} - -# borrowed from Jeffrey Snover http://blogs.msdn.com/powershell/archive/2006/12/07/resolve-error.aspx -# modified to better handle SQL errors -function ResolveError -{ - [CmdletBinding()] - param( - [Parameter(ValueFromPipeline=$true)] - $ErrorRecord=$Error[0], - [Switch] - $Short - ) - - process { - if ($_ -eq $null) { $_ = $ErrorRecord } - $ex = $_.Exception - - if (-not $Short) { - $error_message = "`nErrorRecord:{0}ErrorRecord.InvocationInfo:{1}Exception:`n{2}" - $formatted_errorRecord = $_ | format-list * -force | out-string - $formatted_invocationInfo = $_.InvocationInfo | format-list * -force | out-string - $formatted_exception = '' - - $i = 0 - while ($ex -ne $null) { - $i++ - $formatted_exception += ("$i" * 70) + "`n" + - ($ex | format-list * -force | out-string) + "`n" - $ex = $ex | SelectObjectWithDefault -Name 'InnerException' -Value $null - } - - return $error_message -f $formatted_errorRecord, $formatted_invocationInfo, $formatted_exception - } - - $lastException = @() - while ($ex -ne $null) { - $lastMessage = $ex | SelectObjectWithDefault -Name 'Message' -Value '' - $lastException += ($lastMessage -replace "`n", '') - if ($ex -is [Data.SqlClient.SqlException]) { - $lastException += "(Line [$($ex.LineNumber)] " + - "Procedure [$($ex.Procedure)] Class [$($ex.Class)] " + - " Number [$($ex.Number)] State [$($ex.State)] )" - } - $ex = $ex | SelectObjectWithDefault -Name 'InnerException' -Value $null - } - $shortException = $lastException -join ' --> ' - - $header = $null - $current = $_ - $header = (($_.InvocationInfo | - SelectObjectWithDefault -Name 'PositionMessage' -Value '') -replace "`n", ' '), - ($_ | SelectObjectWithDefault -Name 'Message' -Value ''), - ($_ | SelectObjectWithDefault -Name 'Exception' -Value '') | - ? { -not [String]::IsNullOrEmpty($_) } | - Select -First 1 - - $delimiter = '' - if ((-not [String]::IsNullOrEmpty($header)) -and - (-not [String]::IsNullOrEmpty($shortException))) - { $delimiter = ' [<<==>>] ' } - - return "$($header)$($delimiter)Exception: $($shortException)" - } -} - -function GetTasksFromContext($currentContext) { - - $docs = $currentContext.tasks.Keys | foreach-object { - - $task = $currentContext.tasks.$_ - new-object PSObject -property @{ - Name = $task.Name; - Alias = $task.Alias; - Description = $task.Description; - DependsOn = $task.DependsOn; - } - } - - return $docs -} - -function WriteDocumentation($showDetailed) { - - $currentContext = $psake.context.Peek() - - if ($currentContext.tasks.default) { - $defaultTaskDependencies = $currentContext.tasks.default.DependsOn - } else { - $defaultTaskDependencies = @() - } - - $docs = GetTasksFromContext $currentContext | - Where {$_.Name -ne 'default'} | - ForEach { - $isDefault = $null - if ($defaultTaskDependencies -contains $_.Name) { - $isDefault = $true - } - return Add-Member -InputObject $_ 'Default' $isDefault -PassThru - } - - if ($showDetailed) { - $docs | sort 'Name' | format-list -property Name,Alias,Description,@{Label="Depends On";Expression={$_.DependsOn -join ', '}},Default - } else { - $docs | sort 'Name' | format-table -autoSize -wrap -property Name,Alias,@{Label="Depends On";Expression={$_.DependsOn -join ', '}},Default,Description - } -} - -function WriteTaskTimeSummary($invokePsakeDuration) { - if ($psake.context.count -gt 0) { - "-" * 70 - "Build Time Report" - "-" * 70 - $list = @() - $currentContext = $psake.context.Peek() - while ($currentContext.executedTasks.Count -gt 0) { - $taskKey = $currentContext.executedTasks.Pop() - $task = $currentContext.tasks.$taskKey - if ($taskKey -eq "default") { - continue - } - $list += new-object PSObject -property @{ - Name = $task.Name; - Duration = $task.Duration - } - } - [Array]::Reverse($list) - $list += new-object PSObject -property @{ - Name = "Total:"; - Duration = $invokePsakeDuration - } - # using "out-string | where-object" to filter out the blank line that format-table prepends - $list | format-table -autoSize -property Name,Duration | out-string -stream | where-object { $_ } - } -} - -DATA msgs { -convertfrom-stringdata @' - error_invalid_task_name = Task name should not be null or empty string. - error_task_name_does_not_exist = Task {0} does not exist. - error_circular_reference = Circular reference found for task {0}. - error_missing_action_parameter = Action parameter must be specified when using PreAction or PostAction parameters for task {0}. - error_corrupt_callstack = Call stack was corrupt. Expected {0}, but got {1}. - error_invalid_framework = Invalid .NET Framework version, {0} specified. - error_unknown_framework = Unknown .NET Framework version, {0} specified in {1}. - error_unknown_pointersize = Unknown pointer size ({0}) returned from System.IntPtr. - error_unknown_bitnesspart = Unknown .NET Framework bitness, {0}, specified in {1}. - error_no_framework_install_dir_found = No .NET Framework installation directory found at {0}. - error_bad_command = Error executing command {0}. - error_default_task_cannot_have_action = 'default' task cannot specify an action. - error_duplicate_task_name = Task {0} has already been defined. - error_duplicate_alias_name = Alias {0} has already been defined. - error_invalid_include_path = Unable to include {0}. File not found. - error_build_file_not_found = Could not find the build file {0}. - error_no_default_task = 'default' task required. - error_loading_module = Error loading module {0}. - warning_deprecated_framework_variable = Warning: Using global variable $framework to set .NET framework version used is deprecated. Instead use Framework function or configuration file psake-config.ps1. - required_variable_not_set = Variable {0} must be set to run task {1}. - postcondition_failed = Postcondition failed for task {0}. - precondition_was_false = Precondition was false, not executing task {0}. - continue_on_error = Error in task {0}. {1} - build_success = Build Succeeded! -'@ -} - -Import-LocalizedData -BindingVariable msgs -FileName messages.psd1 -ErrorAction $script:IgnoreError - -$scriptDir = Split-Path $MyInvocation.MyCommand.Path -$manifestPath = Join-Path $scriptDir psake.psd1 -$manifest = Test-ModuleManifest -Path $manifestPath -WarningAction SilentlyContinue - -$script:psake = @{} - -$psake.version = $manifest.Version.ToString() -$psake.context = new-object system.collections.stack # holds onto the current state of all variables -$psake.run_by_psake_build_tester = $false # indicates that build is being run by psake-BuildTester -$psake.config_default = new-object psobject -property @{ - buildFileName = "default.ps1"; - framework = "4.0"; - taskNameFormat = "Executing {0}"; - verboseError = $false; - coloredOutput = $true; - modules = $null; - moduleScope = ""; -} # contains default configuration, can be overriden in psake-config.ps1 in directory with psake.psm1 or in directory with current build script - -$psake.build_success = $false # indicates that the current build was successful -$psake.build_script_file = $null # contains a System.IO.FileInfo for the current build script -$psake.build_script_dir = "" # contains a string with fully-qualified path to current build script - -LoadConfiguration - -export-modulemember -function Invoke-psake, Invoke-Task, Get-PSakeScriptTasks, Task, Properties, Include, FormatTaskName, TaskSetup, TaskTearDown, Framework, Assert, Exec -variable psake diff --git a/build/psake/specs/Get-PSakeScriptTasks_should_pass.ps1 b/build/psake/specs/Get-PSakeScriptTasks_should_pass.ps1 deleted file mode 100644 index 4d1835d..0000000 --- a/build/psake/specs/Get-PSakeScriptTasks_should_pass.ps1 +++ /dev/null @@ -1,41 +0,0 @@ -Task default -depends CheckGetPSakeScriptTasks - -function Assert-EqualArrays($a, $b, $message) -{ - $differences = @(Compare-Object $a $b -SyncWindow 0) - if ($differences.Length -gt 0) - { - $differences - } - Assert ($differences.Length -eq 0) "$message : $($differences.Length) differences found." -} - -function Assert-TaskEqual($t1, $t2) -{ - Assert ($t1.Name -eq $t2.Name) "Task names do not match: $($t1.Name) vs $($t2.Name)" - Assert ($t1.Alias -eq $t2.Alias) "Task aliases do not match for task $($t1.Name): $($t1.Alias) vs $($t2.Alias)" - Assert ($t1.Description -eq $t2.Description) "Task descriptions do not match for task $($t1.Name): $($t1.Description) vs $($t2.Description)" - - Assert-EqualArrays $t1.DependsOn $t2.DependsOn "Task dependencies do not match for task $($t1.Name)" -} - -function HelloYou -{ - Write-Host 'Hello you' -} - -Task CheckGetPSakeScriptTasks { - - $tasks = Get-PSakeScriptTasks .\nested\docs.ps1 - $tasks = $tasks | sort -Property Name - - Assert ($tasks.Length -eq 7) 'Unexpected number of tasks.' - - Assert-TaskEqual $tasks[0] ([pscustomobject]@{Name = 'Compile'; Alias = ''; Description = ''; DependsOn = @('CompileSolutionA','CompileSolutionB');}) - Assert-TaskEqual $tasks[1] ([pscustomobject]@{Name = 'CompileSolutionA'; Alias = ''; Description = 'Compiles solution A'; DependsOn = @(); }) - Assert-TaskEqual $tasks[2] ([pscustomobject]@{Name = 'CompileSolutionB'; Alias = ''; Description = ''; DependsOn = @(); }) - Assert-TaskEqual $tasks[3] ([pscustomobject]@{Name = 'default'; Alias = ''; Description = ''; DependsOn = @('Compile','Test'); }) - Assert-TaskEqual $tasks[4] ([pscustomobject]@{Name = 'IntegrationTests'; Alias = ''; Description = ''; DependsOn = @(); }) - Assert-TaskEqual $tasks[5] ([pscustomobject]@{Name = 'Test'; Alias = ''; Description = ''; DependsOn = @('UnitTests','IntegrationTests'); }) - Assert-TaskEqual $tasks[6] ([pscustomobject]@{Name = 'UnitTests'; Alias = 'ut'; Description = ''; DependsOn = @(); }) -} diff --git a/build/psake/specs/bad_PreAndPostActions_should_fail.ps1 b/build/psake/specs/bad_PreAndPostActions_should_fail.ps1 deleted file mode 100644 index facdfb8..0000000 --- a/build/psake/specs/bad_PreAndPostActions_should_fail.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -task default -depends Test - -task Test -depends Compile, Clean -PreAction {"Pre-Test"} -PostAction {"Post-Test"} - -task Compile -depends Clean { - "Compile" -} - -task Clean { - "Clean" -} \ No newline at end of file diff --git a/build/psake/specs/calling_invoke-task_should_pass.ps1 b/build/psake/specs/calling_invoke-task_should_pass.ps1 deleted file mode 100644 index e986dfd..0000000 --- a/build/psake/specs/calling_invoke-task_should_pass.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -task default -depends A,B - -task A { -} - -task B { - "inside task B before calling task C" - invoke-task C - "inside task B after calling task C" -} - -task C { -} \ No newline at end of file diff --git a/build/psake/specs/circular_dependency_in_tasks_should_fail.ps1 b/build/psake/specs/circular_dependency_in_tasks_should_fail.ps1 deleted file mode 100644 index b23cefa..0000000 --- a/build/psake/specs/circular_dependency_in_tasks_should_fail.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -task default -depends A -task A -depends B { } -task B -depends A { } diff --git a/build/psake/specs/default_task_with_action_should_fail.ps1 b/build/psake/specs/default_task_with_action_should_fail.ps1 deleted file mode 100644 index 5d20507..0000000 --- a/build/psake/specs/default_task_with_action_should_fail.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -task default { - "Starting to do stuff..." - "Adding stuff... 1 + 1 =" + (1+1) - "Stuff done!" -} \ No newline at end of file diff --git a/build/psake/specs/detailedDocs_should_pass.ps1 b/build/psake/specs/detailedDocs_should_pass.ps1 deleted file mode 100644 index 73f0267..0000000 --- a/build/psake/specs/detailedDocs_should_pass.ps1 +++ /dev/null @@ -1,52 +0,0 @@ - -Task default -depends CheckDetailedDocs - -Task CheckDetailedDocs { - $doc = Invoke-psake .\nested\docs.ps1 -detailedDocs -nologo | Out-String - - $expectedDoc = @" - - -Name : Compile -Alias : -Description : -Depends On : CompileSolutionA, CompileSolutionB -Default : True - -Name : CompileSolutionA -Alias : -Description : Compiles solution A -Depends On : -Default : - -Name : CompileSolutionB -Alias : -Description : -Depends On : -Default : - -Name : IntegrationTests -Alias : -Description : -Depends On : -Default : - -Name : Test -Alias : -Description : -Depends On : UnitTests, IntegrationTests -Default : True - -Name : UnitTests -Alias : ut -Description : -Depends On : -Default : - - - - -"@ - Assert ($doc -eq $expectedDoc) "Unexpected simple doc: $doc" - -} diff --git a/build/psake/specs/docs_should_pass.ps1 b/build/psake/specs/docs_should_pass.ps1 deleted file mode 100644 index 40a0231..0000000 --- a/build/psake/specs/docs_should_pass.ps1 +++ /dev/null @@ -1,23 +0,0 @@ - -Task default -depends CheckDocs - -Task CheckDocs { - - $doc = Invoke-psake .\nested\docs.ps1 -docs -nologo | Out-String - - $expectedDoc = @" - -Name Alias Depends On Default Description ----- ----- ---------- ------- ----------- -Compile CompileSolutionA, CompileSolutionB True -CompileSolutionA Compiles solution A -CompileSolutionB -IntegrationTests -Test UnitTests, IntegrationTests True -UnitTests ut - - - -"@ - Assert ($doc -eq $expectedDoc) "Unexpected simple doc: $doc" -} diff --git a/build/psake/specs/dotNet4.5.1_should_pass.ps1 b/build/psake/specs/dotNet4.5.1_should_pass.ps1 deleted file mode 100644 index fc34b8d..0000000 --- a/build/psake/specs/dotNet4.5.1_should_pass.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -Framework "4.5.1x86" - -task default -depends MsBuild - -task MsBuild { - $output = &msbuild /version 2>&1 - Assert ($output -NotLike "12.0") '$output should contain 12.0' -} diff --git a/build/psake/specs/dotNet4.6.1_should_pass.ps1 b/build/psake/specs/dotNet4.6.1_should_pass.ps1 deleted file mode 100644 index 34de952..0000000 --- a/build/psake/specs/dotNet4.6.1_should_pass.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -Framework "4.6.1" - -task default -depends MsBuild - -task MsBuild { - $output = &msbuild /version 2>&1 - Assert ($output -NotLike "14.0") '$output should contain 14.0' -} diff --git a/build/psake/specs/dotNet4.6_should_pass.ps1 b/build/psake/specs/dotNet4.6_should_pass.ps1 deleted file mode 100644 index 0200532..0000000 --- a/build/psake/specs/dotNet4.6_should_pass.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -Framework "4.6" - -task default -depends MsBuild - -task MsBuild { - $output = &msbuild /version 2>&1 - Assert ($output -NotLike "14.0") '$output should contain 14.0' -} diff --git a/build/psake/specs/dotNet4_should_pass.ps1 b/build/psake/specs/dotNet4_should_pass.ps1 deleted file mode 100644 index 09e5a87..0000000 --- a/build/psake/specs/dotNet4_should_pass.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -Framework '4.0' - -task default -depends MsBuild - -task MsBuild { - exec { msbuild /version } -} diff --git a/build/psake/specs/duplicate_alias_should_fail.ps1 b/build/psake/specs/duplicate_alias_should_fail.ps1 deleted file mode 100644 index 00127f3..0000000 --- a/build/psake/specs/duplicate_alias_should_fail.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -task default -task A -alias a {} -task B -alias b {} -task C -alias a {} \ No newline at end of file diff --git a/build/psake/specs/duplicate_tasks_should_fail.ps1 b/build/psake/specs/duplicate_tasks_should_fail.ps1 deleted file mode 100644 index 246201f..0000000 --- a/build/psake/specs/duplicate_tasks_should_fail.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -task A {} -task B {} -task A {} \ No newline at end of file diff --git a/build/psake/specs/executing_module_function_that_depends_on_another_module_should_pass.ps1 b/build/psake/specs/executing_module_function_that_depends_on_another_module_should_pass.ps1 deleted file mode 100644 index 512b03f..0000000 --- a/build/psake/specs/executing_module_function_that_depends_on_another_module_should_pass.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -task default -depends test - -task test { - invoke-psake modules\default.ps1 -} \ No newline at end of file diff --git a/build/psake/specs/explicitly_specified_32bit_build_should_pass.ps1 b/build/psake/specs/explicitly_specified_32bit_build_should_pass.ps1 deleted file mode 100644 index 78e282e..0000000 --- a/build/psake/specs/explicitly_specified_32bit_build_should_pass.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -Framework '4.0x86' - -task default -depends MsBuild - -task MsBuild { - exec { msbuild /version } -} diff --git a/build/psake/specs/failing_postcondition_should_fail.ps1 b/build/psake/specs/failing_postcondition_should_fail.ps1 deleted file mode 100644 index 70f12f1..0000000 --- a/build/psake/specs/failing_postcondition_should_fail.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -task default -depends A,B,C - -task A { - "TaskA" -} - -task B -postcondition { return $false } { - "TaskB" -} - -task C { - "TaskC" -} \ No newline at end of file diff --git a/build/psake/specs/missing_task_should_fail.ps1 b/build/psake/specs/missing_task_should_fail.ps1 deleted file mode 100644 index 24c5c8d..0000000 --- a/build/psake/specs/missing_task_should_fail.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -task default -depends Test - -task Test -depends Compile, Clean { - Write-Host "Running PSake" -} diff --git a/build/psake/specs/modules/ModuleA.psm1 b/build/psake/specs/modules/ModuleA.psm1 deleted file mode 100644 index d731192..0000000 --- a/build/psake/specs/modules/ModuleA.psm1 +++ /dev/null @@ -1,5 +0,0 @@ -function Execute-ModuleAFunction { - Execute-ModuleBFunction -} - -Export-ModuleMember -Function "Execute-ModuleAFunction" \ No newline at end of file diff --git a/build/psake/specs/modules/ModuleB.psm1 b/build/psake/specs/modules/ModuleB.psm1 deleted file mode 100644 index a166615..0000000 --- a/build/psake/specs/modules/ModuleB.psm1 +++ /dev/null @@ -1,4 +0,0 @@ -function Execute-ModuleBFunction { -} - -Export-ModuleMember -Function "Execute-ModuleBFunction" \ No newline at end of file diff --git a/build/psake/specs/modules/default.ps1 b/build/psake/specs/modules/default.ps1 deleted file mode 100644 index 90c2ef7..0000000 --- a/build/psake/specs/modules/default.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -task default -depends test - -task test { - Execute-ModuleAFunction -} \ No newline at end of file diff --git a/build/psake/specs/modules/psake-config.ps1 b/build/psake/specs/modules/psake-config.ps1 deleted file mode 100644 index fd9b8df..0000000 --- a/build/psake/specs/modules/psake-config.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -$config.modules = @("ModuleA.psm1", "ModuleB.psm1") -$config.moduleScope = "global" \ No newline at end of file diff --git a/build/psake/specs/multiline_blocks_should_pass.ps1 b/build/psake/specs/multiline_blocks_should_pass.ps1 deleted file mode 100644 index 9ac8925..0000000 --- a/build/psake/specs/multiline_blocks_should_pass.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -task default -depends doStuff -task doStuff { - "Starting to do stuff..." - "Adding stuff... 1 + 1 =" + (1+1) - "Stuff done!" -} \ No newline at end of file diff --git a/build/psake/specs/nested/always_fail.ps1 b/build/psake/specs/nested/always_fail.ps1 deleted file mode 100644 index e8be8d8..0000000 --- a/build/psake/specs/nested/always_fail.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -Task default -Depends AlwaysFail - -Task AlwaysFail { - Assert $false "This should always fail." -} \ No newline at end of file diff --git a/build/psake/specs/nested/docs.ps1 b/build/psake/specs/nested/docs.ps1 deleted file mode 100644 index d10bf04..0000000 --- a/build/psake/specs/nested/docs.ps1 +++ /dev/null @@ -1,14 +0,0 @@ - -Task default -depends Compile,Test - -Task Compile -depends CompileSolutionA,CompileSolutionB - -Task Test -depends UnitTests,IntegrationTests - -Task CompileSolutionA -description 'Compiles solution A' {} - -Task CompileSolutionB {} - -Task UnitTests -alias 'ut' {} - -Task IntegrationTests {} diff --git a/build/psake/specs/nested/nested1.ps1 b/build/psake/specs/nested/nested1.ps1 deleted file mode 100644 index 81790ec..0000000 --- a/build/psake/specs/nested/nested1.ps1 +++ /dev/null @@ -1 +0,0 @@ -Properties { $x = 100 } Task default -Depends Nested1CheckX Task Nested1CheckX{ Assert ($x -eq 100) '$x was not 100' } \ No newline at end of file diff --git a/build/psake/specs/nested/nested2.ps1 b/build/psake/specs/nested/nested2.ps1 deleted file mode 100644 index 7a4a2b8..0000000 --- a/build/psake/specs/nested/nested2.ps1 +++ /dev/null @@ -1 +0,0 @@ -Properties { $x = 200 } Task default -Depends Nested2CheckX Task Nested2CheckX{ Assert ($x -eq 200) '$x was not 200' } \ No newline at end of file diff --git a/build/psake/specs/nested/whatifpreference.ps1 b/build/psake/specs/nested/whatifpreference.ps1 deleted file mode 100644 index 058522c..0000000 --- a/build/psake/specs/nested/whatifpreference.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -Task default -Depends WhatIfCheck - -Task WhatIfCheck { - Assert ($p1 -eq 'whatifcheck') '$p1 was not whatifcheck' -} diff --git a/build/psake/specs/nested_builds_should_pass.ps1 b/build/psake/specs/nested_builds_should_pass.ps1 deleted file mode 100644 index 36fc830..0000000 --- a/build/psake/specs/nested_builds_should_pass.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -Properties { - $x = 1 -} - -Task default -Depends RunNested1, RunNested2, CheckX - -Task RunNested1 { - Invoke-psake .\nested\nested1.ps1 -} - -Task RunNested2 { - Invoke-psake .\nested\nested2.ps1 -} - -Task CheckX{ - Assert ($x -eq 1) '$x was not 1' -} \ No newline at end of file diff --git a/build/psake/specs/nested_builds_that_fail_should_fail.ps1 b/build/psake/specs/nested_builds_that_fail_should_fail.ps1 deleted file mode 100644 index ec78fed..0000000 --- a/build/psake/specs/nested_builds_that_fail_should_fail.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -Task default -Depends RunAlwaysFail - -Task RunAlwaysFail { - Invoke-psake .\nested\always_fail.ps1 -} diff --git a/build/psake/specs/nonzero_lastexitcode_should_pass.ps1 b/build/psake/specs/nonzero_lastexitcode_should_pass.ps1 deleted file mode 100644 index 94582fa..0000000 --- a/build/psake/specs/nonzero_lastexitcode_should_pass.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -task default -depends MSBuildWithError - -task MSBuildWithError { - msbuild ThisFileDoesNotExist.sln -} \ No newline at end of file diff --git a/build/psake/specs/running_aspnet_compiler_under_dotNet35_should_pass.ps1 b/build/psake/specs/running_aspnet_compiler_under_dotNet35_should_pass.ps1 deleted file mode 100644 index 92d27f7..0000000 --- a/build/psake/specs/running_aspnet_compiler_under_dotNet35_should_pass.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -Framework '3.5' - -task default -depends AspNetCompiler - -task AspNetCompiler { - aspnet_compiler - if ($LastExitCode -ne 1) { - throw 'Error: Could not execute aspnet_compiler' - } - $global:LastExitCode = 0 -} diff --git a/build/psake/specs/simple_properties_and_tasks_should_pass.ps1 b/build/psake/specs/simple_properties_and_tasks_should_pass.ps1 deleted file mode 100644 index cd5d71f..0000000 --- a/build/psake/specs/simple_properties_and_tasks_should_pass.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -properties { - $testMessage = 'Executed Test!' - $compileMessage = 'Executed Compile!' - $cleanMessage = 'Executed Clean!' -} - -task default -depends Test - -task Test -depends Compile, Clean { - $testMessage -} - -task Compile -depends Clean { - $compileMessage -} - -task Clean { - $cleanMessage -} \ No newline at end of file diff --git a/build/psake/specs/task_with_alias_and_dependencies_should_pass.ps1 b/build/psake/specs/task_with_alias_and_dependencies_should_pass.ps1 deleted file mode 100644 index 4aca802..0000000 --- a/build/psake/specs/task_with_alias_and_dependencies_should_pass.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -task default -depends Task_With_Alias - -task Task_With_Alias -depends Task_Dependency -alias twa {} - -task Task_Dependency {} \ No newline at end of file diff --git a/build/psake/specs/task_with_alias_should_pass.ps1 b/build/psake/specs/task_with_alias_should_pass.ps1 deleted file mode 100644 index afec1c2..0000000 --- a/build/psake/specs/task_with_alias_should_pass.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -task default -depends twbdn - -task Task_With_Big_Descriptve_Name -alias twbdn { - "Doing stuff inside task with alias" -} diff --git a/build/psake/specs/tasksetup_should_pass.ps1 b/build/psake/specs/tasksetup_should_pass.ps1 deleted file mode 100644 index 46fb278..0000000 --- a/build/psake/specs/tasksetup_should_pass.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -TaskSetup { - "executing task setup" -} - -Task default -depends Compile, Test, Deploy - -Task Compile { - "Compiling" -} - -Task Test -depends Compile { - "Testing" -} - -Task Deploy -depends Test { - "Deploying" -} \ No newline at end of file diff --git a/build/psake/specs/using_PreAndPostActions_should_pass.ps1 b/build/psake/specs/using_PreAndPostActions_should_pass.ps1 deleted file mode 100644 index fcb36e6..0000000 --- a/build/psake/specs/using_PreAndPostActions_should_pass.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -task default -depends Test - -task Test -depends Compile, Clean -PreAction {"Pre-Test"} -Action { - "Test" -} -PostAction {"Post-Test"} - -task Compile -depends Clean { - "Compile" -} - -task Clean { - "Clean" -} \ No newline at end of file diff --git a/build/psake/specs/using_exec_and_nonzero_lastexitcode_should_fail.ps1 b/build/psake/specs/using_exec_and_nonzero_lastexitcode_should_fail.ps1 deleted file mode 100644 index 480b1db..0000000 --- a/build/psake/specs/using_exec_and_nonzero_lastexitcode_should_fail.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -task default -depends MSBuildWithError - -task MSBuildWithError { - exec { msbuild ThisFileDoesNotExist.sln } -} \ No newline at end of file diff --git a/build/psake/specs/using_framework_should_pass.ps1 b/build/psake/specs/using_framework_should_pass.ps1 deleted file mode 100644 index cb368a2..0000000 --- a/build/psake/specs/using_framework_should_pass.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -task default -depends FrameworkFunction - -task FrameworkFunction { - AssertFramework '2.0' - AssertFramework '3.5' - AssertFramework '4.0' -} - -function AssertFramework{ - param( - [string]$framework - ) - Framework $framework - $msBuildVersion = msbuild /version - Assert ($msBuildVersion[0].ToLower().StartsWith("microsoft (r) build engine version $framework")) '$msBuildVersion does not start with "$framework"' -} \ No newline at end of file diff --git a/build/psake/specs/using_initialization_block_should_pass.ps1 b/build/psake/specs/using_initialization_block_should_pass.ps1 deleted file mode 100644 index 4551571..0000000 --- a/build/psake/specs/using_initialization_block_should_pass.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -properties { - $container = @{} - $container.foo = "foo" - $container.bar = $null - $foo = 1 - $bar = 1 -} - -task default -depends TestInit - -task TestInit { - # values are: - # 1: original - # 2: overide - # 3: new - - Assert ($container.foo -eq "foo") "$container.foo should be foo" - Assert ($container.bar -eq "bar") "$container.bar should be bar" - Assert ($container.baz -eq "baz") "$container.baz should be baz" - Assert ($foo -eq 1) "$foo should be 1" - Assert ($bar -eq 2) "$bar should be 2" - Assert ($baz -eq 3) "$baz should be 3" -} \ No newline at end of file diff --git a/build/psake/specs/using_msbuild_should_pass.ps1 b/build/psake/specs/using_msbuild_should_pass.ps1 deleted file mode 100644 index 72fbc77..0000000 --- a/build/psake/specs/using_msbuild_should_pass.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -task default -depends DisplayNotice -task DisplayNotice { - exec { msbuild /version } -} \ No newline at end of file diff --git a/build/psake/specs/using_parameters_should_pass.ps1 b/build/psake/specs/using_parameters_should_pass.ps1 deleted file mode 100644 index 341b3cd..0000000 --- a/build/psake/specs/using_parameters_should_pass.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -properties { - $my_property = $p1 + $p2 -} - -task default -depends TestParams - -task TestParams { - Assert ($my_property -ne $null) '$my_property should not be null' -} \ No newline at end of file diff --git a/build/psake/specs/using_postcondition_should_pass.ps1 b/build/psake/specs/using_postcondition_should_pass.ps1 deleted file mode 100644 index 0173c5b..0000000 --- a/build/psake/specs/using_postcondition_should_pass.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -task default -depends A,B,C - -task A { - "TaskA" -} - -task B -postcondition { return $true } { - "TaskB" -} - -task C { - "TaskC" -} \ No newline at end of file diff --git a/build/psake/specs/using_precondition_should_pass.ps1 b/build/psake/specs/using_precondition_should_pass.ps1 deleted file mode 100644 index 8be98a6..0000000 --- a/build/psake/specs/using_precondition_should_pass.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -task default -depends A,B,C - -task A { - "TaskA" -} - -task B -precondition { return $false } { - "TaskB" -} - -task C -precondition { return $true } { - "TaskC" -} \ No newline at end of file diff --git a/build/psake/specs/using_properties_should_pass.ps1 b/build/psake/specs/using_properties_should_pass.ps1 deleted file mode 100644 index 64345ee..0000000 --- a/build/psake/specs/using_properties_should_pass.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -properties { - $x = $null - $y = $null - $z = $null -} - -task default -depends TestProperties - -task TestProperties { - Assert ($x -ne $null) "x should not be null" - Assert ($y -ne $null) "y should not be null" - Assert ($z -eq $null) "z should be null" -} \ No newline at end of file diff --git a/build/psake/specs/using_required_when_not_set_should_fail.ps1 b/build/psake/specs/using_required_when_not_set_should_fail.ps1 deleted file mode 100644 index 5e84946..0000000 --- a/build/psake/specs/using_required_when_not_set_should_fail.ps1 +++ /dev/null @@ -1,10 +0,0 @@ -properties { - $x = $null - $y = $null - $z = $null -} - -task default -depends TestProperties - -task TestProperties -requiredVariables z{ -} diff --git a/build/psake/specs/using_required_when_set_should_pass.ps1 b/build/psake/specs/using_required_when_set_should_pass.ps1 deleted file mode 100644 index 20b7ad3..0000000 --- a/build/psake/specs/using_required_when_set_should_pass.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -properties { - $x = $null - $y = $null -} - -task default -depends TestRequired - -task TestRequired -requiredVariables x, y { -} diff --git a/build/psake/specs/whatif_preference_should_pass.ps1 b/build/psake/specs/whatif_preference_should_pass.ps1 deleted file mode 100644 index 7d06399..0000000 --- a/build/psake/specs/whatif_preference_should_pass.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -Task default -Depends RunWhatIf - -Task RunWhatIf { - try { - ## Setup the -whatif flag globally - $global:WhatIfPreference = $true - - ## Ensure that psake ends up by calling something with -whatif e.g. Set-Item - $parameters = @{p1='whatifcheck';} - - Invoke-psake .\nested\whatifpreference.ps1 -parameters $parameters - } finally { - $global:WhatIfPreference = $false - } -} diff --git a/build/psake/specs/writing_psake_variables_should_pass.ps1 b/build/psake/specs/writing_psake_variables_should_pass.ps1 deleted file mode 100644 index 18d378a..0000000 --- a/build/psake/specs/writing_psake_variables_should_pass.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -properties { - $x = 1 -} - -task default -depends Verify - -task Verify -description "This task verifies psake's variables" { - - #Verify the exported module variables - cd variable: - Assert (Test-Path "psake") "variable psake was not exported from module" - - Assert ($psake.ContainsKey("build_success")) "'psake' variable does not contain key 'build_success'" - Assert ($psake.ContainsKey("version")) "'psake' variable does not contain key 'version'" - Assert ($psake.ContainsKey("build_script_file")) "'psake' variable does not contain key 'build_script_file'" - Assert ($psake.ContainsKey("build_script_dir")) "'psake' variable does not contain key 'build_script_dir'" - - Assert (!$psake.build_success) '$psake.build_success should be $false' - Assert ($psake.version) '$psake.version was null or empty' - Assert ($psake.build_script_file) '$psake.build_script_file was null' - Assert ($psake.build_script_file.Name -eq "writing_psake_variables_should_pass.ps1") '$psake.build_script_file.Name was not equal to "writing_psake_variables_should_pass.ps1"' - Assert ($psake.build_script_dir) '$psake.build_script_dir was null or empty' - - Assert ($psake.context.Count -eq 1) '$psake.context should have had a length of one (1) during script execution' - - $config = $psake.context.peek().config - Assert ($config) '$psake.config is $null' - Assert ((new-object "System.IO.FileInfo" $config.buildFileName).FullName -eq $psake.build_script_file.FullName) ('$psake.context.peek().config.buildFileName not equal to "{0}"' -f $psake.build_script_file.FullName) - Assert ($config.framework -eq "4.0") '$psake.context.peek().config.framework not equal to "4.0"' - Assert ($config.taskNameFormat -eq "Executing {0}") '$psake.context.peek().config.taskNameFormat not equal to "Executing {0}"' - Assert (!$config.verboseError) '$psake.context.peek().config.verboseError should be $false' - Assert ($config.coloredOutput) '$psake.context.peek().config.coloredOutput should be $false' - Assert ($config.modules -eq $null) '$psake.context.peek().config.modules is not $null' -} \ No newline at end of file diff --git a/build/psake/tabexpansion/PsakeTabExpansion.ps1 b/build/psake/tabexpansion/PsakeTabExpansion.ps1 deleted file mode 100644 index 5bd25bd..0000000 --- a/build/psake/tabexpansion/PsakeTabExpansion.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -$global:psakeSwitches = @('-docs', '-task', '-properties', '-parameters') - -function script:psakeSwitches($filter) { - $psakeSwitches | where { $_ -like "$filter*" } -} - -function script:psakeDocs($filter, $file) { - if ($file -eq $null -or $file -eq '') { $file = 'default.ps1' } - psake $file -docs | out-string -Stream |% { if ($_ -match "^[^ ]*") { $matches[0]} } |? { $_ -ne "Name" -and $_ -ne "----" -and $_ -like "$filter*" } -} - -function script:psakeFiles($filter) { - ls "$filter*.ps1" |% { $_.Name } -} - -function PsakeTabExpansion($lastBlock) { - switch -regex ($lastBlock) { - '(invoke-psake|psake) ([^\.]*\.ps1)? ?.* ?\-ta?s?k? (\S*)$' { # tasks only - psakeDocs $matches[3] $matches[2] | sort - } - '(invoke-psake|psake) ([^\.]*\.ps1)? ?.* ?(\-\S*)$' { # switches only - psakeSwitches $matches[3] | sort - } - '(invoke-psake|psake) ([^\.]*\.ps1) ?.* ?(\S*)$' { # switches or tasks - @(psakeDocs $matches[3] $matches[2]) + @(psakeSwitches $matches[3]) | sort - } - '(invoke-psake|psake) (\S*)$' { - @(psakeFiles $matches[2]) + @(psakeDocs $matches[2] 'default.ps1') + @(psakeSwitches $matches[2]) | sort - } - } -} diff --git a/build/psake/tabexpansion/Readme.PsakeTab.txt b/build/psake/tabexpansion/Readme.PsakeTab.txt deleted file mode 100644 index 09ff1d1..0000000 --- a/build/psake/tabexpansion/Readme.PsakeTab.txt +++ /dev/null @@ -1,39 +0,0 @@ -_________________________________________________________ -A powershell script for tab completion of psake module build commands - - tab completion for file name: psake d -> psake .\default.ps1 - - tab completion for parameters (docs,task,parameters,properties): psake -t -> psake -task - - tab completion for task: psake -t c -> psake -task Clean ---------------------------------------------------------- - -_________________________________________________________ -Profile example ---------------------------------------------------------- -Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent) -. ./PsakeTabExpansion.ps1 -Pop-Location - -if((Test-Path Function:\TabExpansion) -and (-not (Test-Path Function:\DefaultTabExpansion))) { - Rename-Item Function:\TabExpansion DefaultTabExpansion -} - -# Set up tab expansion and include psake expansion -function TabExpansion($line, $lastWord) { - $lastBlock = [regex]::Split($line, '[|;]')[-1] - - switch -regex ($lastBlock) { - # Execute psake tab completion for all psake-related commands - '(Invoke-psake|psake) (.*)' { PsakeTabExpansion $lastBlock } - # Fall back on existing tab expansion - default { DefaultTabExpansion $line $lastWord } - } -} ---------------------------------------------------------- - -_________________________________________________________ -Based on work by: - - - Keith Dahlby, http://solutionizing.net/ - - Mark Embling, http://www.markembling.info/ - - Jeremy Skinner, http://www.jeremyskinner.co.uk/ - - Dusty Candland, http://www.candland.net/blog ---------------------------------------------------------- diff --git a/default.ps1 b/default.ps1 deleted file mode 100644 index 4f2a7d7..0000000 --- a/default.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -properties { - $baseDir = resolve-path . - $buildDir = "$baseDir\build" - $sourceDir = "$baseDir\src" - $artifactsDir = "$baseDir\artifacts" - $global:config = "Debug" -} - -task default -depends local -task local -depends init, compile -task ci -depends clean, release, local - -task clean { - Remove-Item "$artifactsDir" -recurse -force -ErrorAction SilentlyContinue | Out-Null -} - -task init { - $isDotNetDownloaded = Test-Path dotnet-sdk.exe - - if($isDotNetDownloaded -eq $false) { - Write-Output 'Did not find dotnet-sdk.exe. Starting download.' - exec { curl -O dotnet-sdk.exe https://download.microsoft.com/download/0/F/D/0FD852A4-7EA1-4E2A-983A-0484AC19B92C/dotnet-sdk-2.0.0-win-x64.exe | Out-Default } - } else { - Write-Output 'Found dotnet-sdk.exe. Skipping download.' - } - - Write-Output 'Installing dotnet-sdk.exe.' - exec { .\dotnet-sdk.exe /install /quiet /norestart /log install.log | Out-Default } - exec { dotnet --version | Out-Default } -} - -task release { - $global:config = "Release" -} - -task compile -depends clean { - $projectPath = "$sourceDir\SteamWebAPI2\SteamWebAPI2.csproj" - - $version = if ($env:APPVEYOR_BUILD_NUMBER -ne $NULL) { $env:APPVEYOR_BUILD_NUMBER } else { '0' } - - exec { dotnet restore $projectPath } - exec { dotnet build $projectPath -c $config } - - if ($env:APPVEYOR_REPO_TAG -eq $true) { - exec { dotnet pack $projectPath -c $config -o $artifactsDir } - } - else { - exec { dotnet pack $projectPath -c $config -o $artifactsDir --version-suffix $version } - } -} \ No newline at end of file diff --git a/psake.bat b/psake.bat deleted file mode 100644 index 2270438..0000000 --- a/psake.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -cd %~dp0 - -SETLOCAL -powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "& {Import-Module '.\build\psake\psake.psm1'; invoke-psake .\default.ps1 %*; if ($lastexitcode -ne 0) {write-host "ERROR: $lastexitcode" -fore RED; exit $lastexitcode} }" \ No newline at end of file diff --git a/src/Steam.Models/AvailableGameStatsModel.cs b/src/Steam.Models/AvailableGameStatsModel.cs new file mode 100644 index 0000000..efd9eb4 --- /dev/null +++ b/src/Steam.Models/AvailableGameStatsModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models +{ + public class AvailableGameStatsModel + { + public IReadOnlyCollection Stats { get; set; } + + public IReadOnlyCollection Achievements { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/CSGO/GameMapsPlaytimeGameMode.cs b/src/Steam.Models/CSGO/GameMapsPlaytimeGameMode.cs new file mode 100644 index 0000000..156fec3 --- /dev/null +++ b/src/Steam.Models/CSGO/GameMapsPlaytimeGameMode.cs @@ -0,0 +1,8 @@ +namespace Steam.Models.CSGO +{ + public enum GameMapsPlaytimeGameMode + { + Competitive, + Casual + } +} \ No newline at end of file diff --git a/src/Steam.Models/CSGO/GameMapsPlaytimeInterval.cs b/src/Steam.Models/CSGO/GameMapsPlaytimeInterval.cs new file mode 100644 index 0000000..0d1c985 --- /dev/null +++ b/src/Steam.Models/CSGO/GameMapsPlaytimeInterval.cs @@ -0,0 +1,10 @@ + +namespace Steam.Models.CSGO +{ + public enum GameMapsPlaytimeInterval + { + Day, + Week, + Month + } +} \ No newline at end of file diff --git a/src/Steam.Models/CSGO/GameMapsPlaytimeMapGroup.cs b/src/Steam.Models/CSGO/GameMapsPlaytimeMapGroup.cs new file mode 100644 index 0000000..4ca8bd2 --- /dev/null +++ b/src/Steam.Models/CSGO/GameMapsPlaytimeMapGroup.cs @@ -0,0 +1,7 @@ +namespace Steam.Models.CSGO +{ + public enum GameMapsPlaytimeMapGroup + { + Operation + } +} \ No newline at end of file diff --git a/src/Steam.Models/CSGO/GameMapsPlaytimeModel.cs b/src/Steam.Models/CSGO/GameMapsPlaytimeModel.cs new file mode 100644 index 0000000..68c2e88 --- /dev/null +++ b/src/Steam.Models/CSGO/GameMapsPlaytimeModel.cs @@ -0,0 +1,11 @@ +using System; + +namespace Steam.Models.CSGO +{ + public class GameMapsPlaytimeModel + { + public DateTime IntervalStartTimeStamp { get; set; } + public string MapName { get; set; } + public float RelativePercentage { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/CSGO/ServerStatusAppModel.cs b/src/Steam.Models/CSGO/ServerStatusAppModel.cs new file mode 100644 index 0000000..5f25b32 --- /dev/null +++ b/src/Steam.Models/CSGO/ServerStatusAppModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.CSGO +{ + public class ServerStatusAppModel + { + public uint Version { get; set; } + public ulong Timestamp { get; set; } + public string Time { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/CSGO/ServerStatusDatacenterModel.cs b/src/Steam.Models/CSGO/ServerStatusDatacenterModel.cs new file mode 100644 index 0000000..e78365d --- /dev/null +++ b/src/Steam.Models/CSGO/ServerStatusDatacenterModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.CSGO +{ + public class ServerStatusDatacenterModel + { + public string Name { get; set; } + public string Capacity { get; set; } + public string Load { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/CSGO/ServerStatusMatchmakingModel.cs b/src/Steam.Models/CSGO/ServerStatusMatchmakingModel.cs new file mode 100644 index 0000000..b713253 --- /dev/null +++ b/src/Steam.Models/CSGO/ServerStatusMatchmakingModel.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.CSGO +{ + public class ServerStatusMatchmakingModel + { + public string Scheduler { get; set; } + + public uint OnlineServers { get; set; } + + public uint OnlinePlayers { get; set; } + + public uint SearchingPlayers { get; set; } + + public uint SearchSecondsAverage { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/CSGO/ServerStatusModel.cs b/src/Steam.Models/CSGO/ServerStatusModel.cs new file mode 100644 index 0000000..fbaf84f --- /dev/null +++ b/src/Steam.Models/CSGO/ServerStatusModel.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace Steam.Models.CSGO +{ + public class ServerStatusModel + { + public ServerStatusAppModel App { get; set; } + public ServerStatusServicesModel Services { get; set; } + public IReadOnlyCollection Datacenters { get; set; } + public ServerStatusMatchmakingModel Matchmaking { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/CSGO/ServerStatusServicesModel.cs b/src/Steam.Models/CSGO/ServerStatusServicesModel.cs new file mode 100644 index 0000000..eff9b6a --- /dev/null +++ b/src/Steam.Models/CSGO/ServerStatusServicesModel.cs @@ -0,0 +1,10 @@ +namespace Steam.Models.CSGO +{ + public class ServerStatusServicesModel + { + public string SessionsLogon { get; set; } + public string SteamCommunity { get; set; } + public string IEconItems { get; set; } + public string Leaderboards { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Cleaned/HeroAbilityDetail.cs b/src/Steam.Models/DOTA2/Cleaned/HeroAbilityDetail.cs new file mode 100644 index 0000000..6a47073 --- /dev/null +++ b/src/Steam.Models/DOTA2/Cleaned/HeroAbilityDetail.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Steam.Models.DOTA2 +{ + public class HeroAbilityDetail + { + public uint Id { get; set; } + public string Name { get; set; } + public string AvatarImagePath { get; set; } + public string Description { get; set; } + public IReadOnlyCollection AbilitySpecials { get; set; } + public string Behaviors { get; set; } + public string TeamTargets { get; set; } + public string TargetTypes { get; set; } + public string TargetFlags { get; set; } + public DotaSpellImmunityType SpellImmunityType { get; set; } + public DotaDamageType DamageType { get; set; } + public string CastRange { get; set; } + public string CastPoint { get; set; } + public string Cooldown { get; set; } + public string Duration { get; set; } + public string Damage { get; set; } + public string ManaCost { get; set; } + public DotaHeroAbilityType AbilityType { get; set; } + public string Note0 { get; set; } + public string Note1 { get; set; } + public string Note2 { get; set; } + public string Note3 { get; set; } + public string Note4 { get; set; } + public string Note5 { get; set; } + public string Note6 { get; set; } + public bool HasLinkedSpecialBonus + { + get + { + return AbilitySpecials.Any(x => !String.IsNullOrWhiteSpace(x.LinkedSpecialBonus)); + } + } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Cleaned/HeroAbilitySpecialDetail.cs b/src/Steam.Models/DOTA2/Cleaned/HeroAbilitySpecialDetail.cs new file mode 100644 index 0000000..4d84d41 --- /dev/null +++ b/src/Steam.Models/DOTA2/Cleaned/HeroAbilitySpecialDetail.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.DOTA2 +{ + public class HeroAbilitySpecialDetail + { + public string Name { get; set; } + + public string Value { get; set; } + + public string RawName { get; set; } + + public string LinkedSpecialBonus { get; set; } + + public bool RequiresScepter { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Cleaned/HeroDetail.cs b/src/Steam.Models/DOTA2/Cleaned/HeroDetail.cs new file mode 100644 index 0000000..f958b87 --- /dev/null +++ b/src/Steam.Models/DOTA2/Cleaned/HeroDetail.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class HeroDetail + { + private const int baseHealth = 150; + private const int healthPerStrength = 19; + private const int baseMana = 0; + private const int manaPerIntellect = 13; + private const double armorFactor = 0.14; + + public uint Id { get; set; } + public string Url { get; set; } + public string Name { get; set; } + public string NameInSchema { get; set; } + public string Description { get; set; } + public string AvatarImagePath { get; set; } + public uint BaseStrength { get; set; } + public uint BaseAgility { get; set; } + public uint BaseIntelligence { get; set; } + public uint BaseDamageMin { get; set; } + public uint BaseDamageMax { get; set; } + public uint BaseMoveSpeed { get; set; } + public double BaseArmor { get; set; } + public string Team { get; set; } + public double AttackRange { get; set; } + public double AttackRate { get; set; } + public double TurnRate { get; set; } + public string AttackType { get; set; } + public double StrengthGain { get; set; } + public double AgilityGain { get; set; } + public double IntelligenceGain { get; set; } + public DotaHeroPrimaryAttributeType PrimaryAttribute { get; set; } + public string ActiveTab { get; set; } + public string MinimapIconPath { get; set; } + public bool IsEnabled { get; set; } + + public IReadOnlyCollection Roles { get; set; } + public IReadOnlyCollection Abilities { get; set; } + + public double GetBaseHealth() + { + return GetHealth(0); + } + + public double GetBaseMana() + { + return GetMana(0); + } + + public double GetHealth(int level) + { + return Math.Round(baseHealth + (healthPerStrength * (BaseStrength + (level * StrengthGain)))); + } + + public double GetMana(int level) + { + return Math.Round(baseMana + (manaPerIntellect * (BaseIntelligence + (level * IntelligenceGain)))); + } + + public double GetMinDamage(int level) + { + if (PrimaryAttribute.Key == DotaHeroPrimaryAttributeType.STRENGTH.Key) + { + return Math.Round(BaseDamageMin + (BaseStrength + (level * StrengthGain))); + } + else if (PrimaryAttribute.Key == DotaHeroPrimaryAttributeType.INTELLECT.Key) + { + return Math.Round(BaseDamageMin + (BaseIntelligence + (level * IntelligenceGain))); + } + else if (PrimaryAttribute.Key == DotaHeroPrimaryAttributeType.AGILITY.Key) + { + return Math.Round(BaseDamageMin + (BaseAgility + (level * AgilityGain))); + } + else + { + return 0; + } + } + + public double GetMaxDamage(int level) + { + if (PrimaryAttribute.Key == DotaHeroPrimaryAttributeType.STRENGTH.Key) + { + return Math.Round(BaseDamageMax + (BaseStrength + (level * StrengthGain))); + } + else if (PrimaryAttribute.Key == DotaHeroPrimaryAttributeType.INTELLECT.Key) + { + return Math.Round(BaseDamageMax + (BaseIntelligence + (level * IntelligenceGain))); + } + else if (PrimaryAttribute.Key == DotaHeroPrimaryAttributeType.AGILITY.Key) + { + return Math.Round(BaseDamageMax + (BaseAgility + (level * AgilityGain))); + } + else + { + return 0; + } + } + + public double GetArmor(int level) + { + return BaseArmor + (GetAgility(level) * armorFactor); + } + + public double GetStrength(int level) + { + return Math.Round(BaseStrength + (level * StrengthGain)); + } + + public double GetAgility(int level) + { + return Math.Round(BaseAgility + (level * AgilityGain)); + } + + public double GetIntelligence(int level) + { + return Math.Round(BaseIntelligence + (level * IntelligenceGain)); + } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Cleaned/PlayerCountModel.cs b/src/Steam.Models/DOTA2/Cleaned/PlayerCountModel.cs new file mode 100644 index 0000000..9e74662 --- /dev/null +++ b/src/Steam.Models/DOTA2/Cleaned/PlayerCountModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.DOTA2 +{ + public class PlayerCountModel + { + public uint InGamePlayerCount { get; set; } + public uint DailyPeakPlayerCount { get; set; } + public uint AllTimePeakPlayerCount { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Cleaned/Rarity.cs b/src/Steam.Models/DOTA2/Cleaned/Rarity.cs new file mode 100644 index 0000000..1ff028b --- /dev/null +++ b/src/Steam.Models/DOTA2/Cleaned/Rarity.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.DOTA2 +{ + public class Rarity + { + public string Name { get; set; } + + public uint Id { get; set; } + + public uint Order { get; set; } + + public string Color { get; set; } + + public string LocalizedName { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaAttackType.cs b/src/Steam.Models/DOTA2/Enums/DotaAttackType.cs new file mode 100644 index 0000000..c10f015 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaAttackType.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaAttackType : DotaEnumType + { + public static readonly DotaAttackType UNKNOWN = new DotaAttackType("DOTA_UNIT_CAP_UNKNOWN", "Unknown", "This attack type is unknown."); + public static readonly DotaAttackType RANGED = new DotaAttackType("DOTA_UNIT_CAP_RANGED_ATTACK", "Ranged", "The attack can be performed from a distance."); + public static readonly DotaAttackType MELEE = new DotaAttackType("DOTA_UNIT_CAP_MELEE_ATTACK", "Melee", "The attack must be performed within arm's reach."); + + public DotaAttackType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaDamageType.cs b/src/Steam.Models/DOTA2/Enums/DotaDamageType.cs new file mode 100644 index 0000000..d6a1eed --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaDamageType.cs @@ -0,0 +1,14 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaDamageType : DotaEnumType + { + public static readonly DotaDamageType UNKNOWN = new DotaDamageType("DAMAGE_TYPE_UNKNOWN", "Unknown", "This damage type is unknown."); + public static readonly DotaDamageType PURE = new DotaDamageType("DAMAGE_TYPE_PURE", "Pure", "The damage dealt is not reduced by any resistance."); + public static readonly DotaDamageType PHYSICAL = new DotaDamageType("DAMAGE_TYPE_PHYSICAL", "Physical", "The damage dealth is reduced by armor."); + public static readonly DotaDamageType MAGICAL = new DotaDamageType("DAMAGE_TYPE_MAGICAL", "Magical", "The damage dealt is reduced by spell resistance."); + + public DotaDamageType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaEnumType.cs b/src/Steam.Models/DOTA2/Enums/DotaEnumType.cs new file mode 100644 index 0000000..fe22256 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaEnumType.cs @@ -0,0 +1,23 @@ +namespace Steam.Models.DOTA2 +{ + public abstract class DotaEnumType + { + protected readonly string key; + protected readonly string displayName; + protected readonly string description; + + public DotaEnumType(string key, string displayName, string description) + { + this.key = key; + this.displayName = displayName; + this.description = description; + } + + public string Key { get { return key; } } + + public override string ToString() + { + return displayName; + } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaHeroAbilityBehaviorType.cs b/src/Steam.Models/DOTA2/Enums/DotaHeroAbilityBehaviorType.cs new file mode 100644 index 0000000..b2889f0 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaHeroAbilityBehaviorType.cs @@ -0,0 +1,39 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaHeroAbilityBehaviorType : DotaEnumType + { + public static readonly DotaHeroAbilityBehaviorType UNKNOWN = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_UNKNOWN", "Unknown", "This behavior could not be found."); + public static readonly DotaHeroAbilityBehaviorType HIDDEN = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_HIDDEN", "Hidden", "This ability can be owned by a unit but can't be casted and wont show up on the HUD."); + public static readonly DotaHeroAbilityBehaviorType PASSIVE = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_PASSIVE", "Passive", "Can't be casted but shows up on the ability HUD."); + public static readonly DotaHeroAbilityBehaviorType NO_TARGET = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_NO_TARGET", "No Target", "Doesn't need a target to be cast, ability fires off as soon as the button is pressed."); + public static readonly DotaHeroAbilityBehaviorType UNIT_TARGET = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_UNIT_TARGET", "Unit Target", "Ability needs a target to be casted on."); + public static readonly DotaHeroAbilityBehaviorType POINT = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_POINT", "Cursor Target", "Ability can be cast anywhere the mouse cursor is (If a unit is clicked it will just be cast where the unit was standing)."); + public static readonly DotaHeroAbilityBehaviorType AOE = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_AOE", "Area of Effect", "This ability draws a radius where the ability will have effect. YOU STILL NEED A TARGETTING BEHAVIOR LIKE DOTA_ABILITY_BEHAVIOR_POINT FOR THIS TO WORK."); + public static readonly DotaHeroAbilityBehaviorType NOT_LEARNABLE = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_NOT_LEARNABLE", "Not Learnable", "This abillity is channelled. If the user moves or is silenced the ability is interrupted."); + public static readonly DotaHeroAbilityBehaviorType CHANNELLED = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_CHANNELLED", "Channelled", "This abillity is channelled. If the user moves or is silenced the ability is interrupted."); + public static readonly DotaHeroAbilityBehaviorType ITEM = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_ITEM", "On Item", "This ability is tied up to an item."); + public static readonly DotaHeroAbilityBehaviorType TOGGLE = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_TOGGLE", "Toggle", "This ability toggles on and off."); + public static readonly DotaHeroAbilityBehaviorType IMMEDIATE = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_IMMEDIATE", "Immediate", "This ability is casted immediately."); + public static readonly DotaHeroAbilityBehaviorType ROOT_DISABLES = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_ROOT_DISABLES", "Disables Roots", "This ability breaks the hero free of root effects."); + public static readonly DotaHeroAbilityBehaviorType DONT_RESUME_MOVEMENT = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_DONT_RESUME_MOVEMENT", "Stops Movement", "This ability stops the hero from moving in their direction when casted."); + public static readonly DotaHeroAbilityBehaviorType IGNORE_BACKSWING = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_IGNORE_BACKSWING", "Ignore Animations", "Causes the spell to ignore the backswing animation. It causes the visual animation to instantly stop once the cast point is reached."); + public static readonly DotaHeroAbilityBehaviorType DONT_RESUME_ATTACK = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_DONT_RESUME_ATTACK", "Stops Attacking", "This ability stops the hero from attacking their target after casting."); + public static readonly DotaHeroAbilityBehaviorType IGNORE_PSEUDO_QUEUE = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_IGNORE_PSEUDO_QUEUE", "Ignore Pseudo Queue", "Unknown."); + public static readonly DotaHeroAbilityBehaviorType AUTOCAST = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_AUTOCAST", "Autocast", "This ability can be set to autocast."); + public static readonly DotaHeroAbilityBehaviorType IGNORE_CHANNEL = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_IGNORE_CHANNEL", "Ignore Channel", "Unknown."); + public static readonly DotaHeroAbilityBehaviorType DIRECTIONAL = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_DIRECTIONAL", "Directional", "This ability has a directional component."); + public static readonly DotaHeroAbilityBehaviorType AURA = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_AURA", "Aura", "This ability has an aura effect."); + public static readonly DotaHeroAbilityBehaviorType NORMAL_WHEN_STOLEN = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_NORMAL_WHEN_STOLEN", "Normal When Stolen", "Unknown."); + public static readonly DotaHeroAbilityBehaviorType DONT_ALERT_TARGET = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_DONT_ALERT_TARGET", "Does Not Alert Target", "This ability will not be seen by the target through debuffs or other spell effects."); + public static readonly DotaHeroAbilityBehaviorType UNRESTRICTED = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_UNRESTRICTED", "Unrestricted", "Unknown."); + public static readonly DotaHeroAbilityBehaviorType RUNE_TARGET = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_RUNE_TARGET", "Rune Target", "Unknown."); + public static readonly DotaHeroAbilityBehaviorType DONT_CANCEL_MOVEMENT = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_DONT_CANCEL_MOVEMENT", "Does Not Cancel Movement", "This ability does not stop hero movement."); + public static readonly DotaHeroAbilityBehaviorType OPTIONAL_UNIT_TARGET = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_OPTIONAL_UNIT_TARGET", "Optional Unit Target", "Unknown."); + public static readonly DotaHeroAbilityBehaviorType SUPPRESS_ASSOCIATED_CONSUMABLE = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_SUPPRESS_ASSOCIATED_CONSUMABLE", "Suppress Associated Consumable", "Unknown."); + public static readonly DotaHeroAbilityBehaviorType SHOW_IN_GUIDES = new DotaHeroAbilityBehaviorType("DOTA_ABILITY_BEHAVIOR_SHOW_IN_GUIDES", "Show in Guides", "Unknown."); + + public DotaHeroAbilityBehaviorType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaHeroAbilityType.cs b/src/Steam.Models/DOTA2/Enums/DotaHeroAbilityType.cs new file mode 100644 index 0000000..33bf6db --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaHeroAbilityType.cs @@ -0,0 +1,14 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaHeroAbilityType : DotaEnumType + { + public static readonly DotaHeroAbilityType UNKNOWN = new DotaHeroAbilityType("DOTA_ABILITY_TYPE_UNKNOWN", "Unknown", "This is a an unknown ability type."); + public static readonly DotaHeroAbilityType BASIC = new DotaHeroAbilityType("DOTA_ABILITY_TYPE_BASIC", "Basic", "This is a basic ability learnable at any level."); + public static readonly DotaHeroAbilityType ULTIMATE = new DotaHeroAbilityType("DOTA_ABILITY_TYPE_ULTIMATE", "Ultimate", "This is a unique ultimate ability learnable at certain levels."); + public static readonly DotaHeroAbilityType TALENTS = new DotaHeroAbilityType("DOTA_ABILITY_TYPE_ATTRIBUTES", "Talent", "This is a talent selectable at levels 10, 15, 20, and 25. Previously known as an 'Attribute'."); + + public DotaHeroAbilityType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaHeroPrimaryAttributeType.cs b/src/Steam.Models/DOTA2/Enums/DotaHeroPrimaryAttributeType.cs new file mode 100644 index 0000000..d010244 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaHeroPrimaryAttributeType.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaHeroPrimaryAttributeType : DotaEnumType + { + public static readonly DotaHeroPrimaryAttributeType STRENGTH = new DotaHeroPrimaryAttributeType("DOTA_ATTRIBUTE_STRENGTH", "Strength", "Strength health and health regeneration."); + public static readonly DotaHeroPrimaryAttributeType AGILITY = new DotaHeroPrimaryAttributeType("DOTA_ATTRIBUTE_AGILITY", "Agility", "Agility increases armor."); + public static readonly DotaHeroPrimaryAttributeType INTELLECT = new DotaHeroPrimaryAttributeType("DOTA_ATTRIBUTE_INTELLECT", "Intellect", "Intellect increases mana and mana regeneration."); + + public DotaHeroPrimaryAttributeType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaItemDeclarationType.cs b/src/Steam.Models/DOTA2/Enums/DotaItemDeclarationType.cs new file mode 100644 index 0000000..d3dec3e --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaItemDeclarationType.cs @@ -0,0 +1,14 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaItemDeclarationType : DotaEnumType + { + public static readonly DotaItemDeclarationType UNKNOWN = new DotaItemDeclarationType("DECLARE_PURCHASES_UNKNOWN", "Unknown", "The declaration of this item is unknown."); + public static readonly DotaItemDeclarationType PURCHASES_TO_TEAMMATES = new DotaItemDeclarationType("DECLARE_PURCHASES_TO_TEAMMATES", "To Teammates", "Declare this item to teammates when purchased."); + public static readonly DotaItemDeclarationType PURCHASES_IN_SPEECH = new DotaItemDeclarationType("DECLARE_PURCHASES_IN_SPEECH", "In Speech", "Declare this item in speech when purchased."); + public static readonly DotaItemDeclarationType PURCHASES_TO_SPECTATORS = new DotaItemDeclarationType("DECLARE_PURCHASES_TO_SPECTATORS", "To Spectators", "Declare this item to spectators when purchased."); + + public DotaItemDeclarationType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaItemDisassembleType.cs b/src/Steam.Models/DOTA2/Enums/DotaItemDisassembleType.cs new file mode 100644 index 0000000..f903a8e --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaItemDisassembleType.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaItemDisassembleType : DotaEnumType + { + public static readonly DotaItemDisassembleType UNKNOWN = new DotaItemDisassembleType("DOTA_ITEM_DISASSEMBLE_UNKNOWN", "Unknown", "It is unknown if this item can be disassembled."); + public static readonly DotaItemDisassembleType NEVER = new DotaItemDisassembleType("DOTA_ITEM_DISASSEMBLE_NEVER", "Never", "This item can never be disassembled."); + public static readonly DotaItemDisassembleType ALWAYS = new DotaItemDisassembleType("DOTA_ITEM_DISASSEMBLE_ALWAYS", "Always", "This item can always be disassembled."); + + public DotaItemDisassembleType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaItemShareabilityType.cs b/src/Steam.Models/DOTA2/Enums/DotaItemShareabilityType.cs new file mode 100644 index 0000000..9615d58 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaItemShareabilityType.cs @@ -0,0 +1,14 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaItemShareabilityType : DotaEnumType + { + public static readonly DotaItemShareabilityType UNKNOWN = new DotaItemShareabilityType("ITEM_UNKNOWN_SHAREABLE", "Unknown", "The shareability of this item is unknown."); + public static readonly DotaItemShareabilityType PARTIALLY_SHAREABLE = new DotaItemShareabilityType("ITEM_PARTIALLY_SHAREABLE", "Partially", "This item is partially shareable."); + public static readonly DotaItemShareabilityType FULLY_SHAREABLE = new DotaItemShareabilityType("ITEM_FULLY_SHAREABLE", "Fully", "This item is fully shareable."); + public static readonly DotaItemShareabilityType FULLY_SHAREABLE_STACKING = new DotaItemShareabilityType("ITEM_FULLY_SHAREABLE_STACKING", "Fully (stacking)", "This item is fully shareable in stacking quantities."); + + public DotaItemShareabilityType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaLeagueTier.cs b/src/Steam.Models/DOTA2/Enums/DotaLeagueTier.cs new file mode 100644 index 0000000..565e688 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaLeagueTier.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.DOTA2 +{ + public enum DotaLeagueTier + { + Amateur = 1, + Professional, + Premier + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaSpellImmunityType.cs b/src/Steam.Models/DOTA2/Enums/DotaSpellImmunityType.cs new file mode 100644 index 0000000..0caabc4 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaSpellImmunityType.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaSpellImmunityType : DotaEnumType + { + public static readonly DotaSpellImmunityType UNKNOWN = new DotaSpellImmunityType("SPELL_IMMUNITY_UNKNOWN", "Unknown", "Spell immunity is unknown on this ability."); + public static readonly DotaSpellImmunityType ALLIES_YES = new DotaSpellImmunityType("SPELL_IMMUNITY_ALLIES_YES", "Allies", "This ability pierces spell immunity on allies."); + public static readonly DotaSpellImmunityType ALLIES_NO = new DotaSpellImmunityType("SPELL_IMMUNITY_ALLIES_NO", "Not Allies", "This ability does not pierce spell immunity on allies."); + public static readonly DotaSpellImmunityType ENEMIES_YES = new DotaSpellImmunityType("SPELL_IMMUNITY_ENEMIES_YES", "Enemies", "This ability pierces spell immunity on enemies."); + public static readonly DotaSpellImmunityType ENEMIES_NO = new DotaSpellImmunityType("SPELL_IMMUNITY_ENEMIES_NO", "Not Enemies", "This ability does not pierce spell immunity on enemies."); + + public DotaSpellImmunityType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaTeamType.cs b/src/Steam.Models/DOTA2/Enums/DotaTeamType.cs new file mode 100644 index 0000000..e4c792f --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaTeamType.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaTeamType : DotaEnumType + { + public static readonly DotaTeamType UNKNOWN = new DotaTeamType("Unknown", "Unknown", "This team is unknown."); + public static readonly DotaTeamType GOOD = new DotaTeamType("Good", "Radiant", "The 'good' team."); + public static readonly DotaTeamType BAD = new DotaTeamType("Bad", "Dire", "The 'bad' team."); + + public DotaTeamType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaUnitTargetFlag.cs b/src/Steam.Models/DOTA2/Enums/DotaUnitTargetFlag.cs new file mode 100644 index 0000000..b3e99b4 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaUnitTargetFlag.cs @@ -0,0 +1,17 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaUnitTargetFlag : DotaEnumType + { + public static readonly DotaUnitTargetFlag UNKNOWN = new DotaUnitTargetFlag("DOTA_UNIT_TARGET_FLAG_UNKNOWN", "Unknown", "This flag is an unknown type."); + public static readonly DotaUnitTargetFlag MAGIC_IMMUNE_ENEMIES = new DotaUnitTargetFlag("DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES", "Affects Magic Immune Enemies", "This ability affects magic immune enemies."); + public static readonly DotaUnitTargetFlag INVULNERABLE = new DotaUnitTargetFlag("DOTA_UNIT_TARGET_FLAG_INVULNERABLE", "Affects Invulnerable Units", "This ability affects invulernable targets."); + public static readonly DotaUnitTargetFlag NOT_MAGIC_IMMUNE_ALLIES = new DotaUnitTargetFlag("DOTA_UNIT_TARGET_FLAG_NOT_MAGIC_IMMUNE_ALLIES", "Does Not Affect Magic Immune Allies", "This ability does not affect magic immune allies."); + public static readonly DotaUnitTargetFlag NOT_ANCIENTS = new DotaUnitTargetFlag("DOTA_UNIT_TARGET_FLAG_NOT_ANCIENTS", "Does Not Affect Ancients", "This ability does not affect ancients."); + public static readonly DotaUnitTargetFlag NOT_SUMMONED = new DotaUnitTargetFlag("DOTA_UNIT_TARGET_FLAG_NOT_SUMMONED", "Does Not Affect Summoned", "This ability does not affect summoned targets."); + public static readonly DotaUnitTargetFlag NOT_CREEP_HERO = new DotaUnitTargetFlag("DOTA_UNIT_TARGET_FLAG_NOT_CREEP_HERO", "Does Not Affect Creeps or Heroes", "This ability does not affect creep or hero targets."); + + public DotaUnitTargetFlag(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaUnitTargetTeamType.cs b/src/Steam.Models/DOTA2/Enums/DotaUnitTargetTeamType.cs new file mode 100644 index 0000000..9b85ca6 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaUnitTargetTeamType.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaUnitTargetTeamType : DotaEnumType + { + public static readonly DotaUnitTargetTeamType UNKNOWN = new DotaUnitTargetTeamType("DOTA_UNIT_TARGET_TEAM_UNKNOWN", "Unknown", "This unit target type is unknown."); + public static readonly DotaUnitTargetTeamType ENEMY = new DotaUnitTargetTeamType("DOTA_UNIT_TARGET_TEAM_ENEMY", "Enemies", "The target of the ability must be an enemy."); + public static readonly DotaUnitTargetTeamType FRIENDLY = new DotaUnitTargetTeamType("DOTA_UNIT_TARGET_TEAM_FRIENDLY", "Friendlies", "The target of the ability must be a friendly."); + public static readonly DotaUnitTargetTeamType CUSTOM = new DotaUnitTargetTeamType("DOTA_UNIT_TARGET_TEAM_CUSTOM", "Custom", "The target of the ability is a custom type."); + public static readonly DotaUnitTargetTeamType BOTH = new DotaUnitTargetTeamType("DOTA_UNIT_TARGET_TEAM_BOTH", "Both", "The target of the ability can be both teams."); + + public DotaUnitTargetTeamType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/DotaUnitTargetType.cs b/src/Steam.Models/DOTA2/Enums/DotaUnitTargetType.cs new file mode 100644 index 0000000..b0b2bdf --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/DotaUnitTargetType.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.DOTA2 +{ + public sealed class DotaUnitTargetType : DotaEnumType + { + public static readonly DotaUnitTargetType UNKNOWN = new DotaUnitTargetType("DOTA_UNIT_TARGET_UNKNOWN", "Unknown", "This unit target type is unknown."); + public static readonly DotaUnitTargetType HERO = new DotaUnitTargetType("DOTA_UNIT_TARGET_HERO", "Hero", "The target of the ability can be a hero."); + public static readonly DotaUnitTargetType BASIC = new DotaUnitTargetType("DOTA_UNIT_TARGET_BASIC", "Basic", "The target of the ability can be any basic unit."); + public static readonly DotaUnitTargetType CUSTOM = new DotaUnitTargetType("DOTA_UNIT_TARGET_CUSTOM", "Custom", "The target of the ability is a custom type."); + public static readonly DotaUnitTargetType BUILDING = new DotaUnitTargetType("DOTA_UNIT_TARGET_BUILDING", "Building", "The target of the ability can be a building."); + + public DotaUnitTargetType(string key, string displayName, string description) + : base(key, displayName, description) + { } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/GameFile.cs b/src/Steam.Models/DOTA2/Enums/GameFile.cs new file mode 100644 index 0000000..03ea593 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/GameFile.cs @@ -0,0 +1,14 @@ +namespace Steam.Models.DOTA2 +{ + public enum GameFile + { + HeroAbilities, + ItemAbilities, + Heroes, + InGameItems, + MainSchema, + MainSchemaLocalization, + PublicLocalization, + PanoramaLocalization + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/Enums/SourceFileModel.cs b/src/Steam.Models/DOTA2/Enums/SourceFileModel.cs new file mode 100644 index 0000000..6888683 --- /dev/null +++ b/src/Steam.Models/DOTA2/Enums/SourceFileModel.cs @@ -0,0 +1,14 @@ +namespace Steam.Models.DOTA2 +{ + public enum SourceFileModel + { + HeroAbilities, + ItemAbilities, + Heroes, + InGameItems, + MainSchema, + MainSchemaLocalization, + PublicLocalization, + PanoramaLocalization + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/BarracksState.cs b/src/Steam.Models/DOTA2/External/BarracksState.cs new file mode 100644 index 0000000..a25224c --- /dev/null +++ b/src/Steam.Models/DOTA2/External/BarracksState.cs @@ -0,0 +1,26 @@ +namespace Steam.Models.DOTA2 +{ + public class BarracksState + { + public BarracksState() + { + } + + public BarracksState(uint barracksState) + { + IsTopMeleeAlive = ((barracksState >> 0) & 1) == 1 ? true : false; + IsTopRangedAlive = ((barracksState >> 1) & 1) == 1 ? true : false; + IsMiddleMeleeAlive = ((barracksState >> 2) & 1) == 1 ? true : false; + IsMiddleRangedAlive = ((barracksState >> 3) & 1) == 1 ? true : false; + IsBottomMeleeAlive = ((barracksState >> 4) & 1) == 1 ? true : false; + IsBottomRangedAlive = ((barracksState >> 5) & 1) == 1 ? true : false; + } + + public bool IsTopMeleeAlive { get; set; } + public bool IsTopRangedAlive { get; set; } + public bool IsMiddleMeleeAlive { get; set; } + public bool IsMiddleRangedAlive { get; set; } + public bool IsBottomMeleeAlive { get; set; } + public bool IsBottomRangedAlive { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/DotaBlogFeedItem.cs b/src/Steam.Models/DOTA2/External/DotaBlogFeedItem.cs new file mode 100644 index 0000000..0d2cc1a --- /dev/null +++ b/src/Steam.Models/DOTA2/External/DotaBlogFeedItem.cs @@ -0,0 +1,16 @@ +using System; + +namespace Steam.Models.DOTA2 +{ + public class DotaBlogFeedItem + { + public string Title { get; set; } + public string Link { get; set; } + public DateTime PublishDate { get; set; } + public string Author { get; set; } + public string Category { get; set; } + public string Description { get; set; } + public string ContentEncoded { get; set; } + public string ImageUrl { get; set; } + } +} diff --git a/src/Steam.Models/DOTA2/External/GameItem.cs b/src/Steam.Models/DOTA2/External/GameItem.cs new file mode 100644 index 0000000..65b5061 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/GameItem.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.DOTA2 +{ + public class GameItem + { + public uint Id { get; set; } + public uint Cost { get; set; } + public string Name { get; set; } + public string LocalizedName { get; set; } + public bool IsRecipe { get; set; } + public bool IsAvailableAtSecretShop { get; set; } + public bool IsAvailableAtSideShop { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/Hero.cs b/src/Steam.Models/DOTA2/External/Hero.cs new file mode 100644 index 0000000..ba90fa4 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/Hero.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.DOTA2 +{ + public class Hero + { + public uint Id { get; set; } + + public string Name { get; set; } + + public string LocalizedName { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/HeroAbility.cs b/src/Steam.Models/DOTA2/External/HeroAbility.cs new file mode 100644 index 0000000..37b5b9d --- /dev/null +++ b/src/Steam.Models/DOTA2/External/HeroAbility.cs @@ -0,0 +1,55 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class HeroAbility + { + public uint Id { get; set; } + + public string Name { get; set; } + + public string AbilityType { get; set; } + + public string AbilityBehavior { get; set; } + + public bool OnCastbar { get; set; } + + public bool OnLearnbar { get; set; } + + public string FightRecapLevel { get; set; } + + public string AbilityCastRange { get; set; } + + public uint AbilityRangeBuffer { get; set; } + + public string AbilityCastPoint { get; set; } + + public string AbilityChannelTime { get; set; } + + public string AbilityCooldown { get; set; } + + public string AbilityDuration { get; set; } + + public string AbilitySharedCooldown { get; set; } + + public string AbilityDamage { get; set; } + + public string AbilityManaCost { get; set; } + + public double AbilityModifierSupportValue { get; set; } + + public double AbilityModifierSupportBonus { get; set; } + + public string AbilityUnitTargetTeam { get; set; } + + public string AbilityUnitDamageType { get; set; } + + public string SpellImmunityType { get; set; } + + public string AbilityUnitTargetFlags { get; set; } + + public string AbilityUnitTargetType { get; set; } + + public IList AbilitySpecials { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/HeroAbilitySpecial.cs b/src/Steam.Models/DOTA2/External/HeroAbilitySpecial.cs new file mode 100644 index 0000000..63de01d --- /dev/null +++ b/src/Steam.Models/DOTA2/External/HeroAbilitySpecial.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.DOTA2 +{ + public class HeroAbilitySpecial + { + public string Name { get; set; } + + public string Value { get; set; } + + public string VarType { get; set; } + + public string LinkedSpecialBonus { get; set; } + + public bool RequiresScepter { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/HeroRole.cs b/src/Steam.Models/DOTA2/External/HeroRole.cs new file mode 100644 index 0000000..3ff7626 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/HeroRole.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.DOTA2 +{ + public class HeroRole + { + public string Name { get; set; } + + public string Level { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/HeroSchema.cs b/src/Steam.Models/DOTA2/External/HeroSchema.cs new file mode 100644 index 0000000..d1df40b --- /dev/null +++ b/src/Steam.Models/DOTA2/External/HeroSchema.cs @@ -0,0 +1,181 @@ +namespace Steam.Models.DOTA2 +{ + public class HeroSchema + { + public uint HeroId { get; set; } + + public string Name { get; set; } + + public string BaseClass { get; set; } + + public string Model { get; set; } + + public string SoundSet { get; set; } + + public bool Enabled { get; set; } + + public string Level { get; set; } + + public bool BotImplemented { get; set; } + + public string NewHero { get; set; } + + public string HeroPool1 { get; set; } + + public string HeroUnlockOrder { get; set; } + + public string CMEnabled { get; set; } + + public string CMTournamentIgnore { get; set; } + + public string NewPlayerEnable { get; set; } + + public string AbilityLayout { get; set; } + + public string Ability1 { get; set; } + + public string Ability2 { get; set; } + + public string Ability3 { get; set; } + + public string Ability4 { get; set; } + + public string Ability5 { get; set; } + + public string Ability6 { get; set; } + + public string Ability7 { get; set; } + + public string Ability8 { get; set; } + + public string Ability9 { get; set; } + + public string Ability10 { get; set; } + + public string Ability11 { get; set; } + + public string Ability12 { get; set; } + + public string Ability13 { get; set; } + + public string Ability14 { get; set; } + + public string Ability15 { get; set; } + + public string Ability16 { get; set; } + + public string Ability17 { get; set; } + + public string Ability18 { get; set; } + + public string Ability19 { get; set; } + + public string Ability20 { get; set; } + + public string Ability21 { get; set; } + + public string Ability22 { get; set; } + + public string Ability23 { get; set; } + + public string Ability24 { get; set; } + + public double ArmorPhysical { get; set; } + + public string MagicalResistance { get; set; } + + public string AttackCapabilities { get; set; } + + public uint AttackDamageMin { get; set; } + + public uint AttackDamageMax { get; set; } + + public string AttackDamageType { get; set; } + + public double AttackRate { get; set; } + + public double AttackAnimationPoint { get; set; } + + public uint AttackAcquisitionRange { get; set; } + + public uint AttackRange { get; set; } + + public string ProjectileModel { get; set; } + + public uint ProjectileSpeed { get; set; } + + public string AttributePrimary { get; set; } + + public uint AttributeBaseStrength { get; set; } + + public double AttributeStrengthGain { get; set; } + + public uint AttributeBaseIntelligence { get; set; } + + public double AttributeIntelligenceGain { get; set; } + + public uint AttributeBaseAgility { get; set; } + + public double AttributeAgilityGain { get; set; } + + public uint BountyXP { get; set; } + + public uint BountyGoldMin { get; set; } + + public uint BountyGoldMax { get; set; } + + public string BoundsHullName { get; set; } + + public uint RingRadius { get; set; } + + public string MovementCapabilities { get; set; } + + public uint MovementSpeed { get; set; } + + public double MovementTurnRate { get; set; } + + public bool HasAggressiveStance { get; set; } + + public uint StatusHealth { get; set; } + + public double StatusHealthRegen { get; set; } + + public uint StatusMana { get; set; } + + public double StatusManaRegen { get; set; } + + public string TeamName { get; set; } + + public string Team { get; set; } + + public string CombatClassAttack { get; set; } + + public string CombatClassDefend { get; set; } + + public string UnitRelationshipClass { get; set; } + + public uint VisionDaytimeRange { get; set; } + + public uint VisionNighttimeRange { get; set; } + + public bool HasInventory { get; set; } + + public string VoiceBackgroundSound { get; set; } + + public uint HealthBarOffset { get; set; } + + public string IdleExpression { get; set; } + + public string IdleSoundLoop { get; set; } + + public string AbilityDraftDisabled { get; set; } + + public string ARDMDisabled { get; set; } + + public string Url { get; set; } + + public string Role { get; set; } + + public string RoleLevels { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/ItemAbility.cs b/src/Steam.Models/DOTA2/External/ItemAbility.cs new file mode 100644 index 0000000..794d622 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/ItemAbility.cs @@ -0,0 +1,93 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class ItemAbility + { + public uint Id { get; set; } + + public string Name { get; set; } + + /// + /// Valve's source files don't include localized names. Instead, the callers are responsible for populating this value + /// by performing a lookup in the various language/token mapping files. + /// + public string LocalizedName { get; set; } + + public string AbilityBehavior { get; set; } + + public string AbilityCastRange { get; set; } + + public string AbilityCastPoint { get; set; } + + public string AbilityChannelTime { get; set; } + + public string AbilityCooldown { get; set; } + + public string AbilityDuration { get; set; } + + public string AbilitySharedCooldown { get; set; } + + public string AbilityDamage { get; set; } + + public string AbilityManaCost { get; set; } + + public double AbilityModifierSupportValue { get; set; } + + public string AbilityUnitTargetTeam { get; set; } + + public string AbilityUnitDamageType { get; set; } + + public string AbilityUnitTargetFlags { get; set; } + + public string AbilityUnitTargetType { get; set; } + + public IList AbilitySpecials { get; set; } + + public uint ItemCost { get; set; } + + public string ItemShopTags { get; set; } + + public string ItemQuality { get; set; } + + public bool ItemStackable { get; set; } + + public string ItemShareability { get; set; } + + public bool ItemPermanent { get; set; } + + public uint? ItemInitialCharges { get; set; } + + public uint? ItemDisplayCharges { get; set; } + + public uint? ItemStockMax { get; set; } + + public uint? ItemStockInitial { get; set; } + + public double? ItemStockTime { get; set; } + + public bool? ItemPurchasable { get; set; } + + public bool? ItemSellable { get; set; } + + public bool? ItemKillable { get; set; } + + public string ItemDeclarations { get; set; } + + public bool? ItemCastOnPickup { get; set; } + + public bool? ItemSupport { get; set; } + + public string ItemResult { get; set; } + + public bool? ItemAlertable { get; set; } + + public bool? ItemDroppable { get; set; } + + public bool? ItemContributesToNetWorthWhenDropped { get; set; } + + public string ItemDisassembleRule { get; set; } + + public bool? ItemIsNeutralDrop { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/ItemBuild.cs b/src/Steam.Models/DOTA2/External/ItemBuild.cs new file mode 100644 index 0000000..a3e02bb --- /dev/null +++ b/src/Steam.Models/DOTA2/External/ItemBuild.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class ItemBuild + { + public string Author { get; set; } + + public string Hero { get; set; } + + public string Title { get; set; } + + public IList Items { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/ItemBuildGroup.cs b/src/Steam.Models/DOTA2/External/ItemBuildGroup.cs new file mode 100644 index 0000000..bcf4cd0 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/ItemBuildGroup.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class ItemBuildGroup + { + public string Name { get; set; } + + public IList Items { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/Schema.cs b/src/Steam.Models/DOTA2/External/Schema.cs new file mode 100644 index 0000000..27d7023 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/Schema.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class Schema + { + public SchemaGameInfo GameInfo { get; set; } + + public IList Rarities { get; set; } + + public IList Qualities { get; set; } + + public IList Colors { get; set; } + + public IList Prefabs { get; set; } + + public IList Items { get; set; } + + public IList ItemSets { get; set; } + + public IList ItemAutographs { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaColor.cs b/src/Steam.Models/DOTA2/External/SchemaColor.cs new file mode 100644 index 0000000..1757058 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaColor.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.DOTA2 +{ + public class SchemaColor + { + public string Name { get; set; } + + public string ColorName { get; set; } + + public string HexColor { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaGameInfo.cs b/src/Steam.Models/DOTA2/External/SchemaGameInfo.cs new file mode 100644 index 0000000..ba19376 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaGameInfo.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.DOTA2 +{ + public class SchemaGameInfo + { + public string FirstValidClass { get; set; } + + public string LastValidClass { get; set; } + + public string FirstValidItemSlot { get; set; } + + public string LastValidItemSlot { get; set; } + + public string ItemPresetCount { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaItem.cs b/src/Steam.Models/DOTA2/External/SchemaItem.cs new file mode 100644 index 0000000..d0b67f5 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaItem.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class SchemaItem + { + public string DefIndex { get; set; } + + public string Name { get; set; } + + public string ImageInventoryPath { get; set; } + + public string ItemName { get; set; } + + public string ItemDescription { get; set; } + + public string ItemTypeName { get; set; } + + public string Prefab { get; set; } + + public DateTime? CreationDate { get; set; } + + public DateTime? ExpirationDate { get; set; } + + public SchemaItemTool Tool { get; set; } + + public string TournamentUrl { get; set; } + + public string ImageBannerPath { get; set; } + + public string ItemRarity { get; set; } + + public string ItemQuality { get; set; } + + public string ItemSlot { get; set; } + + public SchemaItemPriceInfo PriceInfo { get; set; } + + public IList UsedByHeroes { get; set; } + + public IList BundledItems { get; set; } + + public IList StaticAttributes { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaItemAutograph.cs b/src/Steam.Models/DOTA2/External/SchemaItemAutograph.cs new file mode 100644 index 0000000..28ec989 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaItemAutograph.cs @@ -0,0 +1,19 @@ +namespace Steam.Models.DOTA2 +{ + public class SchemaItemAutograph + { + public string DefIndex { get; set; } + + public string Name { get; set; } + + public string Autograph { get; set; } + + public ulong? WorkshopLink { get; set; } + + public uint Language { get; set; } + + public string IconPath { get; set; } + + public string Modifier { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaItemPriceInfo.cs b/src/Steam.Models/DOTA2/External/SchemaItemPriceInfo.cs new file mode 100644 index 0000000..7cac72c --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaItemPriceInfo.cs @@ -0,0 +1,19 @@ +using System; + +namespace Steam.Models.DOTA2 +{ + public class SchemaItemPriceInfo + { + public string Bucket { get; set; } + + public string Class { get; set; } + + public string CategoryTags { get; set; } + + public DateTime? Date { get; set; } + + public decimal? Price { get; set; } + + public bool? IsPackItem { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaItemSet.cs b/src/Steam.Models/DOTA2/External/SchemaItemSet.cs new file mode 100644 index 0000000..6cd5a51 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaItemSet.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class SchemaItemSet + { + public string RawName { get; set; } + + public string Name { get; set; } + + public string StoreBundleName { get; set; } + + public IList Items { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaItemStaticAttribute.cs b/src/Steam.Models/DOTA2/External/SchemaItemStaticAttribute.cs new file mode 100644 index 0000000..62931ae --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaItemStaticAttribute.cs @@ -0,0 +1,8 @@ +namespace Steam.Models.DOTA2 +{ + public class SchemaItemStaticAttribute + { + public string Class { get; set; } + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaItemTool.cs b/src/Steam.Models/DOTA2/External/SchemaItemTool.cs new file mode 100644 index 0000000..1fd8ed4 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaItemTool.cs @@ -0,0 +1,7 @@ +namespace Steam.Models.DOTA2 +{ + public class SchemaItemTool + { + public SchemaItemToolUsage Usage { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaItemToolUsage.cs b/src/Steam.Models/DOTA2/External/SchemaItemToolUsage.cs new file mode 100644 index 0000000..0cf8276 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaItemToolUsage.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.DOTA2 +{ + public class SchemaItemToolUsage + { + public uint LeagueId { get; set; } + + public string Tier { get; set; } + + public string Location { get; set; } + + public bool Admin { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaPrefab.cs b/src/Steam.Models/DOTA2/External/SchemaPrefab.cs new file mode 100644 index 0000000..4417c8d --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaPrefab.cs @@ -0,0 +1,29 @@ +namespace Steam.Models.DOTA2 +{ + public class SchemaPrefab + { + public string Type { get; set; } + + public string TypeName { get; set; } + + public string Class { get; set; } + + public string Name { get; set; } + + public string Slot { get; set; } + + public string Quality { get; set; } + + public string Rarity { get; set; } + + public string MinItemLevel { get; set; } + + public string MaxItemLevel { get; set; } + + public string ImageInventorySizeWidth { get; set; } + + public string ImageInventorySizeHeight { get; set; } + + public SchemaPrefabCapability Capabilities { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaPrefabCapability.cs b/src/Steam.Models/DOTA2/External/SchemaPrefabCapability.cs new file mode 100644 index 0000000..df2a863 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaPrefabCapability.cs @@ -0,0 +1,23 @@ +namespace Steam.Models.DOTA2 +{ + public class SchemaPrefabCapability + { + public bool Nameable { get; set; } + + public bool CanHaveSockets { get; set; } + + public bool GemsCanBeExtracted { get; set; } + + public bool CanGiftWrap { get; set; } + + public bool UsableGC { get; set; } + + public bool UsableOutOfGame { get; set; } + + public bool Decodable { get; set; } + + public bool Usable { get; set; } + + public bool IsGem { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaQuality.cs b/src/Steam.Models/DOTA2/External/SchemaQuality.cs new file mode 100644 index 0000000..7df97e1 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaQuality.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.DOTA2 +{ + public class SchemaQuality + { + public string Name { get; set; } + + public uint Value { get; set; } + + public string HexColor { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/SchemaRarity.cs b/src/Steam.Models/DOTA2/External/SchemaRarity.cs new file mode 100644 index 0000000..f3cb909 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/SchemaRarity.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.DOTA2 +{ + public class SchemaRarity + { + public string Name { get; set; } + + public uint Value { get; set; } + + public string LocKey { get; set; } + + public string Color { get; set; } + + public string NextRarity { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/TeamInfo.cs b/src/Steam.Models/DOTA2/External/TeamInfo.cs new file mode 100644 index 0000000..823986f --- /dev/null +++ b/src/Steam.Models/DOTA2/External/TeamInfo.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class TeamInfo + { + public uint TeamId { get; set; } + public string Name { get; set; } + public string Tag { get; set; } + public ulong TimeCreated { get; set; } + public string Rating { get; set; } + public ulong Logo { get; set; } + public ulong LogoSponsor { get; set; } + public string CountryCode { get; set; } + public string Url { get; set; } + public uint GamesPlayedWithCurrentRoster { get; set; } + public uint AdminAccountId { get; set; } + public IReadOnlyCollection PlayerIds { get; set; } + public IReadOnlyCollection LeagueIds { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/External/TowerState.cs b/src/Steam.Models/DOTA2/External/TowerState.cs new file mode 100644 index 0000000..e8efa26 --- /dev/null +++ b/src/Steam.Models/DOTA2/External/TowerState.cs @@ -0,0 +1,36 @@ +namespace Steam.Models.DOTA2 +{ + public class TowerState + { + public TowerState() + { + } + + public TowerState(uint towerState) + { + IsAncientBottomAlive = ((towerState >> 10) & 1) == 1 ? true : false; + IsAncientTopAlive = ((towerState >> 9) & 1) == 1 ? true : false; + IsBottomTier3Alive = ((towerState >> 8) & 1) == 1 ? true : false; + IsBottomTier2Alive = ((towerState >> 7) & 1) == 1 ? true : false; + IsBottomTier1Alive = ((towerState >> 6) & 1) == 1 ? true : false; + IsMiddleTier3Alive = ((towerState >> 5) & 1) == 1 ? true : false; + IsMiddleTier2Alive = ((towerState >> 4) & 1) == 1 ? true : false; + IsMiddleTier1Alive = ((towerState >> 3) & 1) == 1 ? true : false; + IsTopTier3Alive = ((towerState >> 2) & 1) == 1 ? true : false; + IsTopTier2Alive = ((towerState >> 1) & 1) == 1 ? true : false; + IsTopTier1Alive = ((towerState >> 0) & 1) == 1 ? true : false; + } + + public bool IsAncientTopAlive { get; set; } + public bool IsAncientBottomAlive { get; set; } + public bool IsBottomTier3Alive { get; set; } + public bool IsBottomTier2Alive { get; set; } + public bool IsBottomTier1Alive { get; set; } + public bool IsMiddleTier3Alive { get; set; } + public bool IsMiddleTier2Alive { get; set; } + public bool IsMiddleTier1Alive { get; set; } + public bool IsTopTier3Alive { get; set; } + public bool IsTopTier2Alive { get; set; } + public bool IsTopTier1Alive { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LeagueModel.cs b/src/Steam.Models/DOTA2/LeagueModel.cs new file mode 100644 index 0000000..b1fc736 --- /dev/null +++ b/src/Steam.Models/DOTA2/LeagueModel.cs @@ -0,0 +1,34 @@ +using System; + +namespace Steam.Models.DOTA2 +{ + public class LeagueModel + { + public string Name { get; set; } + public uint LeagueId { get; set; } + public string Description { get; set; } + public string TournamentUrl { get; set; } + public uint ItemDef { get; set; } + public string ImageInventoryPath { get; private set; } + public string ImageBannerPath { get; private set; } + public string NameLocalized { get; private set; } + public string DescriptionLocalized { get; private set; } + public string TypeName { get; private set; } + public string Tier { get; private set; } + public string Location { get; private set; } + + public override string ToString() + { + string result = String.Format("Name: {0}", NameLocalized); + if (!String.IsNullOrEmpty(Tier)) + { + result += String.Format(", Tier: {0}", Tier); + } + if (!String.IsNullOrEmpty(Location)) + { + result += String.Format(", Location: {0}", Location); + } + return result; + } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameAbilityModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameAbilityModel.cs new file mode 100644 index 0000000..9e717dd --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameAbilityModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameAbilityModel + { + public uint AbilityId { get; set; } + + public uint AbilityLevel { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameBanModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameBanModel.cs new file mode 100644 index 0000000..33bc957 --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameBanModel.cs @@ -0,0 +1,7 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameBanModel + { + public uint HeroId { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameFlattenedModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameFlattenedModel.cs new file mode 100644 index 0000000..d2a3c68 --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameFlattenedModel.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameFlattenedModel + { + public string LeagueName { get; set; } + public uint SpectatorCount { get; set; } + public string RadiantTeamName { get; set; } + public string DireTeamName { get; set; } + public uint RadiantKillCount { get; set; } + public uint DireKillCount { get; set; } + public string ElapsedTimeDisplay { get; set; } + public uint GameNumber { get; set; } + public uint BestOf { get; set; } + public uint RadiantSeriesWins { get; set; } + public uint DireSeriesWins { get; set; } + public string LeagueLogoPath { get; set; } + public string RadiantTeamLogo { get; set; } + public string DireTeamLogo { get; set; } + public uint RoshanRespawnTimer { get; set; } + public ulong LobbyId { get; set; } + public ulong MatchId { get; set; } + public double StreamDelay { get; set; } + public IReadOnlyCollection Players { get; set; } + public double ElapsedTime { get; set; } + public TowerState RadiantTowerStates { get; set; } + public TowerState DireTowerStates { get; set; } + public IReadOnlyCollection RadiantPicks { get; set; } + public IReadOnlyCollection DirePicks { get; set; } + public IReadOnlyCollection RadiantBans { get; set; } + public IReadOnlyCollection DireBans { get; set; } + public string LeagueTier { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameHeroModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameHeroModel.cs new file mode 100644 index 0000000..05bfbe6 --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameHeroModel.cs @@ -0,0 +1,10 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameHeroModel + { + public uint Id { get; set; } + public string Name { get; set; } + public string AvatarImagePath { get; set; } + public string Url { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameItemModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameItemModel.cs new file mode 100644 index 0000000..cc7b286 --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameItemModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameItemModel + { + public uint Id { get; set; } + public string Name { get; set; } + public string IconFileName { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameModel.cs new file mode 100644 index 0000000..91a2392 --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameModel.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameModel + { + public IReadOnlyCollection Players { get; set; } + + public LiveLeagueGameTeamRadiantInfoModel RadiantTeam { get; set; } + + public LiveLeagueGameTeamDireInfoModel DireTeam { get; set; } + + public ulong LobbyId { get; set; } + + public ulong MatchId { get; set; } + + public uint Spectators { get; set; } + + public uint SeriesId { get; set; } + + public uint GameNumber { get; set; } + + public uint LeagueId { get; set; } + + public double StreamDelaySeconds { get; set; } + + public uint RadiantSeriesWins { get; set; } + + public uint DireSeriesWins { get; set; } + + public uint SeriesType { get; set; } + + public uint LeagueSeriesId { get; set; } + + public uint LeagueGameId { get; set; } + + public string StageName { get; set; } + + public DotaLeagueTier LeagueTier { get; set; } + + public LiveLeagueGameScoreboardModel Scoreboard { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGamePickModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGamePickModel.cs new file mode 100644 index 0000000..c4ddd56 --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGamePickModel.cs @@ -0,0 +1,7 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGamePickModel + { + public uint HeroId { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGamePlayerDetailModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGamePlayerDetailModel.cs new file mode 100644 index 0000000..27a5c48 --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGamePlayerDetailModel.cs @@ -0,0 +1,30 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGamePlayerDetailModel + { + public uint PlayerSlot { get; set; } + public uint AccountId { get; set; } + public uint HeroId { get; set; } + public uint Kills { get; set; } + public uint Deaths { get; set; } + public uint Assists { get; set; } + public uint LastHits { get; set; } + public uint Denies { get; set; } + public uint Gold { get; set; } + public uint Level { get; set; } + public uint GoldPerMinute { get; set; } + public uint ExperiencePerMinute { get; set; } + public uint UltimateState { get; set; } + public uint UltimateCooldown { get; set; } + public int Item0 { get; set; } + public int Item1 { get; set; } + public int Item2 { get; set; } + public int Item3 { get; set; } + public int Item4 { get; set; } + public int Item5 { get; set; } + public uint RespawnTimer { get; set; } + public double PositionX { get; set; } + public double PositionY { get; set; } + public uint NetWorth { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGamePlayerInfoModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGamePlayerInfoModel.cs new file mode 100644 index 0000000..ce0c05b --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGamePlayerInfoModel.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGamePlayerInfoModel + { + public uint AccountId { get; set; } + + public string Name { get; set; } + + public uint HeroId { get; set; } + + public uint Team { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGamePlayerModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGamePlayerModel.cs new file mode 100644 index 0000000..e1670f3 --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGamePlayerModel.cs @@ -0,0 +1,34 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGamePlayerModel + { + public uint AccountId { get; set; } + public string Name { get; set; } + public uint HeroId { get; set; } + public string HeroName { get; set; } + public string HeroAvatarImageFilePath { get; set; } + public uint Team { get; set; } + public uint KillCount { get; set; } + public uint DeathCount { get; set; } + public uint AssistCount { get; set; } + public double PositionX { get; set; } + public double PositionY { get; set; } + public string HeroUrl { get; set; } + public LiveLeagueGameItemModel Item0 { get; set; } + public LiveLeagueGameItemModel Item1 { get; set; } + public LiveLeagueGameItemModel Item2 { get; set; } + public LiveLeagueGameItemModel Item3 { get; set; } + public LiveLeagueGameItemModel Item4 { get; set; } + public LiveLeagueGameItemModel Item5 { get; set; } + public uint RespawnTimer { get; set; } + public uint NetWorth { get; set; } + public uint Gold { get; set; } + public uint Level { get; set; } + public uint LastHits { get; set; } + public uint Denies { get; set; } + public uint GoldPerMinute { get; set; } + public uint XpPerMinute { get; set; } + public uint UltimateState { get; set; } + public uint UltimateCooldown { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameScoreboardModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameScoreboardModel.cs new file mode 100644 index 0000000..966d429 --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameScoreboardModel.cs @@ -0,0 +1,12 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameScoreboardModel + { + public double Duration { get; set; } + + public uint RoshanRespawnTimer { get; set; } + + public LiveLeagueGameTeamRadiantDetailModel Radiant { get; set; } + public LiveLeagueGameTeamDireDetailModel Dire { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameTeamDireDetailModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameTeamDireDetailModel.cs new file mode 100644 index 0000000..37bc9fc --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameTeamDireDetailModel.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameTeamDireDetailModel + { + public uint Score { get; set; } + + public uint TowerState { get; set; } + + public uint BarracksState { get; set; } + + public IReadOnlyCollection Picks { get; set; } + public IReadOnlyCollection Bans { get; set; } + public IReadOnlyCollection Players { get; set; } + public IReadOnlyCollection Abilities { get; set; } + + public TowerState TowerStates { get { return new TowerState(TowerState); } } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameTeamDireInfoModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameTeamDireInfoModel.cs new file mode 100644 index 0000000..1947c3f --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameTeamDireInfoModel.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameTeamDireInfoModel + { + public string TeamName { get; set; } + + public uint TeamId { get; set; } + + public ulong TeamLogo { get; set; } + + public bool Complete { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameTeamRadiantDetailModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameTeamRadiantDetailModel.cs new file mode 100644 index 0000000..843236f --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameTeamRadiantDetailModel.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameTeamRadiantDetailModel + { + public uint Score { get; set; } + + public uint TowerState { get; set; } + + public uint BarracksState { get; set; } + + public IReadOnlyCollection Picks { get; set; } + public IReadOnlyCollection Bans { get; set; } + public IReadOnlyCollection Players { get; set; } + public IReadOnlyCollection Abilities { get; set; } + + public TowerState TowerStates { get { return new TowerState(TowerState); } } + public TowerState BarracksStates { get { return new TowerState(BarracksState); } } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/LiveLeagueGameTeamRadiantInfoModel.cs b/src/Steam.Models/DOTA2/LiveLeagueGameTeamRadiantInfoModel.cs new file mode 100644 index 0000000..ce6947a --- /dev/null +++ b/src/Steam.Models/DOTA2/LiveLeagueGameTeamRadiantInfoModel.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.DOTA2 +{ + public class LiveLeagueGameTeamRadiantInfoModel + { + public string TeamName { get; set; } + + public uint TeamId { get; set; } + + public ulong TeamLogo { get; set; } + + public bool Complete { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/MatchDetailModel.cs b/src/Steam.Models/DOTA2/MatchDetailModel.cs new file mode 100644 index 0000000..384c62c --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchDetailModel.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class MatchDetailModel + { + public IReadOnlyCollection Players { get; set; } + + public bool RadiantWin { get; set; } + + public uint PreGameDuration { get; set; } + + public uint Duration { get; set; } + + public DateTime StartTime { get; set; } + + public ulong MatchId { get; set; } + + public ulong MatchSequenceNumber { get; set; } + + public uint TowerStatusRadiant { get; set; } + + public TowerState TowerStatesRadiant { get { return new TowerState(TowerStatusRadiant); } } + + public uint TowerStatusDire { get; set; } + + public TowerState TowerStatesDire { get { return new TowerState(TowerStatusDire); } } + + public uint BarracksStatusRadiant { get; set; } + + public BarracksState BarracksStatesRadiant { get { return new BarracksState(BarracksStatusRadiant); } } + + public uint BarracksStatusDire { get; set; } + + public BarracksState BarracksStatesDire { get { return new BarracksState(BarracksStatusDire); } } + + public uint Cluster { get; set; } + + public uint FirstBloodTime { get; set; } + + public uint LobbyType { get; set; } + + public uint HumanPlayers { get; set; } + + public uint LeagueId { get; set; } + + public uint PositiveVotes { get; set; } + + public uint NegativeVotes { get; set; } + + public uint GameMode { get; set; } + + public uint Engine { get; set; } + + public uint RadiantTeamId { get; set; } + + public string RadiantName { get; set; } + + public ulong RadiantLogo { get; set; } + + public uint RadiantTeamComplete { get; set; } + + public uint DireTeamId { get; set; } + + public string DireName { get; set; } + + public ulong DireLogo { get; set; } + + public uint DireTeamComplete { get; set; } + + public uint RadiantCaptain { get; set; } + + public uint DireCaptain { get; set; } + + public uint RadiantScore { get; set; } + + public uint DireScore { get; set; } + + public IReadOnlyCollection PicksAndBans { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/MatchHistoryBySequenceNumberMatchModel.cs b/src/Steam.Models/DOTA2/MatchHistoryBySequenceNumberMatchModel.cs new file mode 100644 index 0000000..702d32f --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchHistoryBySequenceNumberMatchModel.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class MatchHistoryBySequenceNumberMatchModel + { + public IList Players { get; set; } + + public bool RadiantWin { get; set; } + + public uint Duration { get; set; } + + public DateTime StartTime { get; set; } + + public ulong MatchId { get; set; } + + public ulong MatchSequenceNumber { get; set; } + + public TowerState TowerStatesRadiant { get { return new TowerState(TowerStatusRadiant); } } + + public uint TowerStatusRadiant { get; set; } + + public TowerState TowerStatesDire { get { return new TowerState(TowerStatusRadiant); } } + + public uint TowerStatusDire { get; set; } + + public BarracksState BarracksStatesRadiant { get { return new BarracksState(BarracksStatusRadiant); } } + + public uint BarracksStatusRadiant { get; set; } + + public BarracksState BarracksStatesDire { get { return new BarracksState(BarracksStatusDire); } } + + public uint BarracksStatusDire { get; set; } + + public uint Cluster { get; set; } + + public DateTime FirstBloodTime { get; set; } + + public uint LobbyType { get; set; } + + public uint HumanPlayers { get; set; } + + public uint LeagueId { get; set; } + + public uint PositiveVotes { get; set; } + + public uint NegativeVotes { get; set; } + + public uint GameMode { get; set; } + + public uint Flags { get; set; } + + public uint Engine { get; set; } + + public uint RadiantScore { get; set; } + + public uint DireScore { get; set; } + } +} diff --git a/src/Steam.Models/DOTA2/MatchHistoryBySequenceNumberMatchPlayerAbilityUpgradeModel.cs b/src/Steam.Models/DOTA2/MatchHistoryBySequenceNumberMatchPlayerAbilityUpgradeModel.cs new file mode 100644 index 0000000..22bd03e --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchHistoryBySequenceNumberMatchPlayerAbilityUpgradeModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.DOTA2 +{ + public class MatchHistoryBySequenceNumberMatchPlayerAbilityUpgradeModel + { + public uint Ability { get; set; } + + public uint Time { get; set; } + + public uint Level { get; set; } + } +} diff --git a/src/Steam.Models/DOTA2/MatchHistoryBySequenceNumberMatchPlayerModel.cs b/src/Steam.Models/DOTA2/MatchHistoryBySequenceNumberMatchPlayerModel.cs new file mode 100644 index 0000000..d07bba3 --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchHistoryBySequenceNumberMatchPlayerModel.cs @@ -0,0 +1,55 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class MatchHistoryBySequenceNumberMatchPlayerModel + { + public IList AbilityUpgrades { get; set; } + + public ulong AccountId { get; set; } + + public uint PlayerSlot { get; set; } + + public uint HeroId { get; set; } + + public uint Item0 { get; set; } + + public uint Item1 { get; set; } + + public uint Item2 { get; set; } + + public uint Item3 { get; set; } + + public uint Item4 { get; set; } + + public uint Item5 { get; set; } + + public uint Kills { get; set; } + + public uint Deaths { get; set; } + + public uint Assists { get; set; } + + public uint LeaverStatus { get; set; } + + public uint LastHits { get; set; } + + public uint Denies { get; set; } + + public uint GoldPerMin { get; set; } + + public uint XpPerMin { get; set; } + + public uint Level { get; set; } + + public uint Gold { get; set; } + + public uint GoldSpent { get; set; } + + public uint HeroDamage { get; set; } + + public uint TowerDamage { get; set; } + + public uint HeroHealing { get; set; } + } +} diff --git a/src/Steam.Models/DOTA2/MatchHistoryMatchModel.cs b/src/Steam.Models/DOTA2/MatchHistoryMatchModel.cs new file mode 100644 index 0000000..f5c0bac --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchHistoryMatchModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class MatchHistoryMatchModel + { + public ulong MatchId { get; set; } + + public ulong MatchSequenceNumber { get; set; } + + public DateTime StartTime { get; set; } + + public uint LobbyType { get; set; } + + public uint RadiantTeamId { get; set; } + + public uint DireTeamId { get; set; } + + public IReadOnlyCollection Players { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/MatchHistoryModel.cs b/src/Steam.Models/DOTA2/MatchHistoryModel.cs new file mode 100644 index 0000000..fa521ba --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchHistoryModel.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class MatchHistoryModel + { + public uint Status { get; set; } + + public uint NumResults { get; set; } + + public uint TotalResults { get; set; } + + public uint ResultsRemaining { get; set; } + + public IReadOnlyCollection Matches { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/MatchHistoryPlayerModel.cs b/src/Steam.Models/DOTA2/MatchHistoryPlayerModel.cs new file mode 100644 index 0000000..80ff4d1 --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchHistoryPlayerModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.DOTA2 +{ + public class MatchHistoryPlayerModel + { + public uint AccountId { get; set; } + + public uint PlayerSlot { get; set; } + + public uint HeroId { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/MatchPickBanModel.cs b/src/Steam.Models/DOTA2/MatchPickBanModel.cs new file mode 100644 index 0000000..9889fa0 --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchPickBanModel.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.DOTA2 +{ + public class MatchPickBanModel + { + public bool IsPick { get; set; } + + public uint HeroId { get; set; } + + public uint Team { get; set; } + + public uint Order { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/MatchPlayerAbilityUpgradeModel.cs b/src/Steam.Models/DOTA2/MatchPlayerAbilityUpgradeModel.cs new file mode 100644 index 0000000..5fcbc7f --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchPlayerAbilityUpgradeModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.DOTA2 +{ + public class MatchPlayerAbilityUpgradeModel + { + public uint Ability { get; set; } + + public uint Time { get; set; } + + public uint Level { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/MatchPlayerAdditionalUnitModel.cs b/src/Steam.Models/DOTA2/MatchPlayerAdditionalUnitModel.cs new file mode 100644 index 0000000..be1630e --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchPlayerAdditionalUnitModel.cs @@ -0,0 +1,27 @@ +namespace Steam.Models.DOTA2 +{ + public class MatchPlayerAdditionalUnitModel + { + public string Unitname { get; set; } + + public uint Item0 { get; set; } + + public uint Item1 { get; set; } + + public uint Item2 { get; set; } + + public uint Item3 { get; set; } + + public uint Item4 { get; set; } + + public uint Item5 { get; set; } + + public uint Backpack0 { get; set; } + + public uint Backpack1 { get; set; } + + public uint Backpack2 { get; set; } + + public uint ItemNeutral { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/MatchPlayerModel.cs b/src/Steam.Models/DOTA2/MatchPlayerModel.cs new file mode 100644 index 0000000..f3e07da --- /dev/null +++ b/src/Steam.Models/DOTA2/MatchPlayerModel.cs @@ -0,0 +1,79 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class MatchPlayerModel + { + public uint AccountId { get; set; } + + public uint PlayerSlot { get; set; } + + public uint HeroId { get; set; } + + public uint Item0 { get; set; } + + public uint Item1 { get; set; } + + public uint Item2 { get; set; } + + public uint Item3 { get; set; } + + public uint Item4 { get; set; } + + public uint Item5 { get; set; } + + public uint Backpack0 { get; set; } + + public uint Backpack1 { get; set; } + + public uint Backpack2 { get; set; } + + public uint ItemNeutral { get; set; } + + public uint Kills { get; set; } + + public uint Deaths { get; set; } + + public uint Assists { get; set; } + + public uint LeaverStatus { get; set; } + + public uint Gold { get; set; } + + public uint LastHits { get; set; } + + public uint Denies { get; set; } + + public uint GoldPerMinute { get; set; } + + public uint ExperiencePerMinute { get; set; } + + public uint GoldSpent { get; set; } + + public uint NetWorth { get; set; } + + public uint AghanimsScepter { get; set; } + + public uint AghanimsShard { get; set; } + + public uint Moonshard { get; set; } + + public uint HeroDamage { get; set; } + + public uint ScaledHeroDamage { get; set; } + + public uint ScaledTowerDamage { get; set; } + + public uint ScaledHeroHealing { get; set; } + + public uint TowerDamage { get; set; } + + public uint HeroHealing { get; set; } + + public uint Level { get; set; } + + public IReadOnlyCollection AbilityUpgrades { get; set; } + + public IReadOnlyCollection AdditionalUnits { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/PlayerOfficialInfoModel.cs b/src/Steam.Models/DOTA2/PlayerOfficialInfoModel.cs new file mode 100644 index 0000000..187d7c3 --- /dev/null +++ b/src/Steam.Models/DOTA2/PlayerOfficialInfoModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.DOTA2 +{ + public class PlayerOfficialInfoModel + { + public string Name { get; set; } + public string TeamName { get; set; } + public string TeamTag { get; set; } + public string Sponsor { get; set; } + public uint FantasyRole { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/ProPlayerDetailModel.cs b/src/Steam.Models/DOTA2/ProPlayerDetailModel.cs new file mode 100644 index 0000000..e98b16f --- /dev/null +++ b/src/Steam.Models/DOTA2/ProPlayerDetailModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class ProPlayerDetailModel + { + public IReadOnlyCollection ProPlayers { get; set; } + + public IReadOnlyCollection Leaderboards { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/ProPlayerInfoModel.cs b/src/Steam.Models/DOTA2/ProPlayerInfoModel.cs new file mode 100644 index 0000000..e7ee982 --- /dev/null +++ b/src/Steam.Models/DOTA2/ProPlayerInfoModel.cs @@ -0,0 +1,23 @@ +namespace Steam.Models.DOTA2 +{ + public class ProPlayerInfoModel + { + public uint AccountId { get; set; } + + public string Name { get; set; } + + public string CountryCode { get; set; } + + public uint FantasyRole { get; set; } + + public uint TeamId { get; set; } + + public string TeamName { get; set; } + + public string TeamTag { get; set; } + + public bool IsPro { get; set; } + + public string Sponsor { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/DOTA2/ProPlayerLeaderboardModel.cs b/src/Steam.Models/DOTA2/ProPlayerLeaderboardModel.cs new file mode 100644 index 0000000..edc93c8 --- /dev/null +++ b/src/Steam.Models/DOTA2/ProPlayerLeaderboardModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.DOTA2 +{ + public class ProPlayerLeaderboardModel + { + public uint Division { get; set; } + + public IReadOnlyCollection AccountIds { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameClientResultModel.cs b/src/Steam.Models/GameClientResultModel.cs new file mode 100644 index 0000000..15bff40 --- /dev/null +++ b/src/Steam.Models/GameClientResultModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models +{ + public class GameClientResultModel + { + public bool Success { get; set; } + + public uint DeployVersion { get; set; } + + public uint ActiveVersion { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/EconItemAttributeAccountInfoModel.cs b/src/Steam.Models/GameEconomy/EconItemAttributeAccountInfoModel.cs new file mode 100644 index 0000000..e9c9c2f --- /dev/null +++ b/src/Steam.Models/GameEconomy/EconItemAttributeAccountInfoModel.cs @@ -0,0 +1,8 @@ +namespace Steam.Models.GameEconomy +{ + public class EconItemAttributeAccountInfoModel + { + public ulong SteamId { get; set; } + public string PersonaName { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/EconItemAttributeModel.cs b/src/Steam.Models/GameEconomy/EconItemAttributeModel.cs new file mode 100644 index 0000000..9ebf7f8 --- /dev/null +++ b/src/Steam.Models/GameEconomy/EconItemAttributeModel.cs @@ -0,0 +1,12 @@ +namespace Steam.Models.GameEconomy +{ + public class EconItemAttributeModel + { + public uint DefIndex { get; set; } + public object Value { get; set; } + + public double FloatValue { get; set; } + + public EconItemAttributeAccountInfoModel AccountInfo { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/EconItemEquippedModel.cs b/src/Steam.Models/GameEconomy/EconItemEquippedModel.cs new file mode 100644 index 0000000..fa5855b --- /dev/null +++ b/src/Steam.Models/GameEconomy/EconItemEquippedModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.GameEconomy +{ + public class EconItemEquippedModel + { + public uint ClassId { get; set; } + + public uint Slot { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/EconItemModel.cs b/src/Steam.Models/GameEconomy/EconItemModel.cs new file mode 100644 index 0000000..45ff537 --- /dev/null +++ b/src/Steam.Models/GameEconomy/EconItemModel.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class EconItemModel + { + public ulong Id { get; set; } + + public ulong OriginalId { get; set; } + + public uint DefIndex { get; set; } + public uint Level { get; set; } + public uint Quality { get; set; } + public ulong Inventory { get; set; } + public uint Quantity { get; set; } + public uint Origin { get; set; } + public IReadOnlyCollection Equipped { get; set; } + public uint Style { get; set; } + public IReadOnlyCollection Attributes { get; set; } + + public bool? FlagCannotTrade { get; set; } + + public bool? FlagCannotCraft { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/EconItemResultModel.cs b/src/Steam.Models/GameEconomy/EconItemResultModel.cs new file mode 100644 index 0000000..58b3b10 --- /dev/null +++ b/src/Steam.Models/GameEconomy/EconItemResultModel.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class EconItemResultModel + { + public uint Status { get; set; } + + public uint NumBackpackSlots { get; set; } + + public IReadOnlyCollection Items { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaAdditionalHiddenBodygroupsModel.cs b/src/Steam.Models/GameEconomy/SchemaAdditionalHiddenBodygroupsModel.cs new file mode 100644 index 0000000..39e8d4a --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaAdditionalHiddenBodygroupsModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaAdditionalHiddenBodygroupsModel + { + public uint Hat { get; set; } + + public uint Headphones { get; set; } + + public uint? Head { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaAttributeControlledAttachedParticleModel.cs b/src/Steam.Models/GameEconomy/SchemaAttributeControlledAttachedParticleModel.cs new file mode 100644 index 0000000..f768272 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaAttributeControlledAttachedParticleModel.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaAttributeControlledAttachedParticleModel + { + public string System { get; set; } + + public uint Id { get; set; } + + public bool AttachToRootbone { get; set; } + + public string Name { get; set; } + + public string Attachment { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaAttributeModel.cs b/src/Steam.Models/GameEconomy/SchemaAttributeModel.cs new file mode 100644 index 0000000..809d036 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaAttributeModel.cs @@ -0,0 +1,21 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaAttributeModel + { + public string Name { get; set; } + + public uint Defindex { get; set; } + + public string AttributeClass { get; set; } + + public string DescriptionString { get; set; } + + public string DescriptionFormat { get; set; } + + public string EffectType { get; set; } + + public bool Hidden { get; set; } + + public bool StoredAsInteger { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaCapabilitiesModel.cs b/src/Steam.Models/GameEconomy/SchemaCapabilitiesModel.cs new file mode 100644 index 0000000..d3d03e2 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaCapabilitiesModel.cs @@ -0,0 +1,45 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaCapabilitiesModel + { + public bool Nameable { get; set; } + + public bool CanCraftMark { get; set; } + + public bool CanBeRestored { get; set; } + + public bool StrangeParts { get; set; } + + public bool CanCardUpgrade { get; set; } + + public bool CanStrangify { get; set; } + + public bool CanKillstreakify { get; set; } + + public bool CanConsume { get; set; } + + public bool? CanGiftWrap { get; set; } + + public bool? CanCollect { get; set; } + + public bool? Paintable { get; set; } + + public bool? CanCraftIfPurchased { get; set; } + + public bool? CanCraftCount { get; set; } + + public bool? UsableGc { get; set; } + + public bool? Usable { get; set; } + + public bool? CanCustomizeTexture { get; set; } + + public bool? UsableOutOfGame { get; set; } + + public bool? CanSpellPage { get; set; } + + public bool? DuckUpgradable { get; set; } + + public bool? Decodable { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaItemAttributeModel.cs b/src/Steam.Models/GameEconomy/SchemaItemAttributeModel.cs new file mode 100644 index 0000000..1d77c2b --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaItemAttributeModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaItemAttributeModel + { + public string Name { get; set; } + + public string Class { get; set; } + + public double Value { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaItemLevelModel.cs b/src/Steam.Models/GameEconomy/SchemaItemLevelModel.cs new file mode 100644 index 0000000..6d10891 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaItemLevelModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class SchemaItemLevelModel + { + public string Name { get; set; } + + public IReadOnlyCollection Levels { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaItemModel.cs b/src/Steam.Models/GameEconomy/SchemaItemModel.cs new file mode 100644 index 0000000..fa876bd --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaItemModel.cs @@ -0,0 +1,81 @@ +using Steam.Models.DOTA2; +using System; +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class SchemaItemModel + { + public uint DefIndex { get; set; } + + public string Name { get; set; } + + public string ImageInventoryPath { get; set; } + + public string ItemName { get; set; } + + public string ItemDescription { get; set; } + + public string ItemTypeName { get; set; } + + public string ItemClass { get; set; } + + public bool ProperName { get; set; } + + public string ItemSlot { get; set; } + + public string ModelPlayer { get; set; } + + public uint ItemQuality { get; set; } + + public uint MinIlevel { get; set; } + + public uint MaxIlevel { get; set; } + + public string ImageUrl { get; set; } + + public string ImageUrlLarge { get; set; } + + public string CraftClass { get; set; } + + public string CraftMaterialType { get; set; } + + public string ItemLogName { get; set; } + + public SchemaCapabilitiesModel Capabilities { get; set; } + + public IReadOnlyCollection UsedByClasses { get; set; } + + public IReadOnlyCollection Styles { get; set; } + + public IReadOnlyCollection Attributes { get; set; } + + public string DropType { get; set; } + + public string ItemSet { get; set; } + + public string HolidayRestriction { get; set; } + + public SchemaPerClassLoadoutSlotsModel PerClassLoadoutSlots { get; set; } + + public SchemaToolModel Tool { get; set; } + + public string Prefab { get; set; } + + public DateTime? CreationDate { get; set; } + + public DateTime? ExpirationDate { get; set; } + + public string TournamentUrl { get; set; } + + public string ImageBannerPath { get; set; } + + public string ItemRarity { get; set; } + + public SchemaItemPriceInfo PriceInfo { get; set; } + + public IList UsedByHeroes { get; set; } + + public IList BundledItems { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaItemSetAttributeModel.cs b/src/Steam.Models/GameEconomy/SchemaItemSetAttributeModel.cs new file mode 100644 index 0000000..4584d30 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaItemSetAttributeModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaItemSetAttributeModel + { + public string Name { get; set; } + + public string Class { get; set; } + + public double Value { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaItemSetModel.cs b/src/Steam.Models/GameEconomy/SchemaItemSetModel.cs new file mode 100644 index 0000000..8650337 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaItemSetModel.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class SchemaItemSetModel + { + public string RawName { get; set; } + + public string ItemSet { get; set; } + + public string Name { get; set; } + + public IReadOnlyCollection Items { get; set; } + + public IReadOnlyCollection Attributes { get; set; } + + public string StoreBundleName { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaKillEaterScoreTypeModel.cs b/src/Steam.Models/GameEconomy/SchemaKillEaterScoreTypeModel.cs new file mode 100644 index 0000000..355d978 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaKillEaterScoreTypeModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaKillEaterScoreTypeModel + { + public uint Type { get; set; } + + public string TypeName { get; set; } + + public string LevelData { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaLevelModel.cs b/src/Steam.Models/GameEconomy/SchemaLevelModel.cs new file mode 100644 index 0000000..6dc65ab --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaLevelModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaLevelModel + { + public uint Level { get; set; } + + public uint RequiredScore { get; set; } + + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaModel.cs b/src/Steam.Models/GameEconomy/SchemaModel.cs new file mode 100644 index 0000000..e606d61 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaModel.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class SchemaModel + { + public uint Status { get; set; } + + public string ItemsGameUrl { get; set; } + + public SchemaQualitiesModel Qualities { get; set; } + + public IReadOnlyCollection OriginNames { get; set; } + + public IReadOnlyCollection Items { get; set; } + + public IReadOnlyCollection Attributes { get; set; } + + public IReadOnlyCollection ItemSets { get; set; } + + public IReadOnlyCollection AttributeControlledAttachedParticles { get; set; } + + public IReadOnlyCollection ItemLevels { get; set; } + + public IReadOnlyCollection KillEaterScoreTypes { get; set; } + + public IReadOnlyCollection StringLookups { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaOriginNameModel.cs b/src/Steam.Models/GameEconomy/SchemaOriginNameModel.cs new file mode 100644 index 0000000..a024211 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaOriginNameModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaOriginNameModel + { + public uint Origin { get; set; } + + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaPerClassLoadoutSlotsModel.cs b/src/Steam.Models/GameEconomy/SchemaPerClassLoadoutSlotsModel.cs new file mode 100644 index 0000000..2ab709a --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaPerClassLoadoutSlotsModel.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaPerClassLoadoutSlotsModel + { + public string Soldier { get; set; } + + public string Heavy { get; set; } + + public string Pyro { get; set; } + + public string Engineer { get; set; } + + public string Demoman { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaQualitiesModel.cs b/src/Steam.Models/GameEconomy/SchemaQualitiesModel.cs new file mode 100644 index 0000000..e3bd2b5 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaQualitiesModel.cs @@ -0,0 +1,82 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaQualitiesModel + { + /// + /// Normal item rarity: https://wiki.teamfortress.com/wiki/Normal + /// + public uint Normal { get; set; } + + /// + /// Genuine item rarity: https://wiki.teamfortress.com/wiki/Genuine + /// + public uint Rarity1 { get; set; } + + /// + /// Unused + /// + public uint Rarity2 { get; set; } + + /// + /// Vintage item rarity: https://wiki.teamfortress.com/wiki/Vintage + /// + public uint Vintage { get; set; } + + /// + /// Unused + /// + public uint Rarity3 { get; set; } + + /// + /// Unusual item rarity: https://wiki.teamfortress.com/wiki/Unusual + /// + public uint Rarity4 { get; set; } + + /// + /// Unique item rarity: https://wiki.teamfortress.com/wiki/Unique + /// + public uint Unique { get; set; } + + /// + /// Community item: https://wiki.teamfortress.com/wiki/Community_(quality) + /// + public uint Community { get; set; } + + /// + /// Developer owned item: https://wiki.teamfortress.com/wiki/Valve_(quality) + /// + public uint Developer { get; set; } + + /// + /// Self made item: https://wiki.teamfortress.com/wiki/Self-Made + /// + public uint SelfMade { get; set; } + + /// + /// Unused + /// + public uint Customized { get; set; } + + /// + /// Strange item: https://wiki.teamfortress.com/wiki/Strange + /// + public uint Strange { get; set; } + + /// + /// Unused + /// + public uint Completed { get; set; } + + /// + /// Haunted item: https://wiki.teamfortress.com/wiki/Haunted + /// + public uint Haunted { get; set; } + + /// + /// Collector's item: https://wiki.teamfortress.com/wiki/Collector%27s + /// + public uint Collectors { get; set; } + + public uint PaintKitWeapon { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaStringLookupModel.cs b/src/Steam.Models/GameEconomy/SchemaStringLookupModel.cs new file mode 100644 index 0000000..3173730 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaStringLookupModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class SchemaStringLookupModel + { + public string TableName { get; set; } + + public IReadOnlyCollection Strings { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaStringModel.cs b/src/Steam.Models/GameEconomy/SchemaStringModel.cs new file mode 100644 index 0000000..1de1cb4 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaStringModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaStringModel + { + public uint Index { get; set; } + + public string String { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaStyleModel.cs b/src/Steam.Models/GameEconomy/SchemaStyleModel.cs new file mode 100644 index 0000000..4714080 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaStyleModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaStyleModel + { + public string Name { get; set; } + + public SchemaAdditionalHiddenBodygroupsModel AdditionalHiddenBodygroups { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaToolModel.cs b/src/Steam.Models/GameEconomy/SchemaToolModel.cs new file mode 100644 index 0000000..25f68a7 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaToolModel.cs @@ -0,0 +1,17 @@ +using Steam.Models.DOTA2; + +namespace Steam.Models.GameEconomy +{ + public class SchemaToolModel + { + public string Type { get; set; } + + public SchemaUsageCapabilitiesModel UsageCapabilities { get; set; } + + public SchemaItemToolUsage Usage { get; set; } + + public string UseString { get; set; } + + public string Restriction { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/SchemaUsageCapabilitiesModel.cs b/src/Steam.Models/GameEconomy/SchemaUsageCapabilitiesModel.cs new file mode 100644 index 0000000..17973f2 --- /dev/null +++ b/src/Steam.Models/GameEconomy/SchemaUsageCapabilitiesModel.cs @@ -0,0 +1,31 @@ +namespace Steam.Models.GameEconomy +{ + public class SchemaUsageCapabilitiesModel + { + public bool Nameable { get; set; } + + public bool? Decodable { get; set; } + + public bool? Paintable { get; set; } + + public bool? CanCustomizeTexture { get; set; } + + public bool? CanGiftWrap { get; set; } + + public bool? PaintableTeamColors { get; set; } + + public bool? CanStrangify { get; set; } + + public bool? CanKillstreakify { get; set; } + + public bool? DuckUpgradable { get; set; } + + public bool? StrangeParts { get; set; } + + public bool? CanCardUpgrade { get; set; } + + public bool? CanSpellPage { get; set; } + + public bool? CanConsume { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreBannerModel.cs b/src/Steam.Models/GameEconomy/StoreBannerModel.cs new file mode 100644 index 0000000..cad3d83 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreBannerModel.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.GameEconomy +{ + public class StoreBannerModel + { + public string BaseFileName { get; set; } + + public string Action { get; set; } + + public string Placement { get; set; } + + public string ActionParam { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreCarouselDataModel.cs b/src/Steam.Models/GameEconomy/StoreCarouselDataModel.cs new file mode 100644 index 0000000..2fd3b00 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreCarouselDataModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class StoreCarouselDataModel + { + public uint MaxDisplayBanners { get; set; } + + public IReadOnlyCollection Banners { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreConfigModel.cs b/src/Steam.Models/GameEconomy/StoreConfigModel.cs new file mode 100644 index 0000000..dcdba83 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreConfigModel.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.GameEconomy +{ + public class StoreConfigModel + { + public ulong DropdownId { get; set; } + + public string Name { get; set; } + + public bool Enabled { get; set; } + + public ulong DefaultSelectionId { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreDropdownDataModel.cs b/src/Steam.Models/GameEconomy/StoreDropdownDataModel.cs new file mode 100644 index 0000000..8c2474c --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreDropdownDataModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class StoreDropdownDataModel + { + public IReadOnlyCollection Dropdowns { get; set; } + + public IReadOnlyCollection Prefabs { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreDropdownModel.cs b/src/Steam.Models/GameEconomy/StoreDropdownModel.cs new file mode 100644 index 0000000..719d06a --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreDropdownModel.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.GameEconomy +{ + public class StoreDropdownModel + { + public ulong Id { get; set; } + + public string Name { get; set; } + + public string Type { get; set; } + + public string LabelText { get; set; } + + public string UrlHistoryParamName { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreFilterAllElementModel.cs b/src/Steam.Models/GameEconomy/StoreFilterAllElementModel.cs new file mode 100644 index 0000000..9a820bf --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreFilterAllElementModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.GameEconomy +{ + public class StoreFilterAllElementModel + { + public ulong Id { get; set; } + + public string LocalizedText { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreFilterElementModel.cs b/src/Steam.Models/GameEconomy/StoreFilterElementModel.cs new file mode 100644 index 0000000..342ee49 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreFilterElementModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.GameEconomy +{ + public class StoreFilterElementModel + { + public string Name { get; set; } + + public string LocalizedText { get; set; } + + public ulong Id { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreFilterModel.cs b/src/Steam.Models/GameEconomy/StoreFilterModel.cs new file mode 100644 index 0000000..fa0d3b3 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreFilterModel.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class StoreFilterModel + { + public uint Id { get; set; } + + public string Name { get; set; } + + public string UrlHistoryParamName { get; set; } + + public StoreFilterAllElementModel AllElement { get; set; } + + public IReadOnlyCollection Elements { get; set; } + + public uint Count { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreHomePageDataModel.cs b/src/Steam.Models/GameEconomy/StoreHomePageDataModel.cs new file mode 100644 index 0000000..2306471 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreHomePageDataModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class StoreHomePageDataModel + { + public uint HomeCategoryId { get; set; } + + public IReadOnlyCollection PopularItems { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreMetaDataModel.cs b/src/Steam.Models/GameEconomy/StoreMetaDataModel.cs new file mode 100644 index 0000000..ef69310 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreMetaDataModel.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class StoreMetaDataModel + { + public StoreCarouselDataModel CarouselData { get; set; } + + public IReadOnlyCollection Tabs { get; set; } + + public IReadOnlyCollection Filters { get; set; } + + public StoreSortingModel Sorting { get; set; } + + public StoreDropdownDataModel DropdownData { get; set; } + + public IReadOnlyCollection PlayerClassData { get; set; } + + public StoreHomePageDataModel HomePageData { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StorePlayerClassDataModel.cs b/src/Steam.Models/GameEconomy/StorePlayerClassDataModel.cs new file mode 100644 index 0000000..ff37967 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StorePlayerClassDataModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.GameEconomy +{ + public class StorePlayerClassDataModel + { + public uint Id { get; set; } + + public string BaseName { get; set; } + + public string LocalizedText { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StorePopularItemModel.cs b/src/Steam.Models/GameEconomy/StorePopularItemModel.cs new file mode 100644 index 0000000..261d1c4 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StorePopularItemModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.GameEconomy +{ + public class StorePopularItemModel + { + public uint DefIndex { get; set; } + + public uint Order { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StorePrefabModel.cs b/src/Steam.Models/GameEconomy/StorePrefabModel.cs new file mode 100644 index 0000000..e68b3cb --- /dev/null +++ b/src/Steam.Models/GameEconomy/StorePrefabModel.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class StorePrefabModel + { + public ulong Id { get; set; } + + public string Name { get; set; } + + public IReadOnlyCollection Config { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreSorterIdModel.cs b/src/Steam.Models/GameEconomy/StoreSorterIdModel.cs new file mode 100644 index 0000000..c89b531 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreSorterIdModel.cs @@ -0,0 +1,7 @@ +namespace Steam.Models.GameEconomy +{ + public class StoreSorterIdModel + { + public ulong Id { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreSorterModel.cs b/src/Steam.Models/GameEconomy/StoreSorterModel.cs new file mode 100644 index 0000000..2d6dc36 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreSorterModel.cs @@ -0,0 +1,17 @@ +namespace Steam.Models.GameEconomy +{ + public class StoreSorterModel + { + public ulong Id { get; set; } + + public string Name { get; set; } + + public string DataType { get; set; } + + public string SortField { get; set; } + + public bool SortReversed { get; set; } + + public string LocalizedText { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreSortingModel.cs b/src/Steam.Models/GameEconomy/StoreSortingModel.cs new file mode 100644 index 0000000..ff56728 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreSortingModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class StoreSortingModel + { + public IReadOnlyCollection Sorters { get; set; } + + public IReadOnlyCollection SortingPrefabs { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreSortingPrefabModel.cs b/src/Steam.Models/GameEconomy/StoreSortingPrefabModel.cs new file mode 100644 index 0000000..81ecacd --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreSortingPrefabModel.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class StoreSortingPrefabModel + { + public ulong Id { get; set; } + + public string Name { get; set; } + + public string UrlHistoryParamName { get; set; } + + public IReadOnlyCollection SorterIds { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreTabChildModel.cs b/src/Steam.Models/GameEconomy/StoreTabChildModel.cs new file mode 100644 index 0000000..ce1c944 --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreTabChildModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.GameEconomy +{ + public class StoreTabChildModel + { + public string Name { get; set; } + + public uint Id { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameEconomy/StoreTabModel.cs b/src/Steam.Models/GameEconomy/StoreTabModel.cs new file mode 100644 index 0000000..309de8f --- /dev/null +++ b/src/Steam.Models/GameEconomy/StoreTabModel.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; + +namespace Steam.Models.GameEconomy +{ + public class StoreTabModel + { + public string Label { get; set; } + + public uint Id { get; set; } + + public uint ParentId { get; set; } + + public bool UseLargeCells { get; set; } + + public bool Default { get; set; } + + public IReadOnlyCollection Children { get; set; } + + public bool Home { get; set; } + + public ulong? DropdownPrefabId { get; set; } + + public string ParentName { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameServers/AccountListModel.cs b/src/Steam.Models/GameServers/AccountListModel.cs new file mode 100644 index 0000000..9f4a8f0 --- /dev/null +++ b/src/Steam.Models/GameServers/AccountListModel.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; + +namespace Steam.Models.GameServers +{ + public class AccountListModel + { + public IEnumerable Servers { get; set; } + + public bool IsBanned { get; set; } + + /// Not sure if this should be a DateTime or bool. Can't find + /// documentation on what this field indicates. + /// + public uint Expires { get; set; } + + /// Steam ID of the account holder that created the game server account. + /// + public ulong Actor { get; set; } + + /// Not sure what this indicates. After creating a game server account, + /// I expected to see a time stamp here, but it returns 0 instead. + /// + public DateTime LastActionTime { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameServers/AccountPublicInfoModel.cs b/src/Steam.Models/GameServers/AccountPublicInfoModel.cs new file mode 100644 index 0000000..e6e565b --- /dev/null +++ b/src/Steam.Models/GameServers/AccountPublicInfoModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.GameServers +{ + public class AccountPublicInfoModel + { + public ulong SteamId { get; set; } + + public uint AppId { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameServers/AccountServerModel.cs b/src/Steam.Models/GameServers/AccountServerModel.cs new file mode 100644 index 0000000..51c78b1 --- /dev/null +++ b/src/Steam.Models/GameServers/AccountServerModel.cs @@ -0,0 +1,25 @@ +using System; + +namespace Steam.Models.GameServers +{ + public class AccountServerModel + { + /// Steam ID of the game server. + /// + public ulong SteamId { get; set; } + + /// AppId that the game server is associated with such as TF2 or CS:GO + /// + public uint AppId { get; set; } + + public string LoginToken { get; set; } + + public string Memo { get; set; } + + public bool IsDeleted { get; set; } + + public bool IsExpired { get; set; } + + public DateTime RtLastLogon { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameServers/CreateAccountModel.cs b/src/Steam.Models/GameServers/CreateAccountModel.cs new file mode 100644 index 0000000..0b8a433 --- /dev/null +++ b/src/Steam.Models/GameServers/CreateAccountModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.GameServers +{ + public class CreateAccountModel + { + public ulong SteamId { get; set; } + + public string LoginToken { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/GameServers/QueryLoginTokenModel.cs b/src/Steam.Models/GameServers/QueryLoginTokenModel.cs new file mode 100644 index 0000000..eb9ea20 --- /dev/null +++ b/src/Steam.Models/GameServers/QueryLoginTokenModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.GameServers +{ + public class QueryLoginTokenModel + { + public bool IsBanned { get; set; } + + public uint Expires { get; set; } + + public ulong SteamId { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/NewsItemModel.cs b/src/Steam.Models/NewsItemModel.cs new file mode 100644 index 0000000..eaf7b03 --- /dev/null +++ b/src/Steam.Models/NewsItemModel.cs @@ -0,0 +1,25 @@ +namespace Steam.Models +{ + public class NewsItemModel + { + public string Gid { get; set; } + + public string Title { get; set; } + + public string Url { get; set; } + + public bool IsExternalUrl { get; set; } + + public string Author { get; set; } + + public string Contents { get; set; } + + public string FeedLabel { get; set; } + + public ulong Date { get; set; } + + public string Feedname { get; set; } + + public string[] Tags { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/PublishedFileDetailsModel.cs b/src/Steam.Models/PublishedFileDetailsModel.cs new file mode 100644 index 0000000..670ef7e --- /dev/null +++ b/src/Steam.Models/PublishedFileDetailsModel.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; + +namespace Steam.Models +{ + public class PublishedFileDetailsModel + { + public ulong PublishedFileId { get; set; } + + public uint Result { get; set; } + + public ulong Creator { get; set; } + + public uint CreatorAppId { get; set; } + + public uint ConsumerAppId { get; set; } + + public string FileName { get; set; } + + public ulong FileSize { get; set; } + + public Uri FileUrl { get; set; } + + public ulong FileContentHandle { get; set; } + + public Uri PreviewUrl { get; set; } + + public ulong PreviewContentHandle { get; set; } + + public string Title { get; set; } + + public string Description { get; set; } + + public DateTime TimeCreated { get; set; } + + public DateTime TimeUpdated { get; set; } + + public PublishedFileVisibility Visibility { get; set; } + + public bool Banned { get; set; } + + public string BanReason { get; set; } + + public ulong Subscriptions { get; set; } + + public ulong Favorited { get; set; } + + public ulong LifetimeSubscriptions { get; set; } + + public ulong LifetimeFavorited { get; set; } + + public ulong Views { get; set; } + + public IList Tags { get; set; } + } +} diff --git a/src/Steam.Models/PublishedFileVisibility.cs b/src/Steam.Models/PublishedFileVisibility.cs new file mode 100644 index 0000000..623e8a8 --- /dev/null +++ b/src/Steam.Models/PublishedFileVisibility.cs @@ -0,0 +1,10 @@ +namespace Steam.Models +{ + public enum PublishedFileVisibility : uint + { + Public = 0, + FriendsOnly = 1, + Private = 2, + Unknown = 3 + } +} diff --git a/src/Steam.Models/SchemaForGameResultModel.cs b/src/Steam.Models/SchemaForGameResultModel.cs new file mode 100644 index 0000000..c745e9c --- /dev/null +++ b/src/Steam.Models/SchemaForGameResultModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models +{ + public class SchemaForGameResultModel + { + public string GameName { get; set; } + + public string GameVersion { get; set; } + + public AvailableGameStatsModel AvailableGameStats { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SchemaGameAchievementModel.cs b/src/Steam.Models/SchemaGameAchievementModel.cs new file mode 100644 index 0000000..a5c8332 --- /dev/null +++ b/src/Steam.Models/SchemaGameAchievementModel.cs @@ -0,0 +1,19 @@ +namespace Steam.Models +{ + public class SchemaGameAchievementModel + { + public string Name { get; set; } + + public ulong DefaultValue { get; set; } + + public string DisplayName { get; set; } + + public uint Hidden { get; set; } + + public string Description { get; set; } + + public string Icon { get; set; } + + public string Icongray { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SchemaGameStatModel.cs b/src/Steam.Models/SchemaGameStatModel.cs new file mode 100644 index 0000000..d992cdb --- /dev/null +++ b/src/Steam.Models/SchemaGameStatModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models +{ + public class SchemaGameStatModel + { + public string Name { get; set; } + + public ulong DefaultValue { get; set; } + + public string DisplayName { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/Steam.Models.csproj b/src/Steam.Models/Steam.Models.csproj new file mode 100644 index 0000000..1d041a6 --- /dev/null +++ b/src/Steam.Models/Steam.Models.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0;netstandard2.1 + + + diff --git a/src/Steam.Models/SteamAppModel.cs b/src/Steam.Models/SteamAppModel.cs new file mode 100644 index 0000000..9cc1f5a --- /dev/null +++ b/src/Steam.Models/SteamAppModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models +{ + public class SteamAppModel + { + public uint AppId { get; set; } + + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamAppUpToDateCheckModel.cs b/src/Steam.Models/SteamAppUpToDateCheckModel.cs new file mode 100644 index 0000000..f1d50d6 --- /dev/null +++ b/src/Steam.Models/SteamAppUpToDateCheckModel.cs @@ -0,0 +1,15 @@ +namespace Steam.Models +{ + public class SteamAppUpToDateCheckModel + { + public bool Success { get; set; } + + public bool UpToDate { get; set; } + + public bool VersionIsListable { get; set; } + + public uint RequiredVersion { get; set; } + + public string Message { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/BadgeModel.cs b/src/Steam.Models/SteamCommunity/BadgeModel.cs new file mode 100644 index 0000000..858095a --- /dev/null +++ b/src/Steam.Models/SteamCommunity/BadgeModel.cs @@ -0,0 +1,21 @@ +namespace Steam.Models.SteamCommunity +{ + public class BadgeModel + { + public uint BadgeId { get; set; } + + public uint Level { get; set; } + + public ulong CompletionTime { get; set; } + + public uint Xp { get; set; } + + public uint Scarcity { get; set; } + + public uint? AppId { get; set; } + + public string CommunityItemId { get; set; } + + public uint? BorderColor { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/BadgeQuestModel.cs b/src/Steam.Models/SteamCommunity/BadgeQuestModel.cs new file mode 100644 index 0000000..3e9d44b --- /dev/null +++ b/src/Steam.Models/SteamCommunity/BadgeQuestModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamCommunity +{ + public class BadgeQuestModel + { + public uint QuestId { get; set; } + + public bool Completed { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/BadgesResultModel.cs b/src/Steam.Models/SteamCommunity/BadgesResultModel.cs new file mode 100644 index 0000000..976fec2 --- /dev/null +++ b/src/Steam.Models/SteamCommunity/BadgesResultModel.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamCommunity +{ + public class BadgesResultModel + { + public IReadOnlyCollection Badges { get; set; } + + public uint PlayerXp { get; set; } + + public uint PlayerLevel { get; set; } + + public uint PlayerXpNeededToLevelUp { get; set; } + + public uint PlayerXpNeededCurrentLevel { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/CommentPermission.cs b/src/Steam.Models/SteamCommunity/CommentPermission.cs new file mode 100644 index 0000000..ce0c1d4 --- /dev/null +++ b/src/Steam.Models/SteamCommunity/CommentPermission.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.SteamCommunity +{ + /// + /// Indicates the selected privacy/visibility level of the player's comments section on their Steam Community profile + /// + public enum CommentPermission + { + Unknown = 0, + FriendsOnly = 1, + Private = 2, + Public = 3 + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/FriendModel.cs b/src/Steam.Models/SteamCommunity/FriendModel.cs new file mode 100644 index 0000000..71a6ae7 --- /dev/null +++ b/src/Steam.Models/SteamCommunity/FriendModel.cs @@ -0,0 +1,13 @@ +using System; + +namespace Steam.Models.SteamCommunity +{ + public class FriendModel + { + public ulong SteamId { get; set; } + + public string Relationship { get; set; } + + public DateTime FriendSince { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/GlobalAchievementPercentageModel.cs b/src/Steam.Models/SteamCommunity/GlobalAchievementPercentageModel.cs new file mode 100644 index 0000000..3bcd558 --- /dev/null +++ b/src/Steam.Models/SteamCommunity/GlobalAchievementPercentageModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamCommunity +{ + public class GlobalAchievementPercentageModel + { + public string Name { get; set; } + + public double Percent { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/GlobalStatModel.cs b/src/Steam.Models/SteamCommunity/GlobalStatModel.cs new file mode 100644 index 0000000..fde657f --- /dev/null +++ b/src/Steam.Models/SteamCommunity/GlobalStatModel.cs @@ -0,0 +1,8 @@ +namespace Steam.Models.SteamCommunity +{ + public class GlobalStatModel + { + public string Name { get; set; } + public uint Total { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/OwnedGameModel.cs b/src/Steam.Models/SteamCommunity/OwnedGameModel.cs new file mode 100644 index 0000000..5ce06fe --- /dev/null +++ b/src/Steam.Models/SteamCommunity/OwnedGameModel.cs @@ -0,0 +1,21 @@ +using System; + +namespace Steam.Models.SteamCommunity +{ + public class OwnedGameModel + { + public uint AppId { get; set; } + + public string Name { get; set; } + + public TimeSpan PlaytimeForever { get; set; } + + public string ImgIconUrl { get; set; } + + public string ImgLogoUrl { get; set; } + + public bool HasCommunityVisibleStats { get; set; } + + public TimeSpan? PlaytimeLastTwoWeeks { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/OwnedGamesResultModel.cs b/src/Steam.Models/SteamCommunity/OwnedGamesResultModel.cs new file mode 100644 index 0000000..798737f --- /dev/null +++ b/src/Steam.Models/SteamCommunity/OwnedGamesResultModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamCommunity +{ + public class OwnedGamesResultModel + { + public uint GameCount { get; set; } + + public IReadOnlyCollection OwnedGames { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/PlayerBansModel.cs b/src/Steam.Models/SteamCommunity/PlayerBansModel.cs new file mode 100644 index 0000000..85923d9 --- /dev/null +++ b/src/Steam.Models/SteamCommunity/PlayerBansModel.cs @@ -0,0 +1,19 @@ +namespace Steam.Models.SteamCommunity +{ + public class PlayerBansModel + { + public string SteamId { get; set; } + + public bool CommunityBanned { get; set; } + + public bool VACBanned { get; set; } + + public uint NumberOfVACBans { get; set; } + + public uint DaysSinceLastBan { get; set; } + + public uint NumberOfGameBans { get; set; } + + public string EconomyBan { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/PlayerSummaryModel.cs b/src/Steam.Models/SteamCommunity/PlayerSummaryModel.cs new file mode 100644 index 0000000..d49adc9 --- /dev/null +++ b/src/Steam.Models/SteamCommunity/PlayerSummaryModel.cs @@ -0,0 +1,109 @@ +using System; + +namespace Steam.Models.SteamCommunity +{ + public class PlayerSummaryModel + { + /// + /// Unique Steam ID of the player. Resolve this using ResolveVanityUrl interface method. + /// + public ulong SteamId { get; set; } + + /// + /// Determines the visibility of the user's profile (public, private, friends) + /// + public ProfileVisibility ProfileVisibility { get; set; } + + /// + /// If set to 1, the user has configured his profile. + /// + public uint ProfileState { get; set; } + + /// + /// User's current nick name (displayed in profile and friends list) + /// + public string Nickname { get; set; } + + /// + /// The date at which the user last logged off Steam + /// It's a 64-bit integer in the JSON response, so we parse it to a DateTime + /// + public DateTime LastLoggedOffDate { get; set; } + + /// + /// The selected privacy/visibility level of the player's comments section on their Steam Community profile + /// + public CommentPermission CommentPermission { get; set; } + + /// + /// The URL for the player's Steam Community profile + /// + public string ProfileUrl { get; set; } + + /// + /// The normal sized uploaded avatar image for the user's Steam profile + /// + public string AvatarUrl { get; set; } + + /// + /// The medium sized uploaded avatar image for the user's Steam profile + /// + public string AvatarMediumUrl { get; set; } + + /// + /// THe full sized uploaded avatar image for the user's Steam profile + /// + public string AvatarFullUrl { get; set; } + + /// + /// The current status of the user on the Steam network + /// + public UserStatus UserStatus { get; set; } + + /// + /// The player's real name as entered on their Steam profile + /// + public string RealName { get; set; } + + /// + /// The player's selected primary group to display on their Steam profile + /// + public string PrimaryGroupId { get; set; } + + /// + /// The date at which the user created their Steam account + /// It's a 64-bit integer in the JSON response, so we parse it to a DateTime + /// + public DateTime AccountCreatedDate { get; set; } + + /// + /// The player's selected country + /// + public string CountryCode { get; set; } + + /// + /// The player's selected state + /// + public string StateCode { get; set; } + + /// + /// The player's selected city. This seems to refer to a database city id, so I'm not sure how to make use of this field. + /// + public uint CityCode { get; set; } + + /// + /// The name of the game that a player is currently playing + /// + public string PlayingGameName { get; set; } + + /// + /// The id of the game that the player is currently playing. This doesn't seem to be an appid, so I'm not sure how to make use of this field. + /// + public string PlayingGameId { get; set; } + + /// + /// The IP of the server the user is currently playing on. + /// + public string PlayingGameServerIP { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/ProfileVisibility.cs b/src/Steam.Models/SteamCommunity/ProfileVisibility.cs new file mode 100644 index 0000000..8f431da --- /dev/null +++ b/src/Steam.Models/SteamCommunity/ProfileVisibility.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.SteamCommunity +{ + /// + /// Indicates the selected privacy/visibility level of the player's Steam Community profile + /// + public enum ProfileVisibility + { + Unknown = 0, + Private = 1, + FriendsOnly = 2, + Public = 3 + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/RecentlyPlayedGameModel.cs b/src/Steam.Models/SteamCommunity/RecentlyPlayedGameModel.cs new file mode 100644 index 0000000..08bea2b --- /dev/null +++ b/src/Steam.Models/SteamCommunity/RecentlyPlayedGameModel.cs @@ -0,0 +1,17 @@ +namespace Steam.Models.SteamCommunity +{ + public class RecentlyPlayedGameModel + { + public uint AppId { get; set; } + + public string Name { get; set; } + + public uint Playtime2Weeks { get; set; } + + public uint PlaytimeForever { get; set; } + + public string ImgIconUrl { get; set; } + + public string ImgLogoUrl { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/RecentlyPlayedGamesResultModel.cs b/src/Steam.Models/SteamCommunity/RecentlyPlayedGamesResultModel.cs new file mode 100644 index 0000000..f93a0ef --- /dev/null +++ b/src/Steam.Models/SteamCommunity/RecentlyPlayedGamesResultModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamCommunity +{ + public class RecentlyPlayedGamesResultModel + { + public uint TotalCount { get; set; } + + public IReadOnlyCollection RecentlyPlayedGames { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/SteamCommunityProfileModel.cs b/src/Steam.Models/SteamCommunity/SteamCommunityProfileModel.cs new file mode 100644 index 0000000..614154b --- /dev/null +++ b/src/Steam.Models/SteamCommunity/SteamCommunityProfileModel.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; + +namespace Steam.Models.SteamCommunity +{ + public class SteamCommunityProfileModel + { + public ulong SteamID { get; set; } + public string State { get; set; } + public string StateMessage { get; set; } + public uint VisibilityState { get; set; } // what is this? + public Uri Avatar { get; set; } + public Uri AvatarMedium { get; set; } + public Uri AvatarFull { get; set; } + public bool IsVacBanned { get; set; } + public string TradeBanState { get; set; } + public bool IsLimitedAccount { get; set; } + public string CustomURL { get; set; } + public string MemberSince { get; set; } + public double SteamRating { get; set; } + public double HoursPlayedLastTwoWeeks { get; set; } + public string Headline { get; set; } + public string Location { get; set; } + public string RealName { get; set; } + public string Summary { get; set; } + public IReadOnlyCollection MostPlayedGames { get; set; } + public string InGameServerIP { get; set; } + public InGameInfoModel InGameInfo { get; set; } + } + + public class SteamCommunityProfileMostPlayedGameModel + { + public string Name { get; set; } + public Uri Link { get; set; } + public Uri Icon { get; set; } + public Uri Logo { get; set; } + public Uri LogoSmall { get; set; } + public double HoursPlayed { get; set; } + public double HoursOnRecord { get; set; } + public string StatsName { get; set; } + } + + public class InGameInfoModel + { + public string GameName { get; set; } + public string GameLink { get; set; } + public string GameIcon { get; set; } + public string GameLogo { get; set; } + public string GameLogoSmall { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamCommunity/UserStatus.cs b/src/Steam.Models/SteamCommunity/UserStatus.cs new file mode 100644 index 0000000..d3a50cc --- /dev/null +++ b/src/Steam.Models/SteamCommunity/UserStatus.cs @@ -0,0 +1,16 @@ +namespace Steam.Models.SteamCommunity +{ + /// + /// Indicates the current status of the user on the Steam network + /// + public enum UserStatus + { + Offline = 0, + Online = 1, + Busy = 2, + Away = 3, + Snooze = 4, + Unknown = 5, + InGame = 6 + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetClassActionModel.cs b/src/Steam.Models/SteamEconomy/AssetClassActionModel.cs new file mode 100644 index 0000000..279951b --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetClassActionModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamEconomy +{ + public class AssetClassActionModel + { + public string Name { get; set; } + + public string Link { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetClassAppDataFilterModel.cs b/src/Steam.Models/SteamEconomy/AssetClassAppDataFilterModel.cs new file mode 100644 index 0000000..99ea650 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetClassAppDataFilterModel.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class AssetClassAppDataFilterModel + { + public IReadOnlyCollection ElementIds { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetClassAppDataModel.cs b/src/Steam.Models/SteamEconomy/AssetClassAppDataModel.cs new file mode 100644 index 0000000..a6863a8 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetClassAppDataModel.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class AssetClassAppDataModel + { + public uint DefIndex { get; set; } + + public string Quality { get; set; } + + public string Slot { get; set; } + + public IReadOnlyCollection FilterData { get; set; } + + public IReadOnlyCollection PlayerClassIds { get; set; } + + public string HighlightColor { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetClassDescriptionModel.cs b/src/Steam.Models/SteamEconomy/AssetClassDescriptionModel.cs new file mode 100644 index 0000000..635e7f4 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetClassDescriptionModel.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.SteamEconomy +{ + public class AssetClassDescriptionModel + { + public string Type { get; set; } + + public string Value { get; set; } + + public string Color { get; set; } + + public string AppData { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetClassInfoModel.cs b/src/Steam.Models/SteamEconomy/AssetClassInfoModel.cs new file mode 100644 index 0000000..e23ec46 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetClassInfoModel.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class AssetClassInfoModel + { + public string IconUrl { get; set; } + + public string IconUrlLarge { get; set; } + + public string IconDragUrl { get; set; } + + public string Name { get; set; } + + public string MarketHashName { get; set; } + + public string MarketName { get; set; } + + public string NameColor { get; set; } + + public string BackgroundColor { get; set; } + + public string Type { get; set; } + + public string Tradable { get; set; } + + public string Marketable { get; set; } + + public string Commodity { get; set; } + + public string MarketTradableRestriction { get; set; } + + public string MarketMarketableRestriction { get; set; } + + public string FraudWarnings { get; set; } + + public IReadOnlyCollection Descriptions { get; set; } + + public IReadOnlyCollection Actions { get; set; } + + public IReadOnlyCollection MarketActions { get; set; } + + public IReadOnlyCollection Tags { get; set; } + + public AssetClassAppDataModel AppData { get; set; } + + public ulong ClassId { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetClassInfoResultModel.cs b/src/Steam.Models/SteamEconomy/AssetClassInfoResultModel.cs new file mode 100644 index 0000000..18979fd --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetClassInfoResultModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class AssetClassInfoResultModel + { + public IReadOnlyCollection AssetClasses { get; set; } + + public bool Success { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetClassMarketActionModel.cs b/src/Steam.Models/SteamEconomy/AssetClassMarketActionModel.cs new file mode 100644 index 0000000..a6cc129 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetClassMarketActionModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamEconomy +{ + public class AssetClassMarketActionModel + { + public string Name { get; set; } + + public string Link { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetClassModel.cs b/src/Steam.Models/SteamEconomy/AssetClassModel.cs new file mode 100644 index 0000000..e527bef --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetClassModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamEconomy +{ + public class AssetClassModel + { + public string Name { get; set; } + + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetClassTagModel.cs b/src/Steam.Models/SteamEconomy/AssetClassTagModel.cs new file mode 100644 index 0000000..0b2721c --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetClassTagModel.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.SteamEconomy +{ + public class AssetClassTagModel + { + public string InternalName { get; set; } + + public string Name { get; set; } + + public string Category { get; set; } + + public string Color { get; set; } + + public string CategoryName { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetModel.cs b/src/Steam.Models/SteamEconomy/AssetModel.cs new file mode 100644 index 0000000..ecbc608 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetModel.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class AssetModel + { + public AssetPricesModel Prices { get; set; } + + public string Name { get; set; } + + public string Date { get; set; } + + public IReadOnlyCollection Class { get; set; } + + public ulong ClassId { get; set; } + + public IReadOnlyCollection Tags { get; set; } + + public IReadOnlyCollection TagIds { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetPriceResultModel.cs b/src/Steam.Models/SteamEconomy/AssetPriceResultModel.cs new file mode 100644 index 0000000..323cbfa --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetPriceResultModel.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class AssetPriceResultModel + { + public bool Success { get; set; } + + public IReadOnlyCollection Assets { get; set; } + + public AssetTagsModel Tags { get; set; } + + public AssetTagIdsModel TagIds { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetPricesModel.cs b/src/Steam.Models/SteamEconomy/AssetPricesModel.cs new file mode 100644 index 0000000..564adf4 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetPricesModel.cs @@ -0,0 +1,59 @@ +namespace Steam.Models.SteamEconomy +{ + public class AssetPricesModel + { + public uint USD { get; set; } + + public uint GBP { get; set; } + + public uint EUR { get; set; } + + public uint RUB { get; set; } + + public uint BRL { get; set; } + + public uint JPY { get; set; } + + public uint NOK { get; set; } + + public uint IDR { get; set; } + + public uint MYR { get; set; } + + public uint PHP { get; set; } + + public uint SGD { get; set; } + + public uint THB { get; set; } + + public uint VND { get; set; } + + public uint KRW { get; set; } + + public uint TRY { get; set; } + + public uint UAH { get; set; } + + public uint MXN { get; set; } + + public uint CAD { get; set; } + + public uint AUD { get; set; } + + public uint NZD { get; set; } + + public uint CNY { get; set; } + + public uint TWD { get; set; } + + public uint HKD { get; set; } + + public uint INR { get; set; } + + public uint AED { get; set; } + + public uint SAR { get; set; } + + public uint ZAR { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetTagIdsModel.cs b/src/Steam.Models/SteamEconomy/AssetTagIdsModel.cs new file mode 100644 index 0000000..64719ae --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetTagIdsModel.cs @@ -0,0 +1,23 @@ +namespace Steam.Models.SteamEconomy +{ + public class AssetTagIdsModel + { + public ulong Tag0 { get; set; } + + public ulong Tag1 { get; set; } + + public ulong Tag2 { get; set; } + + public ulong Tag3 { get; set; } + + public ulong Tag4 { get; set; } + + public ulong Tag5 { get; set; } + + public ulong Tag6 { get; set; } + + public ulong Tag7 { get; set; } + + public ulong Tag8 { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/AssetTagsModel.cs b/src/Steam.Models/SteamEconomy/AssetTagsModel.cs new file mode 100644 index 0000000..a18e1c2 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/AssetTagsModel.cs @@ -0,0 +1,23 @@ +namespace Steam.Models.SteamEconomy +{ + public class AssetTagsModel + { + public string Cosmetics { get; set; } + + public string Tools { get; set; } + + public string Weapons { get; set; } + + public string Taunts { get; set; } + + public string Bundles { get; set; } + + public string Limited { get; set; } + + public string New { get; set; } + + public string Maps { get; set; } + + public string Halloween { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeAssetModel.cs b/src/Steam.Models/SteamEconomy/TradeAssetModel.cs new file mode 100644 index 0000000..6c5ad9e --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeAssetModel.cs @@ -0,0 +1,39 @@ +namespace Steam.Models.SteamEconomy +{ + public class TradeAssetModel + { + public uint AppId { get; set; } + + public uint ContextId { get; set; } + + /// + /// Either assetid or currencyid will be set + /// + public ulong AssetId { get; set; } + + /// + /// Either assetid or currencyid will be set + /// + public ulong CurrencyId { get; set; } + + /// + /// Together with instanceid, uniquely identifies the display of the item + /// + public uint ClassId { get; set; } + + /// + /// Together with classid, uniquely identifies the display of the item + /// + public uint InstanceId { get; set; } + + /// + /// The amount offered in the trade, for stackable items and currency + /// + public uint AmountOffered { get; set; } + + /// + /// A boolean that indicates the item is no longer present in the user's inventory + /// + public bool IsMissing { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeHistoryModel.cs b/src/Steam.Models/SteamEconomy/TradeHistoryModel.cs new file mode 100644 index 0000000..d59fd8f --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeHistoryModel.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class TradeHistoryModel + { + /// + /// Total number of trades performed by the account + /// + public uint TotalTradeCount { get; set; } + + /// + /// Whether or not more are available + /// + public bool AreMoreAvailable { get; set; } + + /// + /// Array of CEcon_GetTradeHistory_Response_Trade + /// + public IList Trades { get; set; } + + /// + /// If get_descriptions was set, this will be a list of item display information. This is associated with the data in the assets/currency_received and assets/currency_given lists via the classid / instanceid identifier pair. + /// + public IList Descriptions { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeHoldDurationsModel.cs b/src/Steam.Models/SteamEconomy/TradeHoldDurationsModel.cs new file mode 100644 index 0000000..f64fb79 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeHoldDurationsModel.cs @@ -0,0 +1,11 @@ +using System; + +namespace Steam.Models.SteamEconomy +{ + public class TradeHoldDurationsModel + { + public TimeSpan EscrowEndDuration { get; set; } + + public DateTime EscrowEndDate { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeHoldDurationsResultModel.cs b/src/Steam.Models/SteamEconomy/TradeHoldDurationsResultModel.cs new file mode 100644 index 0000000..f61a809 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeHoldDurationsResultModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.SteamEconomy +{ + public class TradeHoldDurationsResultModel + { + public TradeHoldDurationsModel MyEscrow { get; set; } + + public TradeHoldDurationsModel TheirEscrow { get; set; } + + public TradeHoldDurationsModel BothEscrow { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeModel.cs b/src/Steam.Models/SteamEconomy/TradeModel.cs new file mode 100644 index 0000000..a0d419c --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeModel.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class TradeModel + { + /// + /// A unique identifier for the trade + /// + public ulong TradeId { get; set; } + + /// + /// The SteamID of your trade partner + /// + public ulong TradeParterSteamId { get; set; } + + /// + /// Unix timestamp of the time the trade started to commit + /// + public DateTime TimeTradeStarted { get; set; } + + /// + /// Unix timestamp of the time the trade will leave escrow + /// + public DateTime TimeEscrowEnds { get; set; } + + /// + /// Status of the Trade + /// + public TradeStatus TradeStatus { get; set; } + + /// + /// Array of CEcon_GetTradeHistory_Response_Trade_TradedAsset showing the items received in the trade + /// + public IList AssetsReceived { get; set; } + + /// + /// Array of CEcon_GetTradeHistory_Response_Trade_TradedAsset showing the items given to the other party in the trade + /// + public IList AssetsGiven { get; set; } + + /// + /// Array of CEcon_GetTradeHistory_Response_Trade_TradedCurrency showing the items received in the trade + /// + public IList CurrencyReceived { get; set; } + + /// + /// array of CEcon_GetTradeHistory_Response_Trade_TradedCurrency showing the items given to the other party in the trade + /// + public IList CurrencyGiven { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeOfferConfirmationMethod.cs b/src/Steam.Models/SteamEconomy/TradeOfferConfirmationMethod.cs new file mode 100644 index 0000000..72cb48c --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeOfferConfirmationMethod.cs @@ -0,0 +1,12 @@ +namespace Steam.Models.SteamEconomy +{ + /// + /// These are the different methods in which a trade offer can be confirmed. + /// + public enum TradeOfferConfirmationMethod + { + Invalid = 0, + Email = 1, + MobileApp = 2 + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeOfferModel.cs b/src/Steam.Models/SteamEconomy/TradeOfferModel.cs new file mode 100644 index 0000000..069dba4 --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeOfferModel.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class TradeOfferModel + { + /// + /// A unique identifier for the trade offer + /// + public uint TradeOfferId { get; set; } + + /// + /// Your partner in the trade offer + /// + public ulong TradePartnerSteamId { get; set; } + + /// + /// A message included by the creator of the trade offer + /// + public string Message { get; set; } + + /// + /// Unix time when the offer will expire (or expired, if it is in the past) + /// + public DateTime TimeExpiration { get; set; } + + /// + /// State of the Trade Offer + /// + public TradeOfferState TradeOfferState { get; set; } + + /// + /// Array of CEcon_Asset, items you will give up in the trade (regardless of who created the offer) + /// + public IList ItemsYouWillGive { get; set; } + + /// + /// Array of CEcon_Asset, items you will receive in the trade (regardless of who created the offer) + /// + public IList ItemsYouWillReceive { get; set; } + + /// + /// Boolean to indicate this is an offer you created. + /// + public bool IsOfferYouCreated { get; set; } + + /// + /// Unix timestamp of the time the offer was sent + /// + public DateTime TimeCreated { get; set; } + + /// + /// Unix timestamp of the time the trade_offer_state last changed. + /// + public DateTime TimeUpdated { get; set; } + + /// + /// Boolean to indicate this is an offer automatically created from a real-time trade. + /// + public bool WasCreatedFromRealTimeTrade { get; set; } + + /// + /// Unix timestamp of when the trade hold period is supposed to be over for this trade offer + /// + public DateTime TimeEscrowEnds { get; set; } + + /// + /// The confirmation method that applies to the user asking about the offer. + /// + public TradeOfferConfirmationMethod ConfirmationMethod { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeOfferResultModel.cs b/src/Steam.Models/SteamEconomy/TradeOfferResultModel.cs new file mode 100644 index 0000000..29a04ec --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeOfferResultModel.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class TradeOfferResultModel + { + /// + /// A CEcon_TradeOffer representing the offer + /// + public TradeOfferModel TradeOffer { get; set; } + + /// + /// If language was set, this will be a list of item display information. This is associated with the data in the items_to_receive and items_to_give lists via the classid / instanceid identifier pair. + /// + public IList Descriptions { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeOfferState.cs b/src/Steam.Models/SteamEconomy/TradeOfferState.cs new file mode 100644 index 0000000..b5e77bb --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeOfferState.cs @@ -0,0 +1,20 @@ +namespace Steam.Models.SteamEconomy +{ + /// + /// These are the different states for a trade offer. + /// + public enum TradeOfferState + { + Invalid = 1, + Active = 2, + Accepted = 3, + Countered = 4, + Expired = 5, + Canceled = 6, + Declined = 7, + InvalidItems = 8, + CreateNeedsConfirmation = 9, + CanceledBySecondFactor = 10, + InEscrow = 11 + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeOffersResultModel.cs b/src/Steam.Models/SteamEconomy/TradeOffersResultModel.cs new file mode 100644 index 0000000..0a25efb --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeOffersResultModel.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamEconomy +{ + public class TradeOffersResultModel + { + /// + /// If get_sent_offers was set, this will be an array of CEcon_TradeOffer values that you have sent. + /// + public IList TradeOffersSent { get; set; } + + /// + /// If get_received_offers was set, this will be an array of CEcon_TradeOffer values that have been sent to you. + /// + public IList TradeOffersReceived { get; set; } + + /// + /// If get_descriptions was set, this will be a list of item display information. This is associated with the data in the items_to_receive and items_to_give lists via the classid / instanceid identifier pair. + /// + public IList Descriptions { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradeStatus.cs b/src/Steam.Models/SteamEconomy/TradeStatus.cs new file mode 100644 index 0000000..d0d62ad --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradeStatus.cs @@ -0,0 +1,21 @@ +namespace Steam.Models.SteamEconomy +{ + /// + /// Tracks the status of a trade after a trade offer has been accepted. + /// + public enum TradeStatus + { + Init = 0, + PreCommitted = 1, + Committed = 2, + Complete = 3, + Failed = 4, + PartialSupportRollback = 5, + FullSupportRollback = 6, + SupportRollbackSelective = 7, + RollbackFailed = 8, + RollbackAbandoned = 9, + InEscrow = 10, + EscrowRollback = 11 + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradedAssetModel.cs b/src/Steam.Models/SteamEconomy/TradedAssetModel.cs new file mode 100644 index 0000000..5bb397d --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradedAssetModel.cs @@ -0,0 +1,43 @@ +namespace Steam.Models.SteamEconomy +{ + public class TradedAssetModel + { + public uint AppId { get; set; } + + public uint ContextId { get; set; } + + public ulong AssetId { get; set; } + + public uint AmountTraded { get; set; } + + /// + /// Together with instanceid, uniquely identifies the display of the item + /// + public uint ClassId { get; set; } + + /// + /// Together with classid, uniquely identifies the display of the item + /// + public uint InstanceId { get; set; } + + /// + /// The asset ID given to the item after the trade completed + /// + public ulong AssetIdAfterTrade { get; set; } + + /// + /// The context ID the item was placed in + /// + public ulong ContextIdAfterTrade { get; set; } + + /// + /// If the trade has been rolled back, the new asset ID given in the rollback + /// + public ulong AssetIdAfterRollback { get; set; } + + /// + /// If the trade has been rolled back, the context ID the new asset was placed in + /// + public ulong ContextIdAfterRollback { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamEconomy/TradedCurrencyModel.cs b/src/Steam.Models/SteamEconomy/TradedCurrencyModel.cs new file mode 100644 index 0000000..c3377fe --- /dev/null +++ b/src/Steam.Models/SteamEconomy/TradedCurrencyModel.cs @@ -0,0 +1,35 @@ +namespace Steam.Models.SteamEconomy +{ + public class TradedCurrencyModel + { + public uint AppId { get; set; } + + public uint ContextId { get; set; } + + public uint CurrencyId { get; set; } + + public uint AmountTraded { get; set; } + + public uint ClassId { get; set; } + + /// + /// The currency ID given after the trade completed + /// + public ulong CurrencyIdAfterTrade { get; set; } + + /// + /// The context ID the currency was placed in + /// + public uint ContextIdAfterTrade { get; set; } + + /// + /// If the trade has been rolled back, the new currency ID given in the rollback + /// + public ulong CurrencyIdAfterRollback { get; set; } + + /// + /// If the trade has been rolled back, the context ID the new asset was placed in + /// + public uint ContextIdAfterRollback { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamInterfaceModel.cs b/src/Steam.Models/SteamInterfaceModel.cs new file mode 100644 index 0000000..ae02e0e --- /dev/null +++ b/src/Steam.Models/SteamInterfaceModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models +{ + public class SteamInterfaceModel + { + public string Name { get; set; } + + public IReadOnlyCollection Methods { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamMethodModel.cs b/src/Steam.Models/SteamMethodModel.cs new file mode 100644 index 0000000..68c7135 --- /dev/null +++ b/src/Steam.Models/SteamMethodModel.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace Steam.Models +{ + public class SteamMethodModel + { + public string Name { get; set; } + + public uint Version { get; set; } + + public string HttpMethod { get; set; } + + public string Description { get; set; } + + public IReadOnlyCollection Parameters { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamNewsResultModel.cs b/src/Steam.Models/SteamNewsResultModel.cs new file mode 100644 index 0000000..a0c414f --- /dev/null +++ b/src/Steam.Models/SteamNewsResultModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models +{ + public class SteamNewsResultModel + { + public uint AppId { get; set; } + + public IReadOnlyCollection NewsItems { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamParameterModel.cs b/src/Steam.Models/SteamParameterModel.cs new file mode 100644 index 0000000..532252c --- /dev/null +++ b/src/Steam.Models/SteamParameterModel.cs @@ -0,0 +1,13 @@ +namespace Steam.Models +{ + public class SteamParameterModel + { + public string Name { get; set; } + + public string Type { get; set; } + + public bool IsOptional { get; set; } + + public string Description { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamPlayer/PlayerAchievementModel.cs b/src/Steam.Models/SteamPlayer/PlayerAchievementModel.cs new file mode 100644 index 0000000..e95df91 --- /dev/null +++ b/src/Steam.Models/SteamPlayer/PlayerAchievementModel.cs @@ -0,0 +1,17 @@ +using System; + +namespace Steam.Models.SteamPlayer +{ + public class PlayerAchievementModel + { + public string APIName { get; set; } + + public uint Achieved { get; set; } + + public DateTime UnlockTime { get; set; } + + public string Name { get; set; } + + public string Description { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamPlayer/PlayerAchievementResultModel.cs b/src/Steam.Models/SteamPlayer/PlayerAchievementResultModel.cs new file mode 100644 index 0000000..637c194 --- /dev/null +++ b/src/Steam.Models/SteamPlayer/PlayerAchievementResultModel.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamPlayer +{ + public class PlayerAchievementResultModel + { + public ulong SteamId { get; set; } + + public string GameName { get; set; } + + public IReadOnlyCollection Achievements { get; set; } + + public bool Success { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamPlayer/UserStatAchievementModel.cs b/src/Steam.Models/SteamPlayer/UserStatAchievementModel.cs new file mode 100644 index 0000000..be07bbf --- /dev/null +++ b/src/Steam.Models/SteamPlayer/UserStatAchievementModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamPlayer +{ + public class UserStatAchievementModel + { + public string Name { get; set; } + + public uint Achieved { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamPlayer/UserStatModel.cs b/src/Steam.Models/SteamPlayer/UserStatModel.cs new file mode 100644 index 0000000..82ce789 --- /dev/null +++ b/src/Steam.Models/SteamPlayer/UserStatModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamPlayer +{ + public class UserStatModel + { + public string Name { get; set; } + + public double Value { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamPlayer/UserStatsForGameResultModel.cs b/src/Steam.Models/SteamPlayer/UserStatsForGameResultModel.cs new file mode 100644 index 0000000..75e7dce --- /dev/null +++ b/src/Steam.Models/SteamPlayer/UserStatsForGameResultModel.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace Steam.Models.SteamPlayer +{ + public class UserStatsForGameResultModel + { + public ulong SteamId { get; set; } + + public string GameName { get; set; } + + public IReadOnlyCollection Stats { get; set; } + + public IReadOnlyCollection Achievements { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamServerInfo.cs b/src/Steam.Models/SteamServerInfo.cs new file mode 100644 index 0000000..54abc56 --- /dev/null +++ b/src/Steam.Models/SteamServerInfo.cs @@ -0,0 +1,12 @@ +using Steam.Models.Utilities; +using System; + +namespace Steam.Models +{ + public class SteamServerInfo + { + public ulong ServerTime { get; set; } + public string ServerTimeString { get; set; } + public DateTime ServerTimeDateTime { get { return ServerTime.ToDateTime(); } } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamServerInfoModel.cs b/src/Steam.Models/SteamServerInfoModel.cs new file mode 100644 index 0000000..46fec9a --- /dev/null +++ b/src/Steam.Models/SteamServerInfoModel.cs @@ -0,0 +1,12 @@ +using Steam.Models.Utilities; +using System; + +namespace Steam.Models +{ + public class SteamServerInfoModel + { + public ulong ServerTime { get; set; } + public string ServerTimeString { get; set; } + public DateTime ServerTimeDateTime { get { return ServerTime.ToDateTime(); } } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamStore/StoreAchievement.cs b/src/Steam.Models/SteamStore/StoreAchievement.cs new file mode 100644 index 0000000..6e2ce67 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreAchievement.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreAchievement + { + public uint Total { get; set; } + + public StoreHighlighted[] Highlighted { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamStore/StoreAppDetailsDataModel.cs b/src/Steam.Models/SteamStore/StoreAppDetailsDataModel.cs new file mode 100644 index 0000000..470a6c8 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreAppDetailsDataModel.cs @@ -0,0 +1,71 @@ +namespace Steam.Models.SteamStore +{ + public class StoreAppDetailsDataModel + { + public string Type { get; set; } + + public string Name { get; set; } + + public uint SteamAppId { get; set; } + + public uint RequiredAge { get; set; } + + public string ControllerSupport { get; set; } + + public bool IsFree { get; set; } + + public uint[] Dlc { get; set; } + + public string DetailedDescription { get; set; } + + public string AboutTheGame { get; set; } + + public string ShortDescription { get; set; } + + public string SupportedLanguages { get; set; } + + public string HeaderImage { get; set; } + + public string Website { get; set; } + + public dynamic PcRequirements { get; set; } + + public dynamic MacRequirements { get; set; } + + public dynamic LinuxRequirements { get; set; } + + public string[] Developers { get; set; } + + public string[] Publishers { get; set; } + + public StorePriceOverview PriceOverview { get; set; } + + public string[] Packages { get; set; } + + public StorePackageGroupModel[] PackageGroups { get; set; } + + public StorePlatformsModel Platforms { get; set; } + + public StoreMetacriticModel Metacritic { get; set; } + + public StoreCategoryModel[] Categories { get; set; } + + public StoreGenreModel[] Genres { get; set; } + + public StoreScreenshotModel[] Screenshots { get; set; } + + public StoreMovieModel[] Movies { get; set; } + + public StoreRecommendationsModel Recommendations { get; set; } + + public StoreAchievement Achievements { get; set; } + + public StoreReleaseDateModel ReleaseDate { get; set; } + + public StoreSupportInfoModel SupportInfo { get; set; } + + public string Background { get; set; } + + public StoreContentDescriptor ContentDescriptors { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreCategoryModel.cs b/src/Steam.Models/SteamStore/StoreCategoryModel.cs new file mode 100644 index 0000000..63c3500 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreCategoryModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreCategoryModel + { + public uint Id { get; set; } + + public string Description { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreComingSoonModel.cs b/src/Steam.Models/SteamStore/StoreComingSoonModel.cs new file mode 100644 index 0000000..921084a --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreComingSoonModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.SteamStore +{ + public class StoreComingSoonModel + { + public uint Id { get; set; } + + public string Name { get; set; } + + public StoreItemModel[] Items { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreContentDescriptor.cs b/src/Steam.Models/SteamStore/StoreContentDescriptor.cs new file mode 100644 index 0000000..2574c03 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreContentDescriptor.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreContentDescriptor + { + public uint[] Ids { get; set; } + + public string Notes { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamStore/StoreFeaturedCategoriesModel.cs b/src/Steam.Models/SteamStore/StoreFeaturedCategoriesModel.cs new file mode 100644 index 0000000..f161908 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreFeaturedCategoriesModel.cs @@ -0,0 +1,19 @@ +namespace Steam.Models.SteamStore +{ + public class StoreFeaturedCategoriesModel + { + public StoreSpecialsModel Specials { get; set; } + + public StoreComingSoonModel ComingSoon { get; set; } + + public StoreTopSellersModel TopSellers { get; set; } + + public StoreNewReleasesModel NewReleases { get; set; } + + public StoreFeaturedCategoryGenreModel Genres { get; set; } + + public StoreTrailerSlideshowModel Trailerslideshow { get; set; } + + public uint Status { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreFeaturedCategoryGenreModel.cs b/src/Steam.Models/SteamStore/StoreFeaturedCategoryGenreModel.cs new file mode 100644 index 0000000..ee4cd66 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreFeaturedCategoryGenreModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreFeaturedCategoryGenreModel + { + public uint Id { get; set; } + + public string Name { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreFeaturedLinuxModel.cs b/src/Steam.Models/SteamStore/StoreFeaturedLinuxModel.cs new file mode 100644 index 0000000..7d66a96 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreFeaturedLinuxModel.cs @@ -0,0 +1,37 @@ +namespace Steam.Models.SteamStore +{ + public class StoreFeaturedLinuxModel + { + public uint Id { get; set; } + + public uint Type { get; set; } + + public string Name { get; set; } + + public bool Discounted { get; set; } + + public uint DiscountPercent { get; set; } + + public uint? OriginalPrice { get; set; } + + public uint FinalPrice { get; set; } + + public string Currency { get; set; } + + public string LargeCapsuleImage { get; set; } + + public string SmallCapsuleImage { get; set; } + + public bool WindowsAvailable { get; set; } + + public bool MacAvailable { get; set; } + + public bool LinuxAvailable { get; set; } + + public bool StreamingvideoAvailable { get; set; } + + public string HeaderImage { get; set; } + + public string ControllerSupport { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreFeaturedMacModel.cs b/src/Steam.Models/SteamStore/StoreFeaturedMacModel.cs new file mode 100644 index 0000000..acd2c8d --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreFeaturedMacModel.cs @@ -0,0 +1,37 @@ +namespace Steam.Models.SteamStore +{ + public class StoreFeaturedMacModel + { + public uint Id { get; set; } + + public uint Type { get; set; } + + public string Name { get; set; } + + public bool Discounted { get; set; } + + public uint DiscountPercent { get; set; } + + public uint? OriginalPrice { get; set; } + + public uint FinalPrice { get; set; } + + public string Currency { get; set; } + + public string LargeCapsuleImage { get; set; } + + public string SmallCapsuleImage { get; set; } + + public bool WindowsAvailable { get; set; } + + public bool MacAvailable { get; set; } + + public bool LinuxAvailable { get; set; } + + public bool StreamingvideoAvailable { get; set; } + + public string HeaderImage { get; set; } + + public string ControllerSupport { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreFeaturedProductsModel.cs b/src/Steam.Models/SteamStore/StoreFeaturedProductsModel.cs new file mode 100644 index 0000000..4a38ee9 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreFeaturedProductsModel.cs @@ -0,0 +1,17 @@ +namespace Steam.Models.SteamStore +{ + public class StoreFeaturedProductsModel + { + public StoreLargeCapsuleModel[] LargeCapsules { get; set; } + + public StoreFeaturedWinModel[] FeaturedWin { get; set; } + + public StoreFeaturedMacModel[] FeaturedMac { get; set; } + + public StoreFeaturedLinuxModel[] FeaturedLinux { get; set; } + + public string Layout { get; set; } + + public uint Status { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreFeaturedWinModel.cs b/src/Steam.Models/SteamStore/StoreFeaturedWinModel.cs new file mode 100644 index 0000000..880b25c --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreFeaturedWinModel.cs @@ -0,0 +1,39 @@ +namespace Steam.Models.SteamStore +{ + public class StoreFeaturedWinModel + { + public uint Id { get; set; } + + public uint Type { get; set; } + + public string Name { get; set; } + + public bool Discounted { get; set; } + + public uint DiscountPercent { get; set; } + + public uint? OriginalPrice { get; set; } + + public uint FinalPrice { get; set; } + + public string Currency { get; set; } + + public string LargeCapsuleImage { get; set; } + + public string SmallCapsuleImage { get; set; } + + public bool WindowsAvailable { get; set; } + + public bool MacAvailable { get; set; } + + public bool LinuxAvailable { get; set; } + + public bool StreamingvideoAvailable { get; set; } + + public string HeaderImage { get; set; } + + public string ControllerSupport { get; set; } + + public uint? DiscountExpiration { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreGenreModel.cs b/src/Steam.Models/SteamStore/StoreGenreModel.cs new file mode 100644 index 0000000..d59ab91 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreGenreModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreGenreModel + { + public uint Id { get; set; } + + public string Description { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreHighlighted.cs b/src/Steam.Models/SteamStore/StoreHighlighted.cs new file mode 100644 index 0000000..b12f40f --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreHighlighted.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreHighlighted + { + public string Name { get; set; } + + public string Path { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamStore/StoreItemModel.cs b/src/Steam.Models/SteamStore/StoreItemModel.cs new file mode 100644 index 0000000..9c176a5 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreItemModel.cs @@ -0,0 +1,41 @@ +namespace Steam.Models.SteamStore +{ + public class StoreItemModel + { + public uint Id { get; set; } + + public uint Type { get; set; } + + public string Name { get; set; } + + public bool Discounted { get; set; } + + public uint DiscountPercent { get; set; } + + public uint? OriginalPrice { get; set; } + + public uint FinalPrice { get; set; } + + public string Currency { get; set; } + + public string LargeCapsuleImage { get; set; } + + public string SmallCapsuleImage { get; set; } + + public bool WindowsAvailable { get; set; } + + public bool MacAvailable { get; set; } + + public bool LinuxAvailable { get; set; } + + public bool StreamingvideoAvailable { get; set; } + + public uint DiscountExpiration { get; set; } + + public string HeaderImage { get; set; } + + public string Body { get; set; } + + public string Url { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreLargeCapsuleModel.cs b/src/Steam.Models/SteamStore/StoreLargeCapsuleModel.cs new file mode 100644 index 0000000..e9b0190 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreLargeCapsuleModel.cs @@ -0,0 +1,39 @@ +namespace Steam.Models.SteamStore +{ + public class StoreLargeCapsuleModel + { + public uint Id { get; set; } + + public uint Type { get; set; } + + public string Name { get; set; } + + public bool Discounted { get; set; } + + public uint DiscountPercent { get; set; } + + public uint? OriginalPrice { get; set; } + + public uint FinalPrice { get; set; } + + public string Currency { get; set; } + + public string LargeCapsuleImage { get; set; } + + public string SmallCapsuleImage { get; set; } + + public bool WindowsAvailable { get; set; } + + public bool MacAvailable { get; set; } + + public bool LinuxAvailable { get; set; } + + public bool StreamingvideoAvailable { get; set; } + + public string HeaderImage { get; set; } + + public string ControllerSupport { get; set; } + + public string Headline { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreMetacriticModel.cs b/src/Steam.Models/SteamStore/StoreMetacriticModel.cs new file mode 100644 index 0000000..724cd6e --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreMetacriticModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreMetacriticModel + { + public uint Score { get; set; } + + public string Url { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreMovieModel.cs b/src/Steam.Models/SteamStore/StoreMovieModel.cs new file mode 100644 index 0000000..6937422 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreMovieModel.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.SteamStore +{ + public class StoreMovieModel + { + public uint Id { get; set; } + + public string Name { get; set; } + + public string Thumbnail { get; set; } + + public StoreWebmModel Webm { get; set; } + + public bool Highlight { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreNewReleasesModel.cs b/src/Steam.Models/SteamStore/StoreNewReleasesModel.cs new file mode 100644 index 0000000..920f283 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreNewReleasesModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.SteamStore +{ + public class StoreNewReleasesModel + { + public uint Id { get; set; } + + public string Name { get; set; } + + public StoreItemModel[] Items { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StorePackageGroupModel.cs b/src/Steam.Models/SteamStore/StorePackageGroupModel.cs new file mode 100644 index 0000000..fb14814 --- /dev/null +++ b/src/Steam.Models/SteamStore/StorePackageGroupModel.cs @@ -0,0 +1,21 @@ +namespace Steam.Models.SteamStore +{ + public class StorePackageGroupModel + { + public string Name { get; set; } + + public string Title { get; set; } + + public string Description { get; set; } + + public string SelectionText { get; set; } + + public string SaveText { get; set; } + + public uint DisplayType { get; set; } + + public string IsRecurringSubscription { get; set; } + + public StoreSubModel[] Subs { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StorePlatformsModel.cs b/src/Steam.Models/SteamStore/StorePlatformsModel.cs new file mode 100644 index 0000000..b732926 --- /dev/null +++ b/src/Steam.Models/SteamStore/StorePlatformsModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.SteamStore +{ + public class StorePlatformsModel + { + public bool Windows { get; set; } + + public bool Mac { get; set; } + + public bool Linux { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StorePriceOverview.cs b/src/Steam.Models/SteamStore/StorePriceOverview.cs new file mode 100644 index 0000000..94b29ff --- /dev/null +++ b/src/Steam.Models/SteamStore/StorePriceOverview.cs @@ -0,0 +1,17 @@ +namespace Steam.Models.SteamStore +{ + public class StorePriceOverview + { + public string Currency { get; set; } + + public uint Initial { get; set; } + + public uint Final { get; set; } + + public uint DiscountPercent { get; set; } + + public string InitialFormatted { get; set; } + + public string FinalFormatted { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreRecommendationsModel.cs b/src/Steam.Models/SteamStore/StoreRecommendationsModel.cs new file mode 100644 index 0000000..c03435c --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreRecommendationsModel.cs @@ -0,0 +1,7 @@ +namespace Steam.Models.SteamStore +{ + public class StoreRecommendationsModel + { + public uint Total { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreReleaseDateModel.cs b/src/Steam.Models/SteamStore/StoreReleaseDateModel.cs new file mode 100644 index 0000000..ae9348f --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreReleaseDateModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreReleaseDateModel + { + public bool ComingSoon { get; set; } + + public string Date { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreScreenshotModel.cs b/src/Steam.Models/SteamStore/StoreScreenshotModel.cs new file mode 100644 index 0000000..f8eaa78 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreScreenshotModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.SteamStore +{ + public class StoreScreenshotModel + { + public uint Id { get; set; } + + public string PathThumbnail { get; set; } + + public string PathFull { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreSpecialsModel.cs b/src/Steam.Models/SteamStore/StoreSpecialsModel.cs new file mode 100644 index 0000000..0b3a748 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreSpecialsModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.SteamStore +{ + public class StoreSpecialsModel + { + public uint Id { get; set; } + + public string Name { get; set; } + + public StoreItemModel[] Items { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreSubModel.cs b/src/Steam.Models/SteamStore/StoreSubModel.cs new file mode 100644 index 0000000..57da535 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreSubModel.cs @@ -0,0 +1,21 @@ +namespace Steam.Models.SteamStore +{ + public class StoreSubModel + { + public uint PackageId { get; set; } + + public string PercentSavingsText { get; set; } + + public uint PercentSavings { get; set; } + + public string OptionText { get; set; } + + public string OptionDescription { get; set; } + + public string CanGetFreeLicense { get; set; } + + public bool IsFreeLicense { get; set; } + + public uint PriceInCentsWithDiscount { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreSupportInfoModel.cs b/src/Steam.Models/SteamStore/StoreSupportInfoModel.cs new file mode 100644 index 0000000..ba165f0 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreSupportInfoModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreSupportInfoModel + { + public string Url { get; set; } + + public string Email { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreTopSellersModel.cs b/src/Steam.Models/SteamStore/StoreTopSellersModel.cs new file mode 100644 index 0000000..10544d3 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreTopSellersModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.SteamStore +{ + public class StoreTopSellersModel + { + public uint Id { get; set; } + + public string Name { get; set; } + + public StoreItemModel[] Items { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreTrailerSlideshowModel.cs b/src/Steam.Models/SteamStore/StoreTrailerSlideshowModel.cs new file mode 100644 index 0000000..447d7a9 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreTrailerSlideshowModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreTrailerSlideshowModel + { + public uint Id { get; set; } + + public string Name { get; set; } + } +} diff --git a/src/Steam.Models/SteamStore/StoreWebmModel.cs b/src/Steam.Models/SteamStore/StoreWebmModel.cs new file mode 100644 index 0000000..e9bbcd7 --- /dev/null +++ b/src/Steam.Models/SteamStore/StoreWebmModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamStore +{ + public class StoreWebmModel + { + public string Resolution480 { get; set; } + + public string Max { get; set; } + } +} diff --git a/src/Steam.Models/SteamUserAuth/SteamAuthError.cs b/src/Steam.Models/SteamUserAuth/SteamAuthError.cs new file mode 100644 index 0000000..0d0b21c --- /dev/null +++ b/src/Steam.Models/SteamUserAuth/SteamAuthError.cs @@ -0,0 +1,8 @@ +namespace Steam.Models.SteamUserAuth +{ + public class SteamAuthError + { + public string ErrorCode { get; set; } + public string ErrorDesc { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamUserAuth/SteamAuthResponseParams.cs b/src/Steam.Models/SteamUserAuth/SteamAuthResponseParams.cs new file mode 100644 index 0000000..c0069be --- /dev/null +++ b/src/Steam.Models/SteamUserAuth/SteamAuthResponseParams.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.SteamUserAuth +{ + public class SteamAuthResponseParams + { + public string Result { get; set; } + public string SteamId { get; set; } + public string OwnerSteamId { get; set; } + public bool VacBanned { get; set; } + public bool PublisherBanned { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamUserAuth/SteamUserAuthResponse.cs b/src/Steam.Models/SteamUserAuth/SteamUserAuthResponse.cs new file mode 100644 index 0000000..7dc0f48 --- /dev/null +++ b/src/Steam.Models/SteamUserAuth/SteamUserAuthResponse.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.SteamUserAuth +{ + public class SteamUserAuthResponse + { + public SteamAuthResponseParams Params { get; set; } + public SteamAuthError Error { get; set; } + public bool Success => Error == null && Params != null; + } +} \ No newline at end of file diff --git a/src/Steam.Models/SteamUserAuth/SteamUserAuthResponseModel.cs b/src/Steam.Models/SteamUserAuth/SteamUserAuthResponseModel.cs new file mode 100644 index 0000000..5b94b9a --- /dev/null +++ b/src/Steam.Models/SteamUserAuth/SteamUserAuthResponseModel.cs @@ -0,0 +1,7 @@ +namespace Steam.Models.SteamUserAuth +{ + public class SteamUserAuthResponseModel + { + public SteamUserAuthResponse Response { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/TF2/GoldenWrenchModel.cs b/src/Steam.Models/TF2/GoldenWrenchModel.cs new file mode 100644 index 0000000..94cf167 --- /dev/null +++ b/src/Steam.Models/TF2/GoldenWrenchModel.cs @@ -0,0 +1,15 @@ +using System; + +namespace Steam.Models.TF2 +{ + public class GoldenWrenchModel + { + public ulong SteamId { get; set; } + + public DateTime Timestamp { get; set; } + + public uint ItemId { get; set; } + + public uint WrenchNumber { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/TF2/SchemaAdditionalHiddenBodygroupsModel.cs b/src/Steam.Models/TF2/SchemaAdditionalHiddenBodygroupsModel.cs new file mode 100644 index 0000000..8748ee2 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaAdditionalHiddenBodygroupsModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.TF2 +{ + public class SchemaAdditionalHiddenBodygroupsModel + { + public uint Hat { get; set; } + + public uint Headphones { get; set; } + + public uint? Head { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaAttributeControlledAttachedParticleModel.cs b/src/Steam.Models/TF2/SchemaAttributeControlledAttachedParticleModel.cs new file mode 100644 index 0000000..e8d0e62 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaAttributeControlledAttachedParticleModel.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.TF2 +{ + public class SchemaAttributeControlledAttachedParticleModel + { + public string System { get; set; } + + public uint Id { get; set; } + + public bool AttachToRootbone { get; set; } + + public string Name { get; set; } + + public string Attachment { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaAttributeModel.cs b/src/Steam.Models/TF2/SchemaAttributeModel.cs new file mode 100644 index 0000000..4c4abff --- /dev/null +++ b/src/Steam.Models/TF2/SchemaAttributeModel.cs @@ -0,0 +1,21 @@ +namespace Steam.Models.TF2 +{ + public class SchemaAttributeModel + { + public string Name { get; set; } + + public uint Defindex { get; set; } + + public string AttributeClass { get; set; } + + public string DescriptionString { get; set; } + + public string DescriptionFormat { get; set; } + + public string EffectType { get; set; } + + public bool Hidden { get; set; } + + public bool StoredAsInteger { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaCapabilitiesModel.cs b/src/Steam.Models/TF2/SchemaCapabilitiesModel.cs new file mode 100644 index 0000000..f8e44c1 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaCapabilitiesModel.cs @@ -0,0 +1,45 @@ +namespace Steam.Models.TF2 +{ + public class SchemaCapabilitiesModel + { + public bool Nameable { get; set; } + + public bool CanCraftMark { get; set; } + + public bool CanBeRestored { get; set; } + + public bool StrangeParts { get; set; } + + public bool CanCardUpgrade { get; set; } + + public bool CanStrangify { get; set; } + + public bool CanKillstreakify { get; set; } + + public bool CanConsume { get; set; } + + public bool? CanGiftWrap { get; set; } + + public bool? CanCollect { get; set; } + + public bool? Paintable { get; set; } + + public bool? CanCraftIfPurchased { get; set; } + + public bool? CanCraftCount { get; set; } + + public bool? UsableGc { get; set; } + + public bool? Usable { get; set; } + + public bool? CanCustomizeTexture { get; set; } + + public bool? UsableOutOfGame { get; set; } + + public bool? CanSpellPage { get; set; } + + public bool? DuckUpgradable { get; set; } + + public bool? Decodable { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaItemAttributeModel.cs b/src/Steam.Models/TF2/SchemaItemAttributeModel.cs new file mode 100644 index 0000000..44b9af8 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaItemAttributeModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.TF2 +{ + public class SchemaItemAttributeModel + { + public string Name { get; set; } + + public string Class { get; set; } + + public double Value { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaItemLevelModel.cs b/src/Steam.Models/TF2/SchemaItemLevelModel.cs new file mode 100644 index 0000000..0b5efb1 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaItemLevelModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.TF2 +{ + public class SchemaItemLevelModel + { + public string Name { get; set; } + + public IList Levels { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaItemModel.cs b/src/Steam.Models/TF2/SchemaItemModel.cs new file mode 100644 index 0000000..d1d8745 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaItemModel.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; + +namespace Steam.Models.TF2 +{ + public class SchemaItemModel + { + public uint DefIndex { get; set; } + + public string Name { get; set; } + + public string ItemTypeName { get; set; } + + public string ItemName { get; set; } + + public string ItemDescription { get; set; } + + public string ImageInventoryPath { get; set; } + + public string ItemClass { get; set; } + + public bool ProperName { get; set; } + + public string ItemSlot { get; set; } + + public string ModelPlayer { get; set; } + + public uint ItemQuality { get; set; } + + public uint MinIlevel { get; set; } + + public uint MaxIlevel { get; set; } + + public string ImageUrl { get; set; } + + public string ImageUrlLarge { get; set; } + + public string CraftClass { get; set; } + + public string CraftMaterialType { get; set; } + + public string ItemLogName { get; set; } + + public SchemaCapabilitiesModel Capabilities { get; set; } + + public IList UsedByClasses { get; set; } + + public IList Styles { get; set; } + + public IList Attributes { get; set; } + + public string DropType { get; set; } + + public string ItemSet { get; set; } + + public string HolidayRestriction { get; set; } + + public SchemaPerClassLoadoutSlotsModel PerClassLoadoutSlots { get; set; } + + public SchemaToolModel Tool { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaItemSetAttributeModel.cs b/src/Steam.Models/TF2/SchemaItemSetAttributeModel.cs new file mode 100644 index 0000000..c66e1f4 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaItemSetAttributeModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.TF2 +{ + public class SchemaItemSetAttributeModel + { + public string Name { get; set; } + + public string Class { get; set; } + + public double Value { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaItemSetModel.cs b/src/Steam.Models/TF2/SchemaItemSetModel.cs new file mode 100644 index 0000000..1d62eeb --- /dev/null +++ b/src/Steam.Models/TF2/SchemaItemSetModel.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace Steam.Models.TF2 +{ + public class SchemaItemSetModel + { + public string ItemSet { get; set; } + + public string Name { get; set; } + + public IList Items { get; set; } + + public IList Attributes { get; set; } + + public string StoreBundleName { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaKillEaterScoreTypeModel.cs b/src/Steam.Models/TF2/SchemaKillEaterScoreTypeModel.cs new file mode 100644 index 0000000..43207c1 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaKillEaterScoreTypeModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.TF2 +{ + public class SchemaKillEaterScoreTypeModel + { + public uint Type { get; set; } + + public string TypeName { get; set; } + + public string LevelData { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaLevelModel.cs b/src/Steam.Models/TF2/SchemaLevelModel.cs new file mode 100644 index 0000000..d5c5635 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaLevelModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models.TF2 +{ + public class SchemaLevelModel + { + public uint Level { get; set; } + + public uint RequiredScore { get; set; } + + public string Name { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaModel.cs b/src/Steam.Models/TF2/SchemaModel.cs new file mode 100644 index 0000000..3624209 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaModel.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; + +namespace Steam.Models.TF2 +{ + public class SchemaModel + { + public string ItemsGameUrl { get; set; } + + public SchemaQualitiesModel Qualities { get; set; } + + public IList OriginNames { get; set; } + + public IList Items { get; set; } + + public IList Attributes { get; set; } + + public IList ItemSets { get; set; } + + public IList AttributeControlledAttachedParticles { get; set; } + + public IList ItemLevels { get; set; } + + public IList KillEaterScoreTypes { get; set; } + + public IList StringLookups { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaOriginNameModel.cs b/src/Steam.Models/TF2/SchemaOriginNameModel.cs new file mode 100644 index 0000000..a70d9d9 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaOriginNameModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.TF2 +{ + public class SchemaOriginNameModel + { + public uint Origin { get; set; } + + public string Name { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaPerClassLoadoutSlotsModel.cs b/src/Steam.Models/TF2/SchemaPerClassLoadoutSlotsModel.cs new file mode 100644 index 0000000..139cf73 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaPerClassLoadoutSlotsModel.cs @@ -0,0 +1,15 @@ +namespace Steam.Models.TF2 +{ + public class SchemaPerClassLoadoutSlotsModel + { + public string Soldier { get; set; } + + public string Heavy { get; set; } + + public string Pyro { get; set; } + + public string Engineer { get; set; } + + public string Demoman { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaQualitiesModel.cs b/src/Steam.Models/TF2/SchemaQualitiesModel.cs new file mode 100644 index 0000000..382f4b5 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaQualitiesModel.cs @@ -0,0 +1,82 @@ +namespace Steam.Models.TF2 +{ + public class SchemaQualitiesModel + { + /// + /// Normal item rarity: https://wiki.teamfortress.com/wiki/Normal + /// + public uint Normal { get; set; } + + /// + /// Genuine item rarity: https://wiki.teamfortress.com/wiki/Genuine + /// + public uint Rarity1 { get; set; } + + /// + /// Unused + /// + public uint Rarity2 { get; set; } + + /// + /// Vintage item rarity: https://wiki.teamfortress.com/wiki/Vintage + /// + public uint Vintage { get; set; } + + /// + /// Unused + /// + public uint Rarity3 { get; set; } + + /// + /// Unusual item rarity: https://wiki.teamfortress.com/wiki/Unusual + /// + public uint Rarity4 { get; set; } + + /// + /// Unique item rarity: https://wiki.teamfortress.com/wiki/Unique + /// + public uint Unique { get; set; } + + /// + /// Community item: https://wiki.teamfortress.com/wiki/Community_(quality) + /// + public uint Community { get; set; } + + /// + /// Developer owned item: https://wiki.teamfortress.com/wiki/Valve_(quality) + /// + public uint Developer { get; set; } + + /// + /// Self made item: https://wiki.teamfortress.com/wiki/Self-Made + /// + public uint SelfMade { get; set; } + + /// + /// Unused + /// + public uint Customized { get; set; } + + /// + /// Strange item: https://wiki.teamfortress.com/wiki/Strange + /// + public uint Strange { get; set; } + + /// + /// Unused + /// + public uint Completed { get; set; } + + /// + /// Haunted item: https://wiki.teamfortress.com/wiki/Haunted + /// + public uint Haunted { get; set; } + + /// + /// Collector's item: https://wiki.teamfortress.com/wiki/Collector%27s + /// + public uint Collectors { get; set; } + + public uint PaintKitWeapon { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaStringLookupModel.cs b/src/Steam.Models/TF2/SchemaStringLookupModel.cs new file mode 100644 index 0000000..1989833 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaStringLookupModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Steam.Models.TF2 +{ + public class SchemaStringLookupModel + { + public string TableName { get; set; } + + public IList Strings { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaStringModel.cs b/src/Steam.Models/TF2/SchemaStringModel.cs new file mode 100644 index 0000000..5ce3318 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaStringModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.TF2 +{ + public class SchemaStringModel + { + public uint Index { get; set; } + + public string String { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaStyleModel.cs b/src/Steam.Models/TF2/SchemaStyleModel.cs new file mode 100644 index 0000000..6325f1e --- /dev/null +++ b/src/Steam.Models/TF2/SchemaStyleModel.cs @@ -0,0 +1,9 @@ +namespace Steam.Models.TF2 +{ + public class SchemaStyleModel + { + public string Name { get; set; } + + public SchemaAdditionalHiddenBodygroupsModel AdditionalHiddenBodygroups { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaToolModel.cs b/src/Steam.Models/TF2/SchemaToolModel.cs new file mode 100644 index 0000000..c26a665 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaToolModel.cs @@ -0,0 +1,13 @@ +namespace Steam.Models.TF2 +{ + public class SchemaToolModel + { + public string Type { get; set; } + + public SchemaUsageCapabilitiesModel UsageCapabilities { get; set; } + + public string UseString { get; set; } + + public string Restriction { get; set; } + } +} diff --git a/src/Steam.Models/TF2/SchemaUsageCapabilitiesModel.cs b/src/Steam.Models/TF2/SchemaUsageCapabilitiesModel.cs new file mode 100644 index 0000000..59f5850 --- /dev/null +++ b/src/Steam.Models/TF2/SchemaUsageCapabilitiesModel.cs @@ -0,0 +1,31 @@ +namespace Steam.Models.TF2 +{ + public class SchemaUsageCapabilitiesModel + { + public bool Nameable { get; set; } + + public bool? Decodable { get; set; } + + public bool? Paintable { get; set; } + + public bool? CanCustomizeTexture { get; set; } + + public bool? CanGiftWrap { get; set; } + + public bool? PaintableTeamColors { get; set; } + + public bool? CanStrangify { get; set; } + + public bool? CanKillstreakify { get; set; } + + public bool? DuckUpgradable { get; set; } + + public bool? StrangeParts { get; set; } + + public bool? CanCardUpgrade { get; set; } + + public bool? CanSpellPage { get; set; } + + public bool? CanConsume { get; set; } + } +} diff --git a/src/Steam.Models/UGCFileDetailsModel.cs b/src/Steam.Models/UGCFileDetailsModel.cs new file mode 100644 index 0000000..fc2a5a4 --- /dev/null +++ b/src/Steam.Models/UGCFileDetailsModel.cs @@ -0,0 +1,11 @@ +namespace Steam.Models +{ + public class UGCFileDetailsModel + { + public string FileName { get; set; } + + public string URL { get; set; } + + public uint Size { get; set; } + } +} \ No newline at end of file diff --git a/src/Steam.Models/Utilities/DateTimeExtensions.cs b/src/Steam.Models/Utilities/DateTimeExtensions.cs new file mode 100644 index 0000000..1778d45 --- /dev/null +++ b/src/Steam.Models/Utilities/DateTimeExtensions.cs @@ -0,0 +1,32 @@ +using System; + +namespace Steam.Models.Utilities +{ + public static class DateTimeExtensions + { + /// + /// Converts a Unix time to a DateTime + /// + /// + /// + public static DateTime ToDateTime(this ulong unixTimeStamp) + { + DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); + return origin.AddSeconds(unixTimeStamp); + } + + /// + /// Converts a DateTime to a Unix time + /// + /// + /// + public static ulong ToUnixTimeStamp(this DateTime dateTime) + { + DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); + + TimeSpan timeSpanSinceOrigin = dateTime.Subtract(origin); + + return Convert.ToUInt64(timeSpanSinceOrigin.TotalSeconds); + } + } +} \ No newline at end of file diff --git a/src/Steam.UnitTests/BaseTest.cs b/src/Steam.UnitTests/BaseTest.cs new file mode 100644 index 0000000..c1ad4f4 --- /dev/null +++ b/src/Steam.UnitTests/BaseTest.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Configuration; +using SteamWebAPI2.Utilities; +using Microsoft.Extensions.Options; + +namespace Steam.UnitTests +{ + public class BaseTest + { + private IConfiguration configuration; + protected readonly SteamWebInterfaceFactory factory; + + public BaseTest() + { + var builder = new ConfigurationBuilder() + .AddJsonFile("appsettings.json"); + configuration = builder.Build(); + + var factoryOptions = new SteamWebInterfaceFactoryOptions() + { + SteamWebApiKey = configuration["SteamWebApiKey"] + }; + factory = new SteamWebInterfaceFactory(Options.Create(factoryOptions)); + } + } +} \ No newline at end of file diff --git a/src/Steam.UnitTests/CSGOServersTests.cs b/src/Steam.UnitTests/CSGOServersTests.cs new file mode 100644 index 0000000..3cc8697 --- /dev/null +++ b/src/Steam.UnitTests/CSGOServersTests.cs @@ -0,0 +1,34 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Steam.Models.CSGO; +using SteamWebAPI2.Interfaces; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class CSGOServersTests : BaseTest + { + [TestMethod] + public async Task GetGameMapsPlaytimeAsync_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + var response = await steamInterface.GetGameMapsPlaytimeAsync( + GameMapsPlaytimeInterval.Week, + GameMapsPlaytimeGameMode.Competitive, + GameMapsPlaytimeMapGroup.Operation + ); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetGameServerStatusAsync_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + var response = await steamInterface.GetGameServerStatusAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + } +} diff --git a/src/Steam.UnitTests/DOTA2EconTests.cs b/src/Steam.UnitTests/DOTA2EconTests.cs new file mode 100644 index 0000000..322d72e --- /dev/null +++ b/src/Steam.UnitTests/DOTA2EconTests.cs @@ -0,0 +1,41 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class DOTA2EconTests : BaseTest + { + private readonly DOTA2Econ steamInterface; + + public DOTA2EconTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + [TestMethod] + public async Task GetHeroesAsync_Should_Succeed() + { + var response = await steamInterface.GetHeroesAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetRaritiesAsync_Should_Succeed() + { + var response = await steamInterface.GetRaritiesAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetTournamentPrizePoolAsync_Should_Succeed() + { + var response = await steamInterface.GetTournamentPrizePoolAsync(); + Assert.IsNotNull(response); + } + } +} diff --git a/src/Steam.UnitTests/DOTA2MatchTests.cs b/src/Steam.UnitTests/DOTA2MatchTests.cs new file mode 100644 index 0000000..2aa685f --- /dev/null +++ b/src/Steam.UnitTests/DOTA2MatchTests.cs @@ -0,0 +1,59 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class DOTA2MatchTests : BaseTest + { + private readonly DOTA2Match steamInterface; + + public DOTA2MatchTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + [TestMethod] + public async Task GetLiveLeagueGamesAsync_Should_Succeed() + { + var response = await steamInterface.GetLiveLeagueGamesAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + // This endpoint seems to be broken on Valve's end as of last year. Commenting for now. + // [TestMethod] + // public async Task GetMatchDetailsAsync_Should_Succeed() + // { + // var response = await steamInterface.GetMatchDetailsAsync(8555615768); + // Assert.IsNotNull(response); + // Assert.IsNotNull(response.Data); + // } + + [TestMethod] + public async Task GetMatchHistoryAsync_Should_Succeed() + { + var response = await steamInterface.GetMatchHistoryAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetMatchHistoryBySequenceNumberAsync_Should_Succeed() + { + var response = await steamInterface.GetMatchHistoryBySequenceNumberAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetTeamInfoByTeamIdAsync_Should_Succeed() + { + var response = await steamInterface.GetTeamInfoByTeamIdAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + } +} diff --git a/src/Steam.UnitTests/DOTA2TicketTests.cs b/src/Steam.UnitTests/DOTA2TicketTests.cs new file mode 100644 index 0000000..60ea855 --- /dev/null +++ b/src/Steam.UnitTests/DOTA2TicketTests.cs @@ -0,0 +1,17 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Net.Http; + +namespace Steam.UnitTests +{ + [TestClass] + public class DOTA2TicketTests : BaseTest + { + private readonly DOTA2Ticket steamInterface; + + public DOTA2TicketTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + } +} diff --git a/src/Steam.UnitTests/EconItemsTeamFortress2Tests.cs b/src/Steam.UnitTests/EconItemsTeamFortress2Tests.cs new file mode 100644 index 0000000..e8994a8 --- /dev/null +++ b/src/Steam.UnitTests/EconItemsTeamFortress2Tests.cs @@ -0,0 +1,68 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class EconItemsTeamFortress2Tests : BaseTest + { + private readonly EconItems steamInterface; + + public EconItemsTeamFortress2Tests() + { + steamInterface = factory.CreateSteamWebInterface( + AppId.TeamFortress2, + new HttpClient() + ); + } + + [TestMethod] + public async Task GetSchemaItemsForTF2Async_Should_Succeed() + { + uint? next = null; + + do + { + var response = await steamInterface.GetSchemaItemsForTF2Async(start: next); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + + next = response.Data.Result.Next; + } + while (next.HasValue); + } + + [TestMethod] + public async Task GetSchemaOverviewForTF2Async_Should_Succeed() + { + var response = await steamInterface.GetSchemaOverviewForTF2Async(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetSchemaUrlAsync_Should_Succeed() + { + var response = await steamInterface.GetSchemaUrlAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetStoreMetaDataAsync_Should_Succeed() + { + var response = await steamInterface.GetStoreMetaDataAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetStoreStatusAsync_Should_Succeed() + { + var response = await steamInterface.GetStoreStatusAsync(); + Assert.IsNotNull(response); + } + } +} diff --git a/src/Steam.UnitTests/EconServiceTests.cs b/src/Steam.UnitTests/EconServiceTests.cs new file mode 100644 index 0000000..a556a49 --- /dev/null +++ b/src/Steam.UnitTests/EconServiceTests.cs @@ -0,0 +1,43 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class EconServiceTests : BaseTest + { + private readonly EconService steamInterface; + + public EconServiceTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + [TestMethod] + public async Task GetPlayerItemsAsync_Should_Succeed() + { + var response = await steamInterface.GetTradeHistoryAsync(10); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetTradeOffersAsync_Should_Succeed() + { + var response = await steamInterface.GetTradeOffersAsync(true, true); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + // TODO: Figure out how to get a Trade Offer ID? From History? + // [TestMethod] + // public async Task GetTradeOfferAsync_Should_Succeed() + // { + // var response = await steamInterface.GetTradeOfferAsync(); + // Assert.IsNotNull(response); + // Assert.IsNotNull(response.Data); + // } + } +} diff --git a/src/Steam.UnitTests/GCVersionTests.cs b/src/Steam.UnitTests/GCVersionTests.cs new file mode 100644 index 0000000..b568e30 --- /dev/null +++ b/src/Steam.UnitTests/GCVersionTests.cs @@ -0,0 +1,128 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class GCVersionTests : BaseTest + { + private readonly GCVersion steamInterfaceTeamFortress2; + private readonly GCVersion steamInterfaceCounterStrikeGO; + private readonly GCVersion steamInterfaceDota2; + private readonly GCVersion steamInterfaceArtifact; + private readonly GCVersion steamInterfaceDotaUnderlords; + + public GCVersionTests() + { + HttpClient httpClient = new HttpClient(); + + steamInterfaceTeamFortress2 = factory.CreateSteamWebInterface( + AppId.TeamFortress2, + httpClient + ); + + steamInterfaceCounterStrikeGO = factory.CreateSteamWebInterface( + AppId.CounterStrikeGO, + httpClient + ); + + steamInterfaceDota2 = factory.CreateSteamWebInterface( + AppId.Dota2, + httpClient + ); + + steamInterfaceArtifact = factory.CreateSteamWebInterface( + AppId.Artifact, + httpClient + ); + + steamInterfaceDotaUnderlords = factory.CreateSteamWebInterface( + AppId.DotaUnderlords, + httpClient + ); + } + + [TestMethod] + public async Task GetClientVersionTeamFortress2Async_Should_Succeed() + { + var response = await steamInterfaceTeamFortress2.GetClientVersionAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetServerVersionTeamFortress2Async_Should_Succeed() + { + var response = await steamInterfaceTeamFortress2.GetServerVersionAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetClientVersionCounterStrikeGOAsync_Should_Fail() + { + await Assert.ThrowsExceptionAsync(() => + steamInterfaceCounterStrikeGO.GetClientVersionAsync() + ); + } + + [TestMethod] + public async Task GetServerVersionCounterStrikeGOAsync_Should_Succeed() + { + var response = await steamInterfaceCounterStrikeGO.GetServerVersionAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetClientVersionDota2Async_Should_Succeed() + { + var response = await steamInterfaceDota2.GetClientVersionAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetServerVersionDota2Async_Should_Succeed() + { + var response = await steamInterfaceDota2.GetServerVersionAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetClientVersionArtifactAsync_Should_Succeed() + { + var response = await steamInterfaceArtifact.GetClientVersionAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetServerVersionArtifactAsync_Should_Succeed() + { + var response = await steamInterfaceArtifact.GetServerVersionAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetClientVersionDotaUnderlordsAsync_Should_Succeed() + { + var response = await steamInterfaceDotaUnderlords.GetClientVersionAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetServerVersionDotaUnderlordsAsync_Should_Succeed() + { + var response = await steamInterfaceDotaUnderlords.GetServerVersionAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + } +} diff --git a/src/Steam.UnitTests/PlayerServiceTests.cs b/src/Steam.UnitTests/PlayerServiceTests.cs new file mode 100644 index 0000000..ad98efc --- /dev/null +++ b/src/Steam.UnitTests/PlayerServiceTests.cs @@ -0,0 +1,59 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class PlayerServiceTests : BaseTest + { + private readonly PlayerService steamInterface; + + public PlayerServiceTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + // Commented out until I can figure out how to get a valid response from this endpoint. + // [TestMethod] + // public async Task GetCommunityBadgeProgressAsync_Should_Succeed() + // { + // var response = await steamInterface.GetCommunityBadgeProgressAsync(76561198050013009); + // Assert.IsNotNull(response); + // Assert.IsNotNull(response.Data); + // } + + [TestMethod] + public async Task GetBadgesAsync_Should_Succeed() + { + var response = await steamInterface.GetBadgesAsync(76561198050013009); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetSteamLevelAsync_Should_Succeed() + { + var response = await steamInterface.GetSteamLevelAsync(76561198050013009); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetOwnedGamesAsync_Should_Succeed() + { + var response = await steamInterface.GetOwnedGamesAsync(76561198050013009); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetRecentlyPlayedGames_Should_Succeed() + { + var response = await steamInterface.GetRecentlyPlayedGamesAsync(76561198050013009); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + } +} diff --git a/src/Steam.UnitTests/Steam.UnitTests.csproj b/src/Steam.UnitTests/Steam.UnitTests.csproj new file mode 100644 index 0000000..c906841 --- /dev/null +++ b/src/Steam.UnitTests/Steam.UnitTests.csproj @@ -0,0 +1,27 @@ + + + + net8.0 + false + 46a53f4e-b4d4-4fad-b7c9-b777001cfe42 + + + + + + + + + + + + + + + + + + Always + + + \ No newline at end of file diff --git a/src/Steam.UnitTests/SteamAppsTests.cs b/src/Steam.UnitTests/SteamAppsTests.cs new file mode 100644 index 0000000..a953233 --- /dev/null +++ b/src/Steam.UnitTests/SteamAppsTests.cs @@ -0,0 +1,35 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class SteamAppsTests : BaseTest + { + private readonly SteamApps steamInterface; + + public SteamAppsTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + // Always returning 503 on Valve's end. Commenting for now. + // [TestMethod] + // public async Task GetAppListAsync_Should_Succeed() + // { + // var response = await steamInterface.GetAppListAsync(); + // Assert.IsNotNull(response); + // Assert.IsNotNull(response.Data); + // } + + [TestMethod] + public async Task UpToDateCheckAsync_Should_Succeed() + { + var response = await steamInterface.UpToDateCheckAsync(440, 1); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + } +} diff --git a/src/Steam.UnitTests/SteamEconomyTests.cs b/src/Steam.UnitTests/SteamEconomyTests.cs new file mode 100644 index 0000000..5607f2b --- /dev/null +++ b/src/Steam.UnitTests/SteamEconomyTests.cs @@ -0,0 +1,36 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class SteamEconomyTests : BaseTest + { + private readonly SteamEconomy steamInterface; + + public SteamEconomyTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + [TestMethod] + public async Task GetAssetClassInfoAsync_Should_Succeed() + { + List classes = new List() { 211447708 }; + var response = await steamInterface.GetAssetClassInfoAsync(440, classes); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetAssetPricesAsync_Should_Succeed() + { + var response = await steamInterface.GetAssetPricesAsync(440); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + } +} diff --git a/src/Steam.UnitTests/SteamNewsTests.cs b/src/Steam.UnitTests/SteamNewsTests.cs new file mode 100644 index 0000000..e1a0b2f --- /dev/null +++ b/src/Steam.UnitTests/SteamNewsTests.cs @@ -0,0 +1,26 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class SteamNewsTests : BaseTest + { + private readonly SteamNews steamInterface; + + public SteamNewsTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + [TestMethod] + public async Task GetNewsForAppAsync_Should_Succeed() + { + var response = await steamInterface.GetNewsForAppAsync(440); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + } +} diff --git a/src/Steam.UnitTests/SteamRemoteTests.cs b/src/Steam.UnitTests/SteamRemoteTests.cs new file mode 100644 index 0000000..f931388 --- /dev/null +++ b/src/Steam.UnitTests/SteamRemoteTests.cs @@ -0,0 +1,38 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Steam.Models; +using SteamWebAPI2.Interfaces; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class SteamRemoteTests : BaseTest + { + private readonly SteamRemoteStorage steamInterface; + + public SteamRemoteTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + [TestMethod] + public async Task GetPublishedFileDetailsAsync_Public_Visibility_Should_Succeed() + { + var response = await steamInterface.GetPublishedFileDetailsAsync(1673456286); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + Assert.AreEqual(PublishedFileVisibility.Public, response.Data.FirstOrDefault()?.Visibility); + } + + [TestMethod] + public async Task GetPublishedFileDetailsAsync_Unknown_Visibility_Should_Succeed() + { + var response = await steamInterface.GetPublishedFileDetailsAsync(2097579725); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + Assert.AreEqual(PublishedFileVisibility.Unknown, response.Data.FirstOrDefault()?.Visibility); + } + } +} diff --git a/src/Steam.UnitTests/SteamStoreTests.cs b/src/Steam.UnitTests/SteamStoreTests.cs new file mode 100644 index 0000000..e8bc5cb --- /dev/null +++ b/src/Steam.UnitTests/SteamStoreTests.cs @@ -0,0 +1,42 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class SteamStoreTests + { + private readonly SteamStore steamStore; + + public SteamStoreTests() + { + steamStore = new SteamStore(null); + } + + [TestMethod] + public async Task GetStoreAppDetailsAsync_Should_Succeed() + { + var response = await steamStore.GetStoreAppDetailsAsync(1086940); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Name); + } + + [TestMethod] + public async Task GetStoreAppDetailsAsync_WithCurrency_Should_Succeed() + { + var response = await steamStore.GetStoreAppDetailsAsync(1086940, "mx"); + Assert.IsNotNull(response); + Assert.IsNotNull(response.PriceOverview?.Currency); + Assert.AreEqual("MXN", response.PriceOverview.Currency); + } + + [TestMethod] + public async Task GetStoreAppDetailsAsync_WithLanguage_Should_Succeed() + { + var response = await steamStore.GetStoreAppDetailsAsync(1086940, "german"); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Name); + } + } +} diff --git a/src/Steam.UnitTests/SteamUserStatsTests.cs b/src/Steam.UnitTests/SteamUserStatsTests.cs new file mode 100644 index 0000000..e63d905 --- /dev/null +++ b/src/Steam.UnitTests/SteamUserStatsTests.cs @@ -0,0 +1,67 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class SteamUserStatsTests : BaseTest + { + private readonly SteamUserStats steamInterface; + + public SteamUserStatsTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + [TestMethod] + public async Task GetGlobalAchievementPercentagesForAppAsync_Should_Succeed() + { + var response = await steamInterface.GetGlobalAchievementPercentagesForAppAsync(440); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetGlobalStatsForGameAsync_Should_Succeed() + { + List statNames = new List() { "crimefest_challenge_dallas_1" }; + var response = await steamInterface.GetGlobalStatsForGameAsync(218620, statNames.AsReadOnly()); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetNumberOfCurrentPlayersForGameAsync_Should_Succeed() + { + var response = await steamInterface.GetNumberOfCurrentPlayersForGameAsync(440); + Assert.IsNotNull(response); + } + + [TestMethod] + public async Task GetPlayerAchievementsAsync_Should_Succeed() + { + var response = await steamInterface.GetPlayerAchievementsAsync(440, 76561198050013009); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetSchemaForGameAsync_Should_Succeed() + { + var response = await steamInterface.GetSchemaForGameAsync(440); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetUserStatsForGameAsync_Should_Succeed() + { + var response = await steamInterface.GetUserStatsForGameAsync(76561198050013009, 440); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + } +} diff --git a/src/Steam.UnitTests/SteamUserTests.cs b/src/Steam.UnitTests/SteamUserTests.cs new file mode 100644 index 0000000..4596979 --- /dev/null +++ b/src/Steam.UnitTests/SteamUserTests.cs @@ -0,0 +1,87 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Collections.Generic; +using System.Globalization; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class SteamUserTests : BaseTest + { + private readonly SteamUser steamInterface; + + public SteamUserTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + [TestMethod] + public async Task GetPlayerSummaryAsync_Should_Succeed() + { + var response = await steamInterface.GetPlayerSummaryAsync(76561198050013009); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetPlayerSummariesAsync_Should_Succeed() + { + List steamIds = new List() { 76561198050013009 }; + var response = await steamInterface.GetPlayerSummariesAsync(steamIds.AsReadOnly()); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetFriendsListAsync_Should_Succeed() + { + var response = await steamInterface.GetFriendsListAsync(76561198050013009); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetPlayerBansAsync_Should_Succeed() + { + var response = await steamInterface.GetPlayerBansAsync(76561198050013009); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetPlayerBansMultipleAsync_Should_Succeed() + { + List steamIds = new List() { 76561198050013009 }; + var response = await steamInterface.GetPlayerBansAsync(steamIds.AsReadOnly()); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetUserGroupsAsync_Should_Succeed() + { + var response = await steamInterface.GetUserGroupsAsync(76561198050013009); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task ResolveVanityUrlAsync_Should_Succeed() + { + var response = await steamInterface.ResolveVanityUrlAsync("aro"); + Assert.IsNotNull(response); + Assert.IsTrue(response.Data > 0); + } + + [TestMethod] + public async Task GetCommunityProfileAsync_Should_Succeed() + { + //for other cultures (for example ru) automaper will not be able to convert floating point numbers and will throw an error + CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("en"); + var response = await steamInterface.GetCommunityProfileAsync(76561198064401017); + Assert.IsNotNull(response); + } + } +} diff --git a/src/Steam.UnitTests/SteamWebAPIUtilTests.cs b/src/Steam.UnitTests/SteamWebAPIUtilTests.cs new file mode 100644 index 0000000..88c54cc --- /dev/null +++ b/src/Steam.UnitTests/SteamWebAPIUtilTests.cs @@ -0,0 +1,34 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class SteamWebAPIUtilTests : BaseTest + { + private readonly SteamWebAPIUtil steamInterface; + + public SteamWebAPIUtilTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + [TestMethod] + public async Task GetServerInfoAsync_Should_Succeed() + { + var response = await steamInterface.GetServerInfoAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + + [TestMethod] + public async Task GetSupportedAPIListAsync_Should_Succeed() + { + var response = await steamInterface.GetSupportedAPIListAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + } +} diff --git a/src/Steam.UnitTests/SteamWebInterfaceFactoryTests.cs b/src/Steam.UnitTests/SteamWebInterfaceFactoryTests.cs new file mode 100644 index 0000000..bfcde04 --- /dev/null +++ b/src/Steam.UnitTests/SteamWebInterfaceFactoryTests.cs @@ -0,0 +1,177 @@ +using Microsoft.Extensions.Options; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using SteamWebAPI2.Utilities; +using System; +using System.Net.Http; + +namespace Steam.UnitTests +{ + [TestClass] + public class SteamWebInterfaceFactoryTests + { + private readonly SteamWebInterfaceFactory factory; + + public SteamWebInterfaceFactoryTests() + { + var factoryOptions = new SteamWebInterfaceFactoryOptions() + { + SteamWebApiKey = "ABC123" + }; + factory = new SteamWebInterfaceFactory(Options.Create(factoryOptions)); + } + + [TestMethod] + public void Constructor_Should_Succeed() + { + var factoryOptions = new SteamWebInterfaceFactoryOptions() + { + SteamWebApiKey = "ABC123" + }; + var factory = new SteamWebInterfaceFactory(Options.Create(factoryOptions)); + Assert.IsNotNull(factory); + } + + [TestMethod] + public void Constructor_Should_Fail_If_Empty_Key() + { + var factoryOptions = new SteamWebInterfaceFactoryOptions() + { + SteamWebApiKey = "" + }; + Assert.ThrowsException(() => new SteamWebInterfaceFactory(Options.Create(factoryOptions))); + } + + [TestMethod] + public void Constructor_Should_Fail_If_Null_Key() + { + Assert.ThrowsException(() => new SteamWebInterfaceFactory(steamWebApiKey: null)); + } + + [TestMethod] + public void Create_SteamUser_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_CSGOServers_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_DOTA2Econ_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_DOTA2Match_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_DOTA2Ticket_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_EconItems_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(AppId.TeamFortress2); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_EconService_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_GameServersService_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_GCVersion_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(AppId.TeamFortress2); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_PlayerService_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_SteamApps_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_SteamEconomy_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_SteamNews_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_SteamRemoteStorage_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_SteamStore_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamStoreInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_SteamUserAuth_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_SteamUserStats_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + + [TestMethod] + public void Create_SteamWebAPIUtil_Interface_Should_Succeed() + { + var steamInterface = factory.CreateSteamWebInterface(); + Assert.IsNotNull(steamInterface); + } + } +} \ No newline at end of file diff --git a/src/Steam.UnitTests/TFItemsTests.cs b/src/Steam.UnitTests/TFItemsTests.cs new file mode 100644 index 0000000..93c375b --- /dev/null +++ b/src/Steam.UnitTests/TFItemsTests.cs @@ -0,0 +1,26 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SteamWebAPI2.Interfaces; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Steam.UnitTests +{ + [TestClass] + public class TFItemsTests : BaseTest + { + private readonly TFItems steamInterface; + + public TFItemsTests() + { + steamInterface = factory.CreateSteamWebInterface(new HttpClient()); + } + + [TestMethod] + public async Task GetServerInfoAsync_Should_Succeed() + { + var response = await steamInterface.GetGoldenWrenchesAsync(); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Data); + } + } +} diff --git a/src/Steam.UnitTests/appsettings.json b/src/Steam.UnitTests/appsettings.json new file mode 100644 index 0000000..3dbfc0b --- /dev/null +++ b/src/Steam.UnitTests/appsettings.json @@ -0,0 +1,3 @@ +{ + "SteamWebApiKey": "" +} \ No newline at end of file diff --git a/src/SteamWebAPI2.sln b/src/SteamWebAPI2.sln index 307ac11..73936aa 100644 --- a/src/SteamWebAPI2.sln +++ b/src/SteamWebAPI2.sln @@ -1,9 +1,13 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26730.10 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29806.167 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWebAPI2", "SteamWebAPI2\SteamWebAPI2.csproj", "{73634D2E-7C05-4916-A213-9D181F9992C9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SteamWebAPI2", "SteamWebAPI2\SteamWebAPI2.csproj", "{73634D2E-7C05-4916-A213-9D181F9992C9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steam.Models", "Steam.Models\Steam.Models.csproj", "{AC645B95-E479-4DD2-AFA3-998DCFF66361}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Steam.UnitTests", "Steam.UnitTests\Steam.UnitTests.csproj", "{FD59C506-0C06-45F3-AE6B-982A6185DBA1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +19,14 @@ Global {73634D2E-7C05-4916-A213-9D181F9992C9}.Debug|Any CPU.Build.0 = Debug|Any CPU {73634D2E-7C05-4916-A213-9D181F9992C9}.Release|Any CPU.ActiveCfg = Release|Any CPU {73634D2E-7C05-4916-A213-9D181F9992C9}.Release|Any CPU.Build.0 = Release|Any CPU + {AC645B95-E479-4DD2-AFA3-998DCFF66361}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC645B95-E479-4DD2-AFA3-998DCFF66361}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC645B95-E479-4DD2-AFA3-998DCFF66361}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC645B95-E479-4DD2-AFA3-998DCFF66361}.Release|Any CPU.Build.0 = Release|Any CPU + {FD59C506-0C06-45F3-AE6B-982A6185DBA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD59C506-0C06-45F3-AE6B-982A6185DBA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD59C506-0C06-45F3-AE6B-982A6185DBA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD59C506-0C06-45F3-AE6B-982A6185DBA1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/SteamWebAPI2/AutoMapperConfiguration.cs b/src/SteamWebAPI2/AutoMapperConfiguration.cs deleted file mode 100644 index ec6391b..0000000 --- a/src/SteamWebAPI2/AutoMapperConfiguration.cs +++ /dev/null @@ -1,663 +0,0 @@ -using AutoMapper; -using Steam.Models; -using Steam.Models.CSGO; -using Steam.Models.DOTA2; -using Steam.Models.GameEconomy; -using Steam.Models.SteamCommunity; -using Steam.Models.SteamEconomy; -using Steam.Models.SteamPlayer; -using Steam.Models.SteamStore; -using Steam.Models.TF2; -using SteamWebAPI2.Models; -using SteamWebAPI2.Models.CSGO; -using SteamWebAPI2.Models.DOTA2; -using SteamWebAPI2.Models.GameEconomy; -using SteamWebAPI2.Models.SteamCommunity; -using SteamWebAPI2.Models.SteamEconomy; -using SteamWebAPI2.Models.SteamPlayer; -using SteamWebAPI2.Models.SteamStore; -using SteamWebAPI2.Models.TF2; -using SteamWebAPI2.Utilities; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; - -namespace SteamWebAPI2 -{ - internal static class AutoMapperConfiguration - { - private static bool isInitialized = false; - private static MapperConfiguration config; - private static IMapper mapper; - - public static IMapper Mapper { get { return mapper; } } - - private static SteamWebResponse ConstructSteamWebResponse(ISteamWebResponse response) - { - if (response == null) - { - return null; - } - - var newResponse = new SteamWebResponse(); - - newResponse.ContentLength = response.ContentLength; - newResponse.ContentType = response.ContentType; - newResponse.ContentTypeCharSet = response.ContentTypeCharSet; - newResponse.Expires = response.Expires; - newResponse.LastModified = response.LastModified; - - if (response.Data != null) - { - newResponse.Data = Mapper.Map(response.Data); - } - - return newResponse; - } - - private static void CreateSteamWebResponseMap(IMapperConfigurationExpression config) - { - config.CreateMap, ISteamWebResponse>() - .ConstructUsing(src => ConstructSteamWebResponse(src)); - } - - public static void Initialize() - { - if (isInitialized) - { - return; - } - - if (config == null) - { - config = new MapperConfiguration(x => - { - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap(x); - //CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap(x); - CreateSteamWebResponseMap>(x); - CreateSteamWebResponseMap>(x); - - #region Endpoint: DOTA2Econ - - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Heroes : null) - ); - - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Items : null) - ); - - x.CreateMap().ConvertUsing(src => src.Result != null ? src.Result.Path : null); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - // TODO: Rework the way Schema models are used for different games (TF2 / DOTA2) - //x.CreateMap() - // .ForMember(dest => dest.Name, opts => opts.Ignore()) - // .ForMember(dest => dest.Value, opts => opts.Ignore()) - // .ForMember(dest => dest.HexColor, opts => opts.Ignore()); - //x.CreateMap() - // .ForMember(dest => dest.GameInfo, opts => opts.Ignore()) - // .ForMember(dest => dest.Rarities, opts => opts.Ignore()) - // .ForMember(dest => dest.Colors, opts => opts.Ignore()) - // .ForMember(dest => dest.Prefabs, opts => opts.Ignore()) - // .ForMember(dest => dest.ItemAutographs, opts => opts.Ignore()); - //x.CreateMap().ConvertUsing( - // src => Mapper.Map(src.Result) - //); - - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Rarities : null) - ); - - x.CreateMap().ConvertUsing(src => src.Result != null ? src.Result.PrizePool : default(uint)); - - #endregion - - #region Endpoint: DOTA2Fantasy - - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - - #endregion - - #region Endpoint: DOTA2Match - - x.CreateMap() - .ForMember(dest => dest.ImageInventoryPath, opts => opts.Ignore()) - .ForMember(dest => dest.ImageBannerPath, opts => opts.Ignore()) - .ForMember(dest => dest.NameLocalized, opts => opts.Ignore()) - .ForMember(dest => dest.DescriptionLocalized, opts => opts.Ignore()) - .ForMember(dest => dest.TypeName, opts => opts.Ignore()) - .ForMember(dest => dest.Tier, opts => opts.Ignore()) - .ForMember(dest => dest.Location, opts => opts.Ignore()); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Leagues : null) - ); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Games : null) - ); - - x.CreateMap() - .ForMember(dest => dest.StartTime, opts => opts.MapFrom(src => src.StartTime.ToDateTime())); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - x.CreateMap() - .ForMember(dest => dest.NumResults, opts => opts.Ignore()) - .ForMember(dest => dest.TotalResults, opts => opts.Ignore()) - .ForMember(dest => dest.ResultsRemaining, opts => opts.Ignore()); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Matches : null) - ); - - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Teams : null) - ); - - #endregion - - #region Endpoint: EconService - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap() - .ForMember(dest => dest.TimeTradeStarted, opts => opts.MapFrom(source => source.TimeTradeStarted.ToDateTime())) - .ForMember(dest => dest.TimeEscrowEnds, opts => opts.MapFrom(source => source.TimeEscrowEnds.ToDateTime())); - x.CreateMap() - .ForMember(dest => dest.TimeCreated, opts => opts.MapFrom(source => source.TimeCreated.ToDateTime())) - .ForMember(dest => dest.TimeEscrowEnds, opts => opts.MapFrom(source => source.TimeEscrowEnds.ToDateTime())) - .ForMember(dest => dest.TimeExpiration, opts => opts.MapFrom(source => source.TimeExpiration.ToDateTime())) - .ForMember(dest => dest.TimeUpdated, opts => opts.MapFrom(source => source.TimeUpdated.ToDateTime())); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - #endregion - - #region Endpoint: GCVersion - - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - #endregion - - #region Endpoint: PlayerService - - x.CreateMap() - .ConvertUsing(src => src.Result != null ? src.Result.LenderSteamId : null); - - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Quests : null) - ); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - x.CreateMap().ConvertUsing(src => - { - if (src.Result == null) - { - return null; - } - else - { - return src.Result.PlayerLevel; - } - }); - - x.CreateMap() - .ForMember(dest => dest.PlaytimeLastTwoWeeks, opts => opts.ResolveUsing(src => - { - if (!src.Playtime2weeks.HasValue) - { - return (TimeSpan?)null; - } - return TimeSpan.FromMinutes(src.Playtime2weeks.Value); - })) - .ForMember(dest => dest.PlaytimeForever, opts => opts.ResolveUsing(src => - { - return TimeSpan.FromMinutes(src.PlaytimeForever); - })); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - #endregion - - #region Endpoint: SteamApps - - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Apps : null) - ); - - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - #endregion - - #region Endpoint: SteamNews - - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - #endregion - - #region Endpoint: SteamRemoteStorage - - x.CreateMap() - .ConvertUsing(src => - { - return (PublishedFileVisibility)src; - }); - x.CreateMap() - .ForMember(dest => dest.FileUrl, opts => opts.MapFrom(source => new Uri(source.FileUrl))) - .ForMember(dest => dest.PreviewUrl, opts => opts.MapFrom(source => new Uri(source.PreviewUrl))); - x.CreateMap>() - .ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>( - src.Result?.Result == 1 ? src.Result.Details : null) - ); - x.CreateMap() - .ConvertUsing( - src => Mapper.Map( - src.Result?.Result == 1 ? src.Result.Details?.SingleOrDefault() : null) - ); - - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - #endregion - - #region Endpoint: SteamUser - - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result != null ? src.Result.Players[0] : null) - ); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Players : null) - ); - - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Friends : null) - ); - - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.PlayerBans) - ); - - x.CreateMap().ConvertUsing(src => src.Gid); - - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Groups : null) - ); - - x.CreateMap().ConvertUsing(src => src.Result != null ? src.Result.SteamId : default(ulong)); - - #endregion - - #region Endpoint: SteamUserStats - - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.AchievementPercentages : null) - ); - - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.GlobalStats : null) - ); - - x.CreateMap().ConvertUsing(src => src.Result != null ? src.Result.PlayerCount : default(uint)); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - #endregion - - #region Endpoint: SteamWebAPIUtil - - x.CreateMap(); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.Interfaces : null) - ); - - #endregion - - #region Endpoint: TFItems - - x.CreateMap(); - x.CreateMap>().ConvertUsing( - src => Mapper.Map, IReadOnlyCollection>(src.Result != null ? src.Result.GoldenWrenches : null) - ); - - #endregion - - #region Endpoint: SteamEconomy - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - #endregion - - x.CreateMap().ConvertUsing(src => src.Result != null ? src.Result.ItemsGameUrl : null); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - x.CreateMap().ConvertUsing(src => src.Result != null ? src.Result.StoreStatus : default(uint)); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap().ConvertUsing( - src => Mapper.Map(src.Result) - ); - - #region Endpoint: SteamStore - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - x.CreateMap(); - - #endregion - - x.CreateMap() - .ForMember(dest => dest.GameIcon, opts => opts.MapFrom(source => source.GameIcon)) - .ForMember(dest => dest.GameLink, opts => opts.MapFrom(source => source.GameLink)) - .ForMember(dest => dest.GameLogo, opts => opts.MapFrom(source => source.GameLogo)) - .ForMember(dest => dest.GameLogoSmall, opts => opts.MapFrom(source => source.GameLogoSmall)) - .ForMember(dest => dest.GameName, opts => opts.MapFrom(source => source.GameName)); - - x.CreateMap() - .ForMember(dest => dest.Link, opts => opts.MapFrom(source => new Uri(source.GameLink))) - .ForMember(dest => dest.Icon, opts => opts.MapFrom(source => new Uri(source.GameIcon))) - .ForMember(dest => dest.Logo, opts => opts.MapFrom(source => new Uri(source.GameLogo))) - .ForMember(dest => dest.LogoSmall, opts => opts.MapFrom(source => new Uri(source.GameLogoSmall))) - .ForMember(dest => dest.Name, opts => opts.MapFrom(source => source.GameName)) - .ForMember(dest => dest.HoursOnRecord, opts => opts.MapFrom(source => !String.IsNullOrEmpty(source.HoursOnRecord) ? double.Parse(source.HoursOnRecord) : 0d)) - .ForMember(dest => dest.HoursPlayed, opts => opts.MapFrom(source => (double)source.HoursPlayed)) - .ForMember(dest => dest.StatsName, opts => opts.MapFrom(source => source.StatsName)); - - x.CreateMap() - .ForMember(dest => dest.AvatarFull, opts => opts.MapFrom(source => new Uri(source.AvatarFull))) - .ForMember(dest => dest.Avatar, opts => opts.MapFrom(source => new Uri(source.AvatarIcon))) - .ForMember(dest => dest.AvatarMedium, opts => opts.MapFrom(source => new Uri(source.AvatarMedium))) - .ForMember(dest => dest.CustomURL, opts => opts.MapFrom(source => source.CustomURL)) - .ForMember(dest => dest.MostPlayedGames, opts => opts.MapFrom(source => source.MostPlayedGames)) - .ForMember(dest => dest.Headline, opts => opts.MapFrom(source => source.Headline)) - .ForMember(dest => dest.HoursPlayedLastTwoWeeks, opts => opts.MapFrom(source => source.HoursPlayed2Wk)) - .ForMember(dest => dest.IsLimitedAccount, opts => opts.MapFrom(source => source.IsLimitedAccount == 1 ? true : false)) - .ForMember(dest => dest.Location, opts => opts.MapFrom(source => source.Location)) - .ForMember(dest => dest.MemberSince, opts => opts.MapFrom(source => source.MemberSince)) - .ForMember(dest => dest.State, opts => opts.MapFrom(source => source.OnlineState)) - .ForMember(dest => dest.StateMessage, opts => opts.MapFrom(source => source.StateMessage)) - .ForMember(dest => dest.SteamID, opts => opts.MapFrom(source => source.SteamID64)) - .ForMember(dest => dest.SteamRating, opts => opts.MapFrom(source => !String.IsNullOrEmpty(source.SteamRating) ? double.Parse(source.SteamRating) : 0d)) - .ForMember(dest => dest.Summary, opts => opts.MapFrom(source => source.Summary)) - .ForMember(dest => dest.TradeBanState, opts => opts.MapFrom(source => source.TradeBanState)) - .ForMember(dest => dest.IsVacBanned, opts => opts.MapFrom(source => source.VacBanned == 1 ? true : false)) - .ForMember(dest => dest.VisibilityState, opts => opts.MapFrom(source => source.VisibilityState)) - .ForMember(dest => dest.InGameServerIP, opts => opts.MapFrom(source => source.InGameServerIP)) - .ForMember(dest => dest.InGameInfo, opts => opts.MapFrom(source => source.InGameInfo)); - }); - - } - - if (mapper == null) - { - mapper = config.CreateMapper(); - } - - isInitialized = true; - -#if DEBUG - config.AssertConfigurationIsValid(); -#endif - } - - public static void Reset() - { - config = null; - mapper = null; - } - } -} \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/AppId.cs b/src/SteamWebAPI2/Interfaces/AppId.cs new file mode 100644 index 0000000..fb92c66 --- /dev/null +++ b/src/SteamWebAPI2/Interfaces/AppId.cs @@ -0,0 +1,16 @@ +namespace SteamWebAPI2.Interfaces +{ + public enum AppId + { + TeamFortress2 = 440, + Dota2 = 570, + Payday2 = 218620, + DefenseGrid2 = 221540, + BattleBlockTheater = 238460, + Portal2 = 620, + CounterStrikeGO = 730, + Portal2_Beta = 841, + Artifact = 583950, + DotaUnderlords = 1046930 + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/CSGOServers.cs b/src/SteamWebAPI2/Interfaces/CSGOServers.cs index 7986ba1..cb51fd8 100644 --- a/src/SteamWebAPI2/Interfaces/CSGOServers.cs +++ b/src/SteamWebAPI2/Interfaces/CSGOServers.cs @@ -1,7 +1,9 @@ using Steam.Models.CSGO; using SteamWebAPI2.Models.CSGO; using SteamWebAPI2.Utilities; +using System.Collections.Generic; using System.Threading.Tasks; +using System.Linq; namespace SteamWebAPI2.Interfaces { @@ -10,19 +12,53 @@ namespace SteamWebAPI2.Interfaces /// public class CSGOServers : ICSGOServers { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// /// - public CSGOServers(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + public CSGOServers(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "ICSGOServers_730") + ? new SteamWebInterface("ICSGOServers_730", steamWebRequest) : steamWebInterface; } + /// + /// Maps to the Steam Web API interface/method of ICSGOServers_730/GetGameMapsPlaytime/v1 + /// + /// + public async Task>> GetGameMapsPlaytimeAsync( + GameMapsPlaytimeInterval interval, + GameMapsPlaytimeGameMode gameMode, + GameMapsPlaytimeMapGroup mapGroup + ) + { + List parameters = new List(); + + parameters.AddIfHasValue(interval.ToString().ToLower(), "interval"); + parameters.AddIfHasValue(gameMode.ToString().ToLower(), "gamemode"); + parameters.AddIfHasValue(mapGroup.ToString().ToLower(), "mapgroup"); + + var steamWebResponse = await steamWebInterface.GetAsync("GetGameMapsPlaytime", 1, parameters); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return result.Playtimes.Select(x => new GameMapsPlaytimeModel + { + MapName = x.MapName, + IntervalStartTimeStamp = x.IntervalStartTimeStamp.ToDateTime(), + RelativePercentage = x.RelativePercentage + }); + }); + } + /// /// Maps to the Steam Web API interface/method of ICSGOServers_730/GetGameServersStatus/v1 /// @@ -30,10 +66,45 @@ public CSGOServers(string steamWebApiKey, ISteamWebInterface steamWebInterface = public async Task> GetGameServerStatusAsync() { var steamWebResponse = await steamWebInterface.GetAsync("GetGameServersStatus", 1); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return new ServerStatusModel + { + App = result.App == null ? null : new ServerStatusAppModel + { + Version = result.App.Version, + Timestamp = result.App.Timestamp, + Time = result.App.Time + }, + Services = result.Services == null ? null : new ServerStatusServicesModel + { + SessionsLogon = result.Services.SessionsLogon, + SteamCommunity = result.Services.SteamCommunity, + IEconItems = result.Services.IEconItems, + Leaderboards = result.Services.Leaderboards + }, + Datacenters = result.Datacenters?.Select(d => new ServerStatusDatacenterModel + { + Name = d.Name, + Capacity = d.Capacity, + Load = d.Load + }).ToList().AsReadOnly(), + Matchmaking = result.Matchmaking == null ? null : new ServerStatusMatchmakingModel + { + Scheduler = result.Matchmaking.Scheduler, + OnlineServers = result.Matchmaking.OnlineServers, + OnlinePlayers = result.Matchmaking.OnlinePlayers, + SearchingPlayers = result.Matchmaking.SearchingPlayers, + SearchSecondsAverage = result.Matchmaking.SearchSecondsAverage + } + }; + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/DOTA2Econ.cs b/src/SteamWebAPI2/Interfaces/DOTA2Econ.cs index ea2b76b..6bf5d6d 100644 --- a/src/SteamWebAPI2/Interfaces/DOTA2Econ.cs +++ b/src/SteamWebAPI2/Interfaces/DOTA2Econ.cs @@ -1,10 +1,9 @@ -using Steam.Models.DOTA2; -using SteamWebAPI2.Models.DOTA2; +using SteamWebAPI2.Models.DOTA2; using SteamWebAPI2.Utilities; using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; +using System.Linq; namespace SteamWebAPI2.Interfaces { @@ -13,35 +12,20 @@ namespace SteamWebAPI2.Interfaces /// public class DOTA2Econ : IDOTA2Econ { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface dota2WebInterface; + private readonly ISteamWebInterface dota2TestWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// /// - public DOTA2Econ(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + public DOTA2Econ(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { - this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "IEconDOTA2_570") + this.dota2WebInterface = steamWebInterface == null + ? new SteamWebInterface("IEconDOTA2_570", steamWebRequest) : steamWebInterface; - } - - /// - /// Returns a collection of in game Dota 2 items. Example: blink dagger. - /// - /// - /// - public async Task>> GetGameItemsAsync(string language = "en_us") - { - List parameters = new List(); - - parameters.AddIfHasValue(language, "language"); - - var steamWebResponse = await steamWebInterface.GetAsync("GetGameItems", 1, parameters); - - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>>(steamWebResponse); - return steamWebResponseModel; + this.dota2TestWebInterface = new SteamWebInterface("IEconDOTA2_205790", steamWebRequest); } /// @@ -50,7 +34,7 @@ public async Task>> GetGame /// /// /// - public async Task>> GetHeroesAsync(string language = "en_us", bool itemizedOnly = false) + public async Task>> GetHeroesAsync(string language = "en_us", bool itemizedOnly = false) { List parameters = new List(); @@ -59,72 +43,114 @@ public async Task>> GetHeroesAs parameters.AddIfHasValue(language, "language"); parameters.AddIfHasValue(itemizedOnlyValue, "itemizedonly"); - var steamWebResponse = await steamWebInterface.GetAsync("GetHeroes", 1, parameters); + var steamWebResponse = await dota2WebInterface.GetAsync("GetHeroes", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return result.Heroes.Select(x => new Steam.Models.DOTA2.Hero + { + Id = x.Id, + LocalizedName = x.LocalizedName, + Name = x.Name + }).ToList() + .AsReadOnly(); + }); } /// - /// It is important to note that the "items" this method is referring to are not the in game items. These are actually cosmetic items found in the DOTA 2 store and workshop. + /// Returns a collection of item rarities. /// - /// - /// + /// /// - public async Task> GetItemIconPathAsync(string iconName, string iconType = "") + public async Task>> GetRaritiesAsync(string language = "en_us") { - if (String.IsNullOrEmpty(iconName)) - { - throw new ArgumentNullException("iconName"); - } - List parameters = new List(); - parameters.AddIfHasValue(iconName, "iconname"); - parameters.AddIfHasValue(iconType, "icontype"); - - var steamWebResponse = await steamWebInterface.GetAsync("GetItemIconPath", 1, parameters); + parameters.AddIfHasValue(language, "language"); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); + var steamWebResponse = await dota2WebInterface.GetAsync("GetRarities", 1, parameters); - return steamWebResponseModel; + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return result.Rarities.Select(x => new Steam.Models.DOTA2.Rarity + { + Id = x.Id, + LocalizedName = x.LocalizedName, + Name = x.Name, + Color = x.Color, + Order = x.Order + }).ToList() + .AsReadOnly(); + }); } /// - /// Returns a collection of item rarities. + /// Returns a tournament prize pool amount for a specific league. /// - /// + /// /// - public async Task>> GetRaritiesAsync(string language = "en_us") + public async Task> GetTournamentPrizePoolAsync(uint? leagueId = null) { List parameters = new List(); - parameters.AddIfHasValue(language, "language"); - - var steamWebResponse = await steamWebInterface.GetAsync("GetRarities", 1, parameters); + parameters.AddIfHasValue(leagueId, "leagueid"); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>>(steamWebResponse); + var steamWebResponse = await dota2WebInterface.GetAsync("GetTournamentPrizePool", 1, parameters); - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return 0; + } + + return result.PrizePool; + }); } /// - /// Returns a tournament prize pool amount for a specific league. + /// It is important to note that the "items" this method is referring to are not the in game items. These are actually cosmetic items found in the DOTA 2 store and workshop. /// - /// + /// + /// /// - public async Task> GetTournamentPrizePoolAsync(uint? leagueId = null) + public async Task> GetItemIconPathAsync(string iconName, string iconType = "") { - List parameters = new List(); + if (string.IsNullOrEmpty(iconName)) + { + throw new ArgumentNullException("iconName"); + } - parameters.AddIfHasValue(leagueId, "leagueid"); + List parameters = new List(); - var steamWebResponse = await steamWebInterface.GetAsync("GetTournamentPrizePool", 1, parameters); + parameters.AddIfHasValue(iconName, "iconname"); + parameters.AddIfHasValue(iconType, "icontype"); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); + var steamWebResponse = await dota2TestWebInterface.GetAsync("GetItemIconPath", 1, parameters); - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return string.Empty; + } + + return result.Path; + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/DOTA2Fantasy.cs b/src/SteamWebAPI2/Interfaces/DOTA2Fantasy.cs deleted file mode 100644 index 6648ee9..0000000 --- a/src/SteamWebAPI2/Interfaces/DOTA2Fantasy.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Steam.Models.DOTA2; -using SteamWebAPI2.Models.DOTA2; -using SteamWebAPI2.Utilities; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace SteamWebAPI2.Interfaces -{ - public class DOTA2Fantasy : IDOTA2Fantasy - { - private ISteamWebInterface steamWebInterface; - - /// - /// Default constructor established the Steam Web API key and initializes for subsequent method calls - /// - /// - public DOTA2Fantasy(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) - { - this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "IDOTA2Fantasy_570") - : steamWebInterface; - } - - /// - /// Returns some official / league information for a Dota 2 player for fantasy sports purposes. - /// - /// - /// - public async Task> GetPlayerOfficialInfo(ulong steamId) - { - List parameters = new List(); - parameters.Add(new SteamWebRequestParameter("accountid", steamId.ToString())); - - var steamWebResponse = await steamWebInterface.GetAsync("GetPlayerOfficialInfo", 1, parameters); - - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; - } - - /// - /// Returns a collection of all professional players registered in professional Dota 2 leagues. - /// - /// - public async Task> GetProPlayerList() - { - var steamWebResponse = await steamWebInterface.GetAsync("GetProPlayerList", 1); - - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; - } - } -} \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/DOTA2Match.cs b/src/SteamWebAPI2/Interfaces/DOTA2Match.cs index 8a4fe0b..90db03d 100644 --- a/src/SteamWebAPI2/Interfaces/DOTA2Match.cs +++ b/src/SteamWebAPI2/Interfaces/DOTA2Match.cs @@ -2,45 +2,26 @@ using SteamWebAPI2.Models.DOTA2; using SteamWebAPI2.Utilities; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; using System.Threading.Tasks; +using System.Linq; namespace SteamWebAPI2.Interfaces { public class DOTA2Match : IDOTA2Match { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// /// - public DOTA2Match(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + public DOTA2Match(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "IDOTA2Match_570") + ? new SteamWebInterface("IDOTA2Match_570", steamWebRequest) : steamWebInterface; } - /// - /// Returns a collection of all leagues registered in Dota 2. - /// - /// - /// - public async Task>> GetLeagueListingAsync(string language = "en_us") - { - List parameters = new List(); - - parameters.AddIfHasValue(language, "language"); - - var steamWebResponse = await steamWebInterface.GetAsync("GetLeagueListing", 1, parameters); - - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>>(steamWebResponse); - - return steamWebResponseModel; - } - /// /// Returns a collection of all live league games and details. Live league games are games registered in a Dota 2 league and are currently being played. /// @@ -56,9 +37,104 @@ public async Task>> G var steamWebResponse = await steamWebInterface.GetAsync("GetLiveLeagueGames", 1); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return result.Games?.Select(x => new LiveLeagueGameModel + { + Players = x.Players?.Select(p => new LiveLeagueGamePlayerInfoModel + { + AccountId = p.AccountId, + HeroId = p.HeroId, + Name = p.Name, + Team = p.Team + }).ToList().AsReadOnly(), + RadiantTeam = x.RadiantTeam == null ? null : new LiveLeagueGameTeamRadiantInfoModel + { + TeamId = x.RadiantTeam.TeamId, + TeamName = x.RadiantTeam.TeamName, + TeamLogo = x.RadiantTeam.TeamLogo, + Complete = x.RadiantTeam.Complete + }, + DireTeam = x.DireTeam == null ? null : new LiveLeagueGameTeamDireInfoModel + { + TeamId = x.DireTeam.TeamId, + TeamName = x.DireTeam.TeamName, + TeamLogo = x.DireTeam.TeamLogo, + Complete = x.DireTeam.Complete + }, + LobbyId = x.LobbyId, + DireSeriesWins = x.DireSeriesWins, + RadiantSeriesWins = x.RadiantSeriesWins, + LeagueId = x.LeagueId, + MatchId = x.MatchId, + Spectators = x.Spectators, + GameNumber = x.GameNumber, + LeagueGameId = x.LeagueGameId, + LeagueSeriesId = x.LeagueSeriesId, + StreamDelaySeconds = x.StreamDelaySeconds, + LeagueTier = x.LeagueTier, + Scoreboard = x.Scoreboard == null ? null : new LiveLeagueGameScoreboardModel + { + Dire = x.Scoreboard.Dire == null ? null : new LiveLeagueGameTeamDireDetailModel + { + Abilities = x.Scoreboard.Dire.Abilities?.Select(a => new LiveLeagueGameAbilityModel + { + AbilityId = a.AbilityId, + AbilityLevel = a.AbilityLevel + }).ToList().AsReadOnly(), + Bans = x.Scoreboard.Dire.Bans?.Select(b => new LiveLeagueGameBanModel + { + HeroId = b.HeroId + }).ToList().AsReadOnly(), + BarracksState = x.Scoreboard.Dire?.BarracksState ?? 0, + Picks = x.Scoreboard.Dire.Picks?.Select(p => new LiveLeagueGamePickModel + { + HeroId = p.HeroId, + }).ToList().AsReadOnly(), + Players = x.Scoreboard.Dire.Players? + .Select(p => MapToLiveLeagueGamePlayerDetail(p)) + .ToList() + .AsReadOnly(), + Score = x.Scoreboard.Dire.Score, + TowerState = x.Scoreboard.Dire.TowerState + }, + Radiant = x.Scoreboard.Radiant == null ? null : new LiveLeagueGameTeamRadiantDetailModel + { + Abilities = x.Scoreboard.Radiant.Abilities?.Select(a => new LiveLeagueGameAbilityModel + { + AbilityId = a.AbilityId, + AbilityLevel = a.AbilityLevel + }).ToList().AsReadOnly(), + Bans = x.Scoreboard.Radiant.Bans?.Select(b => new LiveLeagueGameBanModel + { + HeroId = b.HeroId + }).ToList().AsReadOnly(), + BarracksState = x.Scoreboard.Radiant?.BarracksState ?? 0, + Picks = x.Scoreboard.Radiant.Picks?.Select(p => new LiveLeagueGamePickModel + { + HeroId = p.HeroId, + }).ToList().AsReadOnly(), + Players = x.Scoreboard.Radiant.Players? + .Select(p => MapToLiveLeagueGamePlayerDetail(p)) + .ToList() + .AsReadOnly(), + Score = x.Scoreboard.Radiant.Score, + TowerState = x.Scoreboard.Radiant.TowerState + }, + Duration = x.Scoreboard.Duration, + RoshanRespawnTimer = x.Scoreboard.RoshanRespawnTimer + }, + SeriesId = x.SeriesId, + SeriesType = x.SeriesType, + StageName = x.StageName + }).ToList().AsReadOnly(); + }); } /// @@ -74,9 +150,113 @@ public async Task> GetMatchDetailsAsync(ulon var steamWebResponse = await steamWebInterface.GetAsync("GetMatchDetails", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return new MatchDetailModel + { + Players = result.Players?.Select(p => new MatchPlayerModel + { + AccountId = p.AccountId, + PlayerSlot = p.PlayerSlot, + HeroId = p.HeroId, + Item0 = p.Item0, + Item1 = p.Item1, + Item2 = p.Item2, + Item3 = p.Item3, + Item4 = p.Item4, + Item5 = p.Item5, + Backpack0 = p.Backpack0, + Backpack1 = p.Backpack1, + Backpack2 = p.Backpack2, + ItemNeutral = p.ItemNeutral, + Kills = p.Kills, + Deaths = p.Deaths, + Assists = p.Assists, + LeaverStatus = p.LeaverStatus, + Gold = p.Gold, + LastHits = p.LastHits, + Denies = p.Denies, + GoldPerMinute = p.GoldPerMinute, + ExperiencePerMinute = p.ExperiencePerMinute, + GoldSpent = p.GoldSpent, + NetWorth = p.NetWorth, + AghanimsScepter = p.AghanimsScepter, + AghanimsShard = p.AghanimsShard, + Moonshard = p.Moonshard, + HeroDamage = p.HeroDamage, + TowerDamage = p.TowerDamage, + HeroHealing = p.HeroHealing, + ScaledHeroDamage = p.ScaledHeroDamage, + ScaledTowerDamage = p.ScaledTowerDamage, + ScaledHeroHealing = p.ScaledHeroHealing, + Level = p.Level, + AbilityUpgrades = p.AbilityUpgrades?.Select(a => new MatchPlayerAbilityUpgradeModel + { + Ability = a.Ability, + Time = a.Time, + Level = a.Level + }).ToList().AsReadOnly(), + AdditionalUnits = p.AdditionalUnits?.Select(u => new MatchPlayerAdditionalUnitModel + { + Unitname = u.Unitname, + Item0 = u.Item0, + Item1 = u.Item1, + Item2 = u.Item2, + Item3 = u.Item3, + Item4 = u.Item4, + Item5 = u.Item5, + Backpack0 = u.Backpack0, + Backpack1 = u.Backpack1, + Backpack2 = u.Backpack2, + ItemNeutral = u.ItemNeutral + }).ToList().AsReadOnly() + }).ToList().AsReadOnly(), + RadiantWin = result.RadiantWin, + PreGameDuration = result.PreGameDuration, + Duration = result.Duration, + StartTime = result.StartTime.ToDateTime(), + MatchId = result.MatchId, + MatchSequenceNumber = result.MatchSequenceNumber, + TowerStatusRadiant = result.TowerStatusRadiant, + TowerStatusDire = result.TowerStatusDire, + BarracksStatusRadiant = result.BarracksStatusRadiant, + BarracksStatusDire = result.BarracksStatusDire, + Cluster = result.Cluster, + FirstBloodTime = result.FirstBloodTime, + LobbyType = result.LobbyType, + HumanPlayers = result.HumanPlayers, + LeagueId = result.LeagueId, + PositiveVotes = result.PositiveVotes, + NegativeVotes = result.NegativeVotes, + GameMode = result.GameMode, + Engine = result.Engine, + RadiantTeamId = result.RadiantTeamId, + RadiantName = result.RadiantName, + RadiantLogo = result.RadiantLogo, + RadiantTeamComplete = result.RadiantTeamComplete, + DireTeamId = result.DireTeamId, + DireName = result.DireName, + DireLogo = result.DireLogo, + DireTeamComplete = result.DireTeamComplete, + RadiantCaptain = result.RadiantCaptain, + DireCaptain = result.DireCaptain, + RadiantScore = result.RadiantScore, + DireScore = result.DireScore, + PicksAndBans = result.PicksAndBans?.Select(pb => new MatchPickBanModel + { + IsPick = pb.IsPick, + HeroId = pb.HeroId, + Team = pb.Team, + Order = pb.Order + }).ToList().AsReadOnly() + }; + }); } /// @@ -110,9 +290,37 @@ public async Task> GetMatchHistoryAsync(uin var steamWebResponse = await steamWebInterface.GetAsync("GetMatchHistory", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return new MatchHistoryModel + { + Matches = result.Matches?.Select(m => new MatchHistoryMatchModel + { + DireTeamId = m.DireTeamId, + LobbyType = m.LobbyType, + MatchId = m.MatchId, + MatchSequenceNumber = m.MatchSequenceNumber, + Players = m.Players?.Select(p => new MatchHistoryPlayerModel + { + AccountId = p.AccountId, + PlayerSlot = p.PlayerSlot, + HeroId = p.HeroId, + }).ToList().AsReadOnly(), + RadiantTeamId = m.RadiantTeamId, + StartTime = m.StartTime + }).ToList().AsReadOnly(), + NumResults = result.NumResults, + ResultsRemaining = result.ResultsRemaining, + Status = result.Status, + TotalResults = result.TotalResults + }; + }); } /// @@ -130,11 +338,30 @@ public async Task> var steamWebResponse = await steamWebInterface.GetAsync("GetMatchHistoryBySequenceNum", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return result.Matches?.Select(m => new MatchHistoryMatchModel + { + DireTeamId = m.DireTeamId, + LobbyType = m.LobbyType, + MatchId = m.MatchId, + MatchSequenceNumber = m.MatchSequenceNumber, + Players = m.Players?.Select(p => new MatchHistoryPlayerModel + { + AccountId = p.AccountId, + PlayerSlot = p.PlayerSlot, + HeroId = p.HeroId + }).ToList().AsReadOnly(), + RadiantTeamId = m.RadiantTeamId, + StartTime = m.StartTime + }).ToList().AsReadOnly(); + }); } /// @@ -143,7 +370,7 @@ public async Task> /// /// /// - public async Task>> GetTeamInfoByTeamIdAsync(long? startAtTeamId = null, uint? teamsRequested = null) + public async Task>> GetTeamInfoByTeamIdAsync(long? startAtTeamId = null, uint? teamsRequested = null) { List parameters = new List(); @@ -152,9 +379,62 @@ public async Task>> GetTeam var steamWebResponse = await steamWebInterface.GetAsync("GetTeamInfoByTeamID", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>>(steamWebResponse); + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return result.Teams?.Select(t => new Steam.Models.DOTA2.TeamInfo + { + TeamId = t.TeamId, + Name = t.Name, + Tag = t.Tag, + TimeCreated = t.TimeCreated, + Rating = t.Rating, + CountryCode = t.CountryCode, + AdminAccountId = t.AdminAccountId, + Logo = t.Logo, + LogoSponsor = t.LogoSponsor, + Url = t.Url, + GamesPlayedWithCurrentRoster = t.GamesPlayedWithCurrentRoster, + PlayerIds = t.PlayerIds?.ToList().AsReadOnly(), + LeagueIds = t.LeagueIds?.ToList().AsReadOnly() + }).ToList().AsReadOnly(); + }); + } - return steamWebResponseModel; + private LiveLeagueGamePlayerDetailModel MapToLiveLeagueGamePlayerDetail(LiveLeagueGamePlayerDetail p) + { + return new LiveLeagueGamePlayerDetailModel + { + AccountId = p.AccountId, + Assists = p.Assists, + Deaths = p.Deaths, + Denies = p.Denies, + Gold = p.Gold, + HeroId = p.HeroId, + ExperiencePerMinute = p.ExperiencePerMinute, + GoldPerMinute = p.GoldPerMinute, + Item0 = p.Item0, + Item1 = p.Item1, + Item2 = p.Item2, + Item3 = p.Item3, + Item4 = p.Item4, + Item5 = p.Item5, + Kills = p.Kills, + LastHits = p.LastHits, + Level = p.Level, + NetWorth = p.NetWorth, + PlayerSlot = p.PlayerSlot, + PositionX = p.PositionX, + PositionY = p.PositionY, + RespawnTimer = p.RespawnTimer, + UltimateCooldown = p.UltimateCooldown, + UltimateState = p.UltimateState + }; } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/DOTA2Ticket.cs b/src/SteamWebAPI2/Interfaces/DOTA2Ticket.cs index 9c1b647..87508c6 100644 --- a/src/SteamWebAPI2/Interfaces/DOTA2Ticket.cs +++ b/src/SteamWebAPI2/Interfaces/DOTA2Ticket.cs @@ -4,16 +4,16 @@ namespace SteamWebAPI2.Interfaces { public class DOTA2Ticket : IDOTA2Ticket { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public DOTA2Ticket(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public DOTA2Ticket(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "IDOTA2Ticket_570") + ? new SteamWebInterface("IDOTA2Ticket_570", steamWebRequest) : steamWebInterface; } } diff --git a/src/SteamWebAPI2/Interfaces/EconItems.cs b/src/SteamWebAPI2/Interfaces/EconItems.cs index f62d88c..2be5233 100644 --- a/src/SteamWebAPI2/Interfaces/EconItems.cs +++ b/src/SteamWebAPI2/Interfaces/EconItems.cs @@ -1,43 +1,31 @@ -using Steam.Models.GameEconomy; -using SteamWebAPI2.Models.GameEconomy; -using SteamWebAPI2.Utilities; -using System; +using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; +using Steam.Models.GameEconomy; +using SteamWebAPI2.Models.GameEconomy; +using SteamWebAPI2.Utilities; namespace SteamWebAPI2.Interfaces { - public enum EconItemsAppId - { - TeamFortress2 = 440, - Dota2 = 570, - Payday2 = 218620, - DefenseGrid2 = 221540, - BattleBlockTheater = 238460, - Portal2 = 620, - CounterStrikeGO = 730, - Portal2_Beta = 841 - } - public class EconItems : IEconItems { + private readonly ISteamWebInterface steamWebInterface; + private uint appId; // The API only exposes certain methods for certain App Ids in the EconItems interface // I'm hard coding the values for now until I come up with a better, more dynamic solution private List validSchemaAppIds = new List(); - private List validSchemaUrlAppIds = new List(); private List validStoreMetaDataAppIds = new List(); private List validStoreStatusAppIds = new List(); - private ISteamWebInterface steamWebInterface; - /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public EconItems(string steamWebApiKey, EconItemsAppId appId, ISteamWebInterface steamWebInterface = null) + /// + public EconItems(ISteamWebRequest steamWebRequest, AppId appId, ISteamWebInterface steamWebInterface = null) { if (appId <= 0) { @@ -45,26 +33,26 @@ public EconItems(string steamWebApiKey, EconItemsAppId appId, ISteamWebInterface } this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "IEconItems_" + (uint)appId) + ? new SteamWebInterface("IEconItems_" + (uint)appId, steamWebRequest) : steamWebInterface; this.appId = (uint)appId; - validSchemaAppIds.Add((uint)EconItemsAppId.TeamFortress2); - validSchemaAppIds.Add((uint)EconItemsAppId.Dota2); - validSchemaAppIds.Add((uint)EconItemsAppId.Portal2); - validSchemaAppIds.Add((uint)EconItemsAppId.Portal2_Beta); - validSchemaAppIds.Add((uint)EconItemsAppId.CounterStrikeGO); + validSchemaAppIds.Add((uint)AppId.TeamFortress2); + validSchemaAppIds.Add((uint)AppId.Dota2); + validSchemaAppIds.Add((uint)AppId.Portal2); + validSchemaAppIds.Add((uint)AppId.Portal2_Beta); + validSchemaAppIds.Add((uint)AppId.CounterStrikeGO); - validSchemaUrlAppIds.Add((uint)EconItemsAppId.TeamFortress2); - validSchemaUrlAppIds.Add((uint)EconItemsAppId.Dota2); - validSchemaUrlAppIds.Add((uint)EconItemsAppId.CounterStrikeGO); + validSchemaUrlAppIds.Add((uint)AppId.TeamFortress2); + validSchemaUrlAppIds.Add((uint)AppId.Dota2); + validSchemaUrlAppIds.Add((uint)AppId.CounterStrikeGO); - validStoreMetaDataAppIds.Add((uint)EconItemsAppId.TeamFortress2); - validStoreMetaDataAppIds.Add((uint)EconItemsAppId.Dota2); - validStoreMetaDataAppIds.Add((uint)EconItemsAppId.CounterStrikeGO); + validStoreMetaDataAppIds.Add((uint)AppId.TeamFortress2); + validStoreMetaDataAppIds.Add((uint)AppId.Dota2); + validStoreMetaDataAppIds.Add((uint)AppId.CounterStrikeGO); - validStoreStatusAppIds.Add((uint)EconItemsAppId.TeamFortress2); + validStoreStatusAppIds.Add((uint)AppId.TeamFortress2); } /// @@ -80,55 +68,93 @@ public async Task> GetPlayerItemsAsync(ul var steamWebResponse = await steamWebInterface.GetAsync("GetPlayerItems", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return new EconItemResultModel + { + Status = result.Status, + NumBackpackSlots = result.NumBackpackSlots, + Items = result.Items?.Select(i => new EconItemModel + { + Id = i.Id, + OriginalId = i.OriginalId, + DefIndex = i.DefIndex, + Level = i.Level, + Quality = i.Quality, + Inventory = i.Inventory, + Quantity = i.Quantity, + Origin = i.Origin, + Equipped = i.Equipped?.Select(e => new EconItemEquippedModel + { + ClassId = e.ClassId, + Slot = e.Slot + }).ToList().AsReadOnly(), + Style = i.Style, + Attributes = i.Attributes?.Select(a => new EconItemAttributeModel + { + DefIndex = a.DefIndex, + Value = a.Value, + FloatValue = a.FloatValue, + AccountInfo = a.AccountInfo == null ? null : new EconItemAttributeAccountInfoModel + { + SteamId = a.AccountInfo.SteamId, + PersonaName = a.AccountInfo.PersonaName + } + }).ToList().AsReadOnly(), + FlagCannotTrade = i.FlagCannotTrade, + FlagCannotCraft = i.FlagCannotCraft + }).ToList().AsReadOnly() + }; + }); } /// - /// Returns the economy / item schema for a specific App ID. + /// Returns the item schema for TF2 specifically. /// /// /// - public async Task> GetSchemaAsync(string language = "en_us") + public async Task> GetSchemaItemsForTF2Async(string language = "en_us", uint? start = null) { - if (!validSchemaAppIds.Contains(appId)) + if (appId != (int)AppId.TeamFortress2) { - throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetSchema method.", appId)); + throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetSchemaTF2 method.", appId)); } List parameters = new List(); parameters.AddIfHasValue(language, "language"); + parameters.AddIfHasValue(start, "start"); - var steamWebResponse = await steamWebInterface.GetAsync("GetSchema", 1, parameters); - - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); + var steamWebResponse = await steamWebInterface.GetAsync("GetSchemaItems", 1, parameters); - return steamWebResponseModel; + return steamWebResponse; } /// - /// Returns the economy / item schema for TF2 specifically. + /// Returns the schema overview for TF2 specifically. /// /// /// - public async Task> GetSchemaForTF2Async(string language = "en_us") + public async Task> GetSchemaOverviewForTF2Async(string language = "en_us") { - if (this.appId != (int)EconItemsAppId.TeamFortress2) + if (appId != (int)AppId.TeamFortress2) { - throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetSchemaTF2 method.", appId)); + throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetSchemaTF2 method.", appId)); } List parameters = new List(); parameters.AddIfHasValue(language, "language"); - var steamWebResponse = await steamWebInterface.GetAsync("GetSchema", 1, parameters); + var steamWebResponse = await steamWebInterface.GetAsync("GetSchemaOverview", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse; } /// @@ -139,14 +165,15 @@ public async Task> GetSchemaUrlAsync() { if (!validSchemaUrlAppIds.Contains(appId)) { - throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetSchemaUrl method.", appId)); + throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetSchemaUrl method.", appId)); } var steamWebResponse = await steamWebInterface.GetAsync("GetSchemaURL", 1); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + return from?.Result?.ItemsGameUrl; + }); } /// @@ -158,7 +185,7 @@ public async Task> GetStoreMetaDataAsync(s { if (!validStoreMetaDataAppIds.Contains(appId)) { - throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetStoreMetaData method.", appId)); + throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetStoreMetaData method.", appId)); } List parameters = new List(); @@ -167,9 +194,123 @@ public async Task> GetStoreMetaDataAsync(s var steamWebResponse = await steamWebInterface.GetAsync("GetStoreMetaData", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return new StoreMetaDataModel + { + CarouselData = result.CarouselData == null ? null : new StoreCarouselDataModel + { + Banners = result.CarouselData.Banners?.Select(b => new StoreBannerModel + { + BaseFileName = b.BaseFileName, + Action = b.Action, + Placement = b.Placement, + ActionParam = b.ActionParam + }).ToList().AsReadOnly(), + MaxDisplayBanners = result.CarouselData.MaxDisplayBanners + }, + Tabs = result.Tabs?.Select(t => new StoreTabModel + { + Children = t.Children?.Select(c => new StoreTabChildModel + { + Name = t.ParentName, + Id = t.Id, + }).ToList().AsReadOnly(), + Default = t.Default, + Home = t.Home, + DropdownPrefabId = t.DropdownPrefabId, + Id = t.Id, + Label = t.Label, + ParentId = t.ParentId, + ParentName = t.ParentName, + UseLargeCells = t.UseLargeCells + }).ToList().AsReadOnly(), + DropdownData = result.DropdownData == null ? null : new StoreDropdownDataModel + { + Dropdowns = result.DropdownData.Dropdowns?.Select(d => new StoreDropdownModel + { + Id = d.Id, + Name = d.Name, + LabelText = d.LabelText, + Type = d.Type, + UrlHistoryParamName = d.UrlHistoryParamName + }).ToList().AsReadOnly(), + Prefabs = result.DropdownData.Prefabs.Select(p => new StorePrefabModel + { + Id = p.Id, + Name = p.Name, + Config = p.Config?.Select(c => new StoreConfigModel + { + DefaultSelectionId = c.DefaultSelectionId, + DropdownId = c.DropdownId, + Enabled = c.Enabled, + Name = c.Name + }).ToList().AsReadOnly() + }).ToList().AsReadOnly() + }, + Filters = result.Filters?.Select(f => new StoreFilterModel + { + Id = f.Id, + Name = f.Name, + UrlHistoryParamName = f.UrlHistoryParamName, + Count = f.Count, + AllElement = f.AllElement == null ? null : new StoreFilterAllElementModel + { + Id = f.AllElement.Id, + LocalizedText = f.AllElement.LocalizedText + }, + Elements = f.Elements?.Select(e => new StoreFilterElementModel + { + Id = e.Id, + LocalizedText = e.LocalizedText, + Name = e.Name + }).ToList().AsReadOnly() + }).ToList().AsReadOnly(), + HomePageData = result.HomePageData == null ? null : new StoreHomePageDataModel + { + HomeCategoryId = result.HomePageData.HomeCategoryId, + PopularItems = result.HomePageData.PopularItems?.Select(i => new StorePopularItemModel + { + DefIndex = i.DefIndex, + Order = i.Order, + }).ToList().AsReadOnly() + }, + PlayerClassData = result.PlayerClassData?.Select(pc => new StorePlayerClassDataModel + { + BaseName = pc.BaseName, + Id = pc.Id, + LocalizedText = pc.LocalizedText + }).ToList().AsReadOnly(), + Sorting = result.Sorting == null ? null : new StoreSortingModel + { + Sorters = result.Sorting.Sorters?.Select(s => new StoreSorterModel + { + Id = s.Id, + Name = s.Name, + DataType = s.DataType, + LocalizedText = s.LocalizedText, + SortField = s.SortField, + SortReversed = s.SortReversed + }).ToList().AsReadOnly(), + SortingPrefabs = result.Sorting.SortingPrefabs?.Select(sp => new StoreSortingPrefabModel + { + Id = sp.Id, + Name = sp.Name, + UrlHistoryParamName = sp.UrlHistoryParamName, + SorterIds = sp.SorterIds?.Select(si => new StoreSorterIdModel + { + Id = si.Id + }).ToList().AsReadOnly() + }).ToList().AsReadOnly() + } + }; + }); } /// @@ -180,14 +321,15 @@ public async Task> GetStoreStatusAsync() { if (!validStoreStatusAppIds.Contains(appId)) { - throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetStoreStatus method.", appId)); + throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetStoreStatus method.", appId)); } var steamWebResponse = await steamWebInterface.GetAsync("GetStoreStatus", 1); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + return from?.Result?.StoreStatus ?? 0; + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/EconService.cs b/src/SteamWebAPI2/Interfaces/EconService.cs index e4c89d2..4d86b08 100644 --- a/src/SteamWebAPI2/Interfaces/EconService.cs +++ b/src/SteamWebAPI2/Interfaces/EconService.cs @@ -1,22 +1,25 @@ -using SteamWebAPI2.Models.SteamEconomy; +using Steam.Models.SteamEconomy; +using SteamWebAPI2.Models.SteamEconomy; using SteamWebAPI2.Utilities; +using System; using System.Collections.Generic; using System.Threading.Tasks; +using System.Linq; namespace SteamWebAPI2.Interfaces { public class EconService : IEconService { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public EconService(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public EconService(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "IEconService") + ? new SteamWebInterface("IEconService", steamWebRequest) : steamWebInterface; } @@ -32,26 +35,60 @@ public EconService(string steamWebApiKey, ISteamWebInterface steamWebInterface = /// If set, trades in status k_ETradeStatus_Failed, k_ETradeStatus_RollbackFailed, k_ETradeStatus_RollbackAbandoned, and k_ETradeStatus_EscrowRollback will be included /// Unknown /// - public async Task> GetTradeHistoryAsync(uint maxTrades, uint startAfterTime = 0, ulong startAfterTradeId = 0, bool navigatingBack = false, bool getDescriptions = false, string language = "", bool includeFailed = false, bool includeTotal = false) + public async Task> GetTradeHistoryAsync( + uint maxTrades, + DateTime? startAfterTime = null, + ulong startAfterTradeId = 0, + bool navigatingBack = false, + bool getDescriptions = false, + string language = "", + bool includeFailed = false, + bool includeTotal = false) { List parameters = new List(); + ulong? startAfterTimeUnix = startAfterTime.HasValue + ? startAfterTime.Value.ToUnixTimeStamp() + : (ulong?)null; + parameters.AddIfHasValue(maxTrades, "max_trades"); - parameters.AddIfHasValue(startAfterTime, "start_after_time"); + parameters.AddIfHasValue(startAfterTimeUnix, "start_after_time"); parameters.AddIfHasValue(startAfterTradeId, "start_after_tradeid"); parameters.AddIfHasValue(navigatingBack, "navigating_back"); parameters.AddIfHasValue(getDescriptions, "get_descriptions"); parameters.AddIfHasValue(language, "language"); parameters.AddIfHasValue(includeFailed, "include_failed"); - parameters.AddIfHasValue(includeTotal, "inclue_total"); + parameters.AddIfHasValue(includeTotal, "include_total"); var steamWebResponse = await steamWebInterface.GetAsync("GetTradeHistory", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new TradeHistoryModel + { + TotalTradeCount = result.TotalTradeCount, + AreMoreAvailable = result.AreMoreAvailable, + Trades = result.Trades?.Select(t => new TradeModel + { + TradeId = t.TradeId, + TradeParterSteamId = t.TradeParterSteamId, + TimeTradeStarted = t.TimeTradeStarted.ToDateTime(), + TimeEscrowEnds = t.TimeEscrowEnds.ToDateTime(), + TradeStatus = (Steam.Models.SteamEconomy.TradeStatus)t.TradeStatus, + AssetsReceived = t.AssetsReceived?.Select(a => MapToTradedAssetModel(a)).ToList(), + AssetsGiven = t.AssetsGiven?.Select(a => MapToTradedAssetModel(a)).ToList(), + CurrencyReceived = t.CurrencyReceived?.Select(a => MapToTradedCurrencyModel(a)).ToList(), + CurrencyGiven = t.CurrencyGiven?.Select(a => MapToTradedCurrencyModel(a)).ToList() + }).ToList(), + Descriptions = result.Descriptions?.ToList() + }; + }); } /// @@ -65,28 +102,49 @@ public EconService(string steamWebApiKey, ISteamWebInterface steamWebInterface = /// Return trade offers that are not in an active state. /// A unix time value. when active_only is set, inactive offers will be returned if their state was updated since this time. Useful to get delta updates on what has changed. WARNING: If not passed, this will default to the time your account last viewed the trade offers page. To avoid this behavior use a very low or very high date. /// - public async Task> GetTradeOffersAsync(bool getSentOffers, bool getReceivedOffers, bool getDescriptions = false, string language = "", bool activeOnly = false, bool historicalOnly = false, uint timeHistoricalCutoff = 0) + public async Task> GetTradeOffersAsync( + bool getSentOffers, + bool getReceivedOffers, + bool getDescriptions = false, + string language = "", + bool activeOnly = false, + bool historicalOnly = false, + DateTime? timeHistoricalCutoff = null) { List parameters = new List(); int getSentOffersBit = getSentOffers ? 1 : 0; int getReceivedOffersBit = getReceivedOffers ? 1 : 0; + ulong? timeHistoricalCutoffUnix = timeHistoricalCutoff.HasValue + ? timeHistoricalCutoff.Value.ToUnixTimeStamp() + : (ulong?)null; + parameters.AddIfHasValue(getSentOffersBit, "get_sent_offers"); parameters.AddIfHasValue(getReceivedOffersBit, "get_received_offers"); parameters.AddIfHasValue(getDescriptions, "get_descriptions"); parameters.AddIfHasValue(language, "language"); parameters.AddIfHasValue(activeOnly, "active_only"); parameters.AddIfHasValue(historicalOnly, "historicalOnly"); - parameters.AddIfHasValue(timeHistoricalCutoff, "time_historical_cutoff"); + parameters.AddIfHasValue(timeHistoricalCutoffUnix, "time_historical_cutoff"); var steamWebResponse = await steamWebInterface.GetAsync("GetTradeOffers", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new TradeOffersResultModel + { + TradeOffersSent = result.TradeOffersSent?.Select(tos => MapToTradeOfferModel(tos)).ToList(), + TradeOffersReceived = result.TradeOffersReceived?.Select(tos => MapToTradeOfferModel(tos)).ToList(), + Descriptions = result.Descriptions == null ? null : result.Descriptions.ToList() + }; + }); } /// @@ -95,20 +153,188 @@ public EconService(string steamWebApiKey, ISteamWebInterface steamWebInterface = /// The trade offer identifier /// The language to use for item display information. /// - public async Task> GetTradeOfferAsync(ulong tradeOfferId, string language = "") + public async Task> GetTradeOfferAsync( + ulong tradeOfferId, + string language = "", + bool getDescriptions = false) { List parameters = new List(); parameters.AddIfHasValue(tradeOfferId, "tradeOfferId"); parameters.AddIfHasValue(language, "language"); + parameters.AddIfHasValue(getDescriptions, "get_descriptions"); var steamWebResponse = await steamWebInterface.GetAsync("GetTradeOffer", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return new TradeOfferResultModel + { + TradeOffer = result.TradeOffer == null ? null : new TradeOfferModel + { + TradeOfferId = result.TradeOffer.TradeOfferId, + TradePartnerSteamId = result.TradeOffer.TradePartnerSteamId, + Message = result.TradeOffer.Message, + TimeExpiration = result.TradeOffer.TimeExpiration.ToDateTime(), + TradeOfferState = (Steam.Models.SteamEconomy.TradeOfferState)result.TradeOffer.TradeOfferState, + ItemsYouWillGive = result.TradeOffer.ItemsYouWillGive?.Select(i => MapToTradeAssetModel(i)).ToList(), + ItemsYouWillReceive = result.TradeOffer.ItemsYouWillReceive?.Select(i => MapToTradeAssetModel(i)).ToList(), + IsOfferYouCreated = result.TradeOffer.IsOfferYouCreated, + TimeCreated = result.TradeOffer.TimeCreated.ToDateTime(), + TimeUpdated = result.TradeOffer.TimeUpdated.ToDateTime(), + WasCreatedFromRealTimeTrade = result.TradeOffer.WasCreatedFromRealTimeTrade, + ConfirmationMethod = (Steam.Models.SteamEconomy.TradeOfferConfirmationMethod)result.TradeOffer.ConfirmationMethod, + TimeEscrowEnds = result.TradeOffer.TimeEscrowEnds.ToDateTime() + }, + Descriptions = result.Descriptions == null ? null : result.Descriptions.ToList() + }; + }); + } + + public async Task> GetTradeStatusAsync(ulong tradeId, bool getDescriptions, string language) + { + List parameters = new List(); + parameters.AddIfHasValue(tradeId, "tradeid"); + parameters.AddIfHasValue(getDescriptions, "get_descriptions"); + parameters.AddIfHasValue(language, "language"); + var steamWebResponse = await steamWebInterface.GetAsync("GetTradeStatus", 1, parameters); + return steamWebResponse; + } + + public async Task> GetTradeOffersSummaryAsync(DateTime? timeLastVisit = null) + { + ulong? timeLastVisitUnix = timeLastVisit.HasValue + ? timeLastVisit.Value.ToUnixTimeStamp() + : (ulong?)null; + + List parameters = new List(); + parameters.AddIfHasValue(timeLastVisitUnix, "time_last_visit"); + var steamWebResponse = await steamWebInterface.GetAsync("GetTradeOffersSummary", 1, parameters); + return steamWebResponse; + } + + public async Task> DeclineTradeOfferAsync(ulong tradeOfferId) + { + List parameters = new List(); + parameters.AddIfHasValue(tradeOfferId, "tradeofferid"); + var steamWebResponse = await steamWebInterface.PostAsync("DeclineTradeOffer", 1, parameters); + return steamWebResponse; + } + + public async Task> CancelTradeOfferAsync(ulong tradeOfferId) + { + List parameters = new List(); + parameters.AddIfHasValue(tradeOfferId, "tradeofferid"); + var steamWebResponse = await steamWebInterface.PostAsync("CancelTradeOffer", 1, parameters); + return steamWebResponse; + } + + public async Task> GetTradeHoldDurationsAsync(ulong steamIdTarget, string tradeOfferAccessToken = "") + { + List parameters = new List(); + parameters.AddIfHasValue(steamIdTarget, "steamid_target"); + parameters.AddIfHasValue(tradeOfferAccessToken, "trade_offer_access_token"); + var steamWebResponse = await steamWebInterface.GetAsync("GetTradeHoldDurations", 1, parameters); + + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return new TradeHoldDurationsResultModel + { + MyEscrow = MapToTradeHoldDurationsModel(result.MyEscrow), + TheirEscrow = MapToTradeHoldDurationsModel(result.TheirEscrow), + BothEscrow = MapToTradeHoldDurationsModel(result.BothEscrow) + }; + }); + } + + private static TradedAssetModel MapToTradedAssetModel(TradedAsset ta) + { + return new TradedAssetModel + { + AppId = ta.AppId, + ContextId = ta.ContextId, + AssetId = ta.AssetId, + AmountTraded = ta.AmountTraded, + ClassId = ta.ClassId, + InstanceId = ta.InstanceId, + AssetIdAfterTrade = ta.AssetIdAfterTrade, + ContextIdAfterTrade = ta.ContextIdAfterTrade, + AssetIdAfterRollback = ta.AssetIdAfterRollback, + ContextIdAfterRollback = ta.ContextIdAfterRollback + }; + } + + private static TradedCurrencyModel MapToTradedCurrencyModel(TradedCurrency tc) + { + return new TradedCurrencyModel + { + AppId = tc.AppId, + ContextId = tc.ContextId, + CurrencyId = tc.CurrencyId, + AmountTraded = tc.AmountTraded, + ClassId = tc.ClassId, + CurrencyIdAfterTrade = tc.CurrencyIdAfterTrade, + ContextIdAfterTrade = tc.ContextIdAfterTrade, + CurrencyIdAfterRollback = tc.CurrencyIdAfterRollback, + ContextIdAfterRollback = tc.ContextIdAfterRollback + }; + } - return steamWebResponseModel; + private static TradeOfferModel MapToTradeOfferModel(TradeOffer to) + { + return new TradeOfferModel + { + TradeOfferId = to.TradeOfferId, + TradePartnerSteamId = to.TradePartnerSteamId, + Message = to.Message, + TimeExpiration = to.TimeExpiration.ToDateTime(), + TradeOfferState = (Steam.Models.SteamEconomy.TradeOfferState)to.TradeOfferState, + ItemsYouWillGive = to.ItemsYouWillGive?.Select(i => MapToTradeAssetModel(i)).ToList(), + ItemsYouWillReceive = to.ItemsYouWillReceive?.Select(i => MapToTradeAssetModel(i)).ToList(), + IsOfferYouCreated = to.IsOfferYouCreated, + TimeCreated = to.TimeCreated.ToDateTime(), + TimeUpdated = to.TimeUpdated.ToDateTime(), + WasCreatedFromRealTimeTrade = to.WasCreatedFromRealTimeTrade, + ConfirmationMethod = (Steam.Models.SteamEconomy.TradeOfferConfirmationMethod)to.ConfirmationMethod, + TimeEscrowEnds = to.TimeEscrowEnds.ToDateTime() + }; } + + private static TradeAssetModel MapToTradeAssetModel(TradeAsset ta) + { + return new TradeAssetModel + { + AppId = ta.AppId, + ContextId = ta.ContextId, + AssetId = ta.AssetId, + AmountOffered = ta.AmountOffered, + ClassId = ta.ClassId, + InstanceId = ta.InstanceId, + CurrencyId = ta.CurrencyId, + IsMissing = ta.IsMissing + }; + } + + private static TradeHoldDurationsModel MapToTradeHoldDurationsModel(TradeHoldDurations d) + { + return new TradeHoldDurationsModel + { + EscrowEndDuration = TimeSpan.FromSeconds(d.EscrowEndDurationSeconds), + EscrowEndDate = d.EscrowEndDateRfc3339, + }; + } + } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/GCVersion.cs b/src/SteamWebAPI2/Interfaces/GCVersion.cs index fe745cf..b993b54 100644 --- a/src/SteamWebAPI2/Interfaces/GCVersion.cs +++ b/src/SteamWebAPI2/Interfaces/GCVersion.cs @@ -1,39 +1,31 @@ -using Steam.Models; -using SteamWebAPI2.Models; -using SteamWebAPI2.Utilities; -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; +using Steam.Models; +using SteamWebAPI2.Models; +using SteamWebAPI2.Utilities; namespace SteamWebAPI2.Interfaces { - public enum GCVersionAppId - { - TeamFortress2 = 440, - Dota2 = 570, - CounterStrikeGO = 730 - } - public class GCVersion : IGCVersion { + private readonly ISteamWebInterface steamWebInterface; + private uint appId; // The API only exposes certain methods for certain App Ids in the EconItems interface // I'm hard coding the values for now until I come up with a better, more dynamic solution private List validClientVersionAppIds = new List(); - private List validServerVersionAppIds = new List(); - private ISteamWebInterface steamWebInterface; - /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public GCVersion(string steamWebApiKey, GCVersionAppId appId, ISteamWebInterface steamWebInterface = null) + /// + public GCVersion(ISteamWebRequest steamWebRequest, AppId appId, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "IGCVersion_" + (uint)appId) + ? new SteamWebInterface("IGCVersion_" + (uint)appId, steamWebRequest) : steamWebInterface; if (appId <= 0) @@ -43,12 +35,16 @@ public GCVersion(string steamWebApiKey, GCVersionAppId appId, ISteamWebInterface this.appId = (uint)appId; - validClientVersionAppIds.Add(440); - validClientVersionAppIds.Add(570); + validClientVersionAppIds.Add((int)AppId.TeamFortress2); + validClientVersionAppIds.Add((int)AppId.Dota2); + validClientVersionAppIds.Add((int)AppId.Artifact); + validClientVersionAppIds.Add((int)AppId.DotaUnderlords); - validServerVersionAppIds.Add(440); - validServerVersionAppIds.Add(570); - validServerVersionAppIds.Add(730); + validServerVersionAppIds.Add((int)AppId.TeamFortress2); + validServerVersionAppIds.Add((int)AppId.Dota2); + validServerVersionAppIds.Add((int)AppId.CounterStrikeGO); + validServerVersionAppIds.Add((int)AppId.Artifact); + validServerVersionAppIds.Add((int)AppId.DotaUnderlords); } /// @@ -59,14 +55,26 @@ public async Task> GetClientVersionAsyn { if (!validClientVersionAppIds.Contains(appId)) { - throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetClientVersion method.", appId)); + throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetClientVersion method.", appId)); } var steamWebResponse = await steamWebInterface.GetAsync("GetClientVersion", 1); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return new GameClientResultModel + { + Success = result.Success, + DeployVersion = result.DeployVersion, + ActiveVersion = result.ActiveVersion + }; + }); } /// @@ -77,14 +85,26 @@ public async Task> GetServerVersionAsyn { if (!validServerVersionAppIds.Contains(appId)) { - throw new InvalidOperationException(String.Format("AppId {0} is not valid for the GetServerVersion method.", appId)); + throw new InvalidOperationException(string.Format("AppId {0} is not valid for the GetServerVersion method.", appId)); } var steamWebResponse = await steamWebInterface.GetAsync("GetServerVersion", 1); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return new GameClientResultModel + { + Success = result.Success, + DeployVersion = result.DeployVersion, + ActiveVersion = result.ActiveVersion + }; + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/GameServersService.cs b/src/SteamWebAPI2/Interfaces/GameServersService.cs index 391b605..5ce78a0 100644 --- a/src/SteamWebAPI2/Interfaces/GameServersService.cs +++ b/src/SteamWebAPI2/Interfaces/GameServersService.cs @@ -1,81 +1,186 @@ -using SteamWebAPI2.Utilities; -using System.Collections.Generic; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; +using Steam.Models.GameServers; +using SteamWebAPI2.Models.GameServers; +using SteamWebAPI2.Utilities; namespace SteamWebAPI2.Interfaces { public class GameServersService : IGameServersService { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public GameServersService(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public GameServersService(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "IGameServersService") + ? new SteamWebInterface("IGameServersService", steamWebRequest) : steamWebInterface; } - public async Task> GetAccountListAsync() + /// Gets a list of game server accounts with their logon tokens. + /// + /// Collection of game server accounts attached to the account associated with the web API key. + public async Task> GetAccountListAsync() { - var steamWebResponse = await steamWebInterface.GetAsync("GetAccountList", 1); - return steamWebResponse; + var steamWebResponse = await steamWebInterface.GetAsync("GetAccountList", 1); + return steamWebResponse.MapTo((from) => + { + var result = from?.Response; + if (result == null) + { + return null; + } + + return new AccountListModel + { + Servers = result.Servers?.Select(s => new AccountServerModel + { + SteamId = s.SteamId, + LoginToken = s.LoginToken, + Memo = s.Memo, + AppId = s.AppId, + IsDeleted = s.IsDeleted, + IsExpired = s.IsExpired, + RtLastLogon = s.RtLastLogon.ToDateTime() + }).ToList(), + IsBanned = result.IsBanned, + Expires = result.Expires, + Actor = result.Actor, + LastActionTime = result.LastActionTime.ToDateTime() + }; + }); } - public async Task> CreateAccount(uint appId, string memo) + /// Creates a persistent game server account. + /// + /// Only supports TF2 and CSGO. + /// Free text to attach to server. Does nothing but act as an identifier. + /// Steam ID and LoginToken for the new server. + public async Task> CreateAccountAsync(AppId appId, string memo) { List parameters = new List(); - parameters.AddIfHasValue(appId, "appid"); + parameters.AddIfHasValue((int)appId, "appid"); parameters.AddIfHasValue(memo, "memo"); - var steamWebResponse = await steamWebInterface.PostAsync("CreateAccount", 1, parameters); - return steamWebResponse; + + var steamWebResponse = await steamWebInterface.PostAsync("CreateAccount", 1, parameters); + + return steamWebResponse.MapTo((from) => + { + var result = from?.Response; + if (result == null) + { + return null; + } + + return new CreateAccountModel + { + SteamId = result.SteamId, + LoginToken = result.LoginToken + }; + }); } - public async Task> SetMemo(ulong steamId, string memo) + /// This method changes the memo associated with the game server account. + /// Memos do not affect the account in any way. The memo shows up in the GetAccountList + /// response and serves only as a reminder of what the account is used for. + /// + /// Steam ID of the server to alter. + /// Free text to attach to server. Does nothing but act as an identifier. + /// 200 OK with no content indicates success from this endpoint. + public async Task SetMemoAsync(ulong steamId, string memo) { List parameters = new List(); parameters.AddIfHasValue(steamId, "steamid"); parameters.AddIfHasValue(memo, "memo"); - var steamWebResponse = await steamWebInterface.PostAsync("SetMemo", 1, parameters); - return steamWebResponse; + await steamWebInterface.PostAsync("SetMemo", 1, parameters); } - public async Task> ResetLoginToken(ulong steamId) + /// Generates a new login token for the specified game server + /// + /// The SteamID of the game server to reset the login token + /// New login token + public async Task> ResetLoginTokenAsync(ulong steamId) { List parameters = new List(); parameters.AddIfHasValue(steamId, "steamid"); - var steamWebResponse = await steamWebInterface.PostAsync("ResetLoginToken", 1, parameters); - return steamWebResponse; + var steamWebResponse = await steamWebInterface.PostAsync("ResetLoginToken", 1, parameters); + return steamWebResponse.MapTo((from) => + { + var result = from?.Response; + if (result == null) + { + return null; + } + + return result.LoginToken; + }); } - public async Task> DeleteAccount(ulong steamId) + /// Deletes a persistent game server account + /// + /// The SteamID of the game server account to delete + /// 200 OK with no content indicates success from this endpoint. + public async Task DeleteAccountAsync(ulong steamId) { List parameters = new List(); parameters.AddIfHasValue(steamId, "steamid"); - var steamWebResponse = await steamWebInterface.PostAsync("DeleteAccount", 1, parameters); - return steamWebResponse; + await steamWebInterface.PostAsync("DeleteAccount", 1, parameters); } - public async Task> GetAccountPublicInfo(ulong steamId) + /// Gets public information about a given game server account + /// + /// The SteamID of the game server to get info + /// Steam ID and associated App ID of the game server + public async Task> GetAccountPublicInfoAsync(ulong steamId) { List parameters = new List(); parameters.AddIfHasValue(steamId, "steamid"); - var steamWebResponse = await steamWebInterface.GetAsync("GetAccountPublicInfo", 1, parameters); - return steamWebResponse; + var steamWebResponse = await steamWebInterface.GetAsync("GetAccountPublicInfo", 1, parameters); + + return steamWebResponse.MapTo((from) => + { + var result = from?.Response; + if (result == null) + { + return null; + } + + return new AccountPublicInfoModel + { + SteamId = result.SteamId, + AppId = result.AppId + }; + }); } - public async Task> QueryLoginToken(string loginToken) + public async Task> QueryLoginTokenAsync(string loginToken) { List parameters = new List(); parameters.AddIfHasValue(loginToken, "login_token"); - var steamWebResponse = await steamWebInterface.GetAsync("QueryLoginToken", 1, parameters); - return steamWebResponse; + var steamWebResponse = await steamWebInterface.GetAsync("QueryLoginToken", 1, parameters); + return steamWebResponse.MapTo((from) => + { + var result = from?.Response; + if (result == null) + { + return null; + } + + return new QueryLoginTokenModel + { + IsBanned = result.IsBanned, + Expires = result.Expires, + SteamId = result.SteamId + }; + }); } - public async Task> GetServerSteamIDsByIP(IReadOnlyCollection serverIPs) + public async Task> GetServerSteamIDsByIPAsync(IReadOnlyCollection serverIPs) { List parameters = new List(); parameters.AddIfHasValue(serverIPs, "server_ips"); @@ -83,7 +188,7 @@ public async Task> GetServerSteamIDsByIP(IReadOnlyCol return steamWebResponse; } - public async Task> GetServerIPsBySteamID(IReadOnlyCollection steamIds) + public async Task> GetServerIPsBySteamIDAsync(IReadOnlyCollection steamIds) { List parameters = new List(); parameters.AddIfHasValue(steamIds, "server_steamids"); diff --git a/src/SteamWebAPI2/Interfaces/IDOTA2Econ.cs b/src/SteamWebAPI2/Interfaces/IDOTA2Econ.cs index 25ecd3f..7e895f9 100644 --- a/src/SteamWebAPI2/Interfaces/IDOTA2Econ.cs +++ b/src/SteamWebAPI2/Interfaces/IDOTA2Econ.cs @@ -7,13 +7,9 @@ namespace SteamWebAPI2.Interfaces { public interface IDOTA2Econ { - Task>> GetGameItemsAsync(string language = ""); + Task>> GetHeroesAsync(string language = "", bool itemizedOnly = false); - Task>> GetHeroesAsync(string language = "", bool itemizedOnly = false); - - Task> GetItemIconPathAsync(string iconName, string iconType = ""); - - Task>> GetRaritiesAsync(string language = ""); + Task>> GetRaritiesAsync(string language = ""); Task> GetTournamentPrizePoolAsync(uint? leagueId = null); } diff --git a/src/SteamWebAPI2/Interfaces/IDOTA2Fantasy.cs b/src/SteamWebAPI2/Interfaces/IDOTA2Fantasy.cs deleted file mode 100644 index 87a1daa..0000000 --- a/src/SteamWebAPI2/Interfaces/IDOTA2Fantasy.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Steam.Models.DOTA2; -using SteamWebAPI2.Utilities; -using System.Threading.Tasks; - -namespace SteamWebAPI2.Interfaces -{ - public interface IDOTA2Fantasy - { - Task> GetPlayerOfficialInfo(ulong steamId); - - Task> GetProPlayerList(); - } -} \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/IDOTA2Match.cs b/src/SteamWebAPI2/Interfaces/IDOTA2Match.cs index 20a67dc..b8e1d6a 100644 --- a/src/SteamWebAPI2/Interfaces/IDOTA2Match.cs +++ b/src/SteamWebAPI2/Interfaces/IDOTA2Match.cs @@ -7,8 +7,6 @@ namespace SteamWebAPI2.Interfaces { public interface IDOTA2Match { - Task>> GetLeagueListingAsync(string language); - Task>> GetLiveLeagueGamesAsync(uint? leagueId = null, ulong? matchId = null); Task> GetMatchDetailsAsync(ulong matchId); @@ -17,6 +15,6 @@ public interface IDOTA2Match Task>> GetMatchHistoryBySequenceNumberAsync(ulong? startAtMatchSequenceNumber = null, uint? matchesRequested = null); - Task>> GetTeamInfoByTeamIdAsync(long? startAtTeamId = default(long?), uint? teamsRequested = null); + Task>> GetTeamInfoByTeamIdAsync(long? startAtTeamId = default(long?), uint? teamsRequested = null); } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/IEconItems.cs b/src/SteamWebAPI2/Interfaces/IEconItems.cs index c063be0..b1c6cef 100644 --- a/src/SteamWebAPI2/Interfaces/IEconItems.cs +++ b/src/SteamWebAPI2/Interfaces/IEconItems.cs @@ -1,5 +1,4 @@ -using Steam.Models.DOTA2; -using Steam.Models.GameEconomy; +using Steam.Models.GameEconomy; using SteamWebAPI2.Utilities; using System.Threading.Tasks; @@ -9,9 +8,9 @@ public interface IEconItems { Task> GetPlayerItemsAsync(ulong steamId); - Task> GetSchemaAsync(string language = "en_us"); - - Task> GetSchemaForTF2Async(string language = "en_us"); + Task> GetSchemaItemsForTF2Async(string language = "en_us", uint? start = null); + + Task> GetSchemaOverviewForTF2Async(string language = "en_us"); Task> GetSchemaUrlAsync(); @@ -19,4 +18,4 @@ public interface IEconItems Task> GetStoreStatusAsync(); } -} +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/IEconService.cs b/src/SteamWebAPI2/Interfaces/IEconService.cs index 78a39a1..b29b684 100644 --- a/src/SteamWebAPI2/Interfaces/IEconService.cs +++ b/src/SteamWebAPI2/Interfaces/IEconService.cs @@ -1,5 +1,6 @@ using Steam.Models.SteamEconomy; using SteamWebAPI2.Utilities; +using System; using System.Threading.Tasks; namespace SteamWebAPI2.Interfaces @@ -18,7 +19,20 @@ public interface IEconService /// If set, trades in status k_ETradeStatus_Failed, k_ETradeStatus_RollbackFailed, k_ETradeStatus_RollbackAbandoned, and k_ETradeStatus_EscrowRollback will be included /// Unknown /// - Task> GetTradeHistoryAsync(uint maxTrades, uint startAfterTime, ulong startAfterTradeId, bool navigatingBack, bool getDescriptions, string language, bool includeFailed, bool includeTotal); + Task> GetTradeHistoryAsync( + uint maxTrades, + DateTime? startAfterTime, + ulong startAfterTradeId, + bool navigatingBack, + bool getDescriptions, + string language, + bool includeFailed, + bool includeTotal); + + Task> GetTradeStatusAsync( + ulong tradeId, + bool getDescriptions, + string language); /// /// This API gets a list of trade offers (up to a maximum of 500 sent or 1000 received regardless of time_historical_cutoff) for the account associated with the WebAPI key. You cannot call this API for accounts other than your own. @@ -29,9 +43,16 @@ public interface IEconService /// Needed if get_descriptions is set, the language to use for item descriptions. /// Return only trade offers in an active state (offers that haven't been accepted yet), or any offers that have had their state change since time_historical_cutoff. /// Return trade offers that are not in an active state. - /// A unix time value. when active_only is set, inactive offers will be returned if their state was updated since this time. Useful to get delta updates on what has changed. WARNING: If not passed, this will default to the time your account last viewed the trade offers page. To avoid this behavior use a very low or very high date. + /// A unix time value. When active_only is set, inactive offers will be returned if their state was updated since this time. Useful to get delta updates on what has changed. WARNING: If not passed, this will default to the time your account last viewed the trade offers page. To avoid this behavior use a very low or very high date. /// - Task> GetTradeOffersAsync(bool getSentOffers, bool getReceivedOffers, bool getDescriptions, string language, bool activeOnly, bool historicalOnly, uint timeHistoricalCutoff); + Task> GetTradeOffersAsync( + bool getSentOffers, + bool getReceivedOffers, + bool getDescriptions, + string language, + bool activeOnly, + bool historicalOnly, + DateTime? timeHistoricalCutoff); /// /// This API gets details about a single trade offer. The trade offer must have been sent to or from the account associated with the WebAPI key. You cannot call this API for accounts other than your own. @@ -39,10 +60,14 @@ public interface IEconService /// The trade offer identifier /// The language to use for item display information. /// - Task> GetTradeOfferAsync(ulong tradeOfferId, string language); + Task> GetTradeOfferAsync(ulong tradeOfferId, string language, bool getDescriptions); + + Task> GetTradeOffersSummaryAsync(DateTime? timeLastVisit); + + Task> DeclineTradeOfferAsync(ulong tradeOfferId); + + Task> CancelTradeOfferAsync(ulong tradeOfferId); - //Task GetTradeOffersSummary(ulong timeLastVisit); - //Task DeclineTradeOffer(ulong tradeOfferId); - //Task CancelTradeOffer(ulong tradeOfferId); + Task> GetTradeHoldDurationsAsync(ulong steamIdTarget, string tradeOfferAccessToken); } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/IGameServersService.cs b/src/SteamWebAPI2/Interfaces/IGameServersService.cs index 6439d78..1c50d89 100644 --- a/src/SteamWebAPI2/Interfaces/IGameServersService.cs +++ b/src/SteamWebAPI2/Interfaces/IGameServersService.cs @@ -1,4 +1,5 @@ -using SteamWebAPI2.Utilities; +using Steam.Models.GameServers; +using SteamWebAPI2.Utilities; using System.Collections.Generic; using System.Threading.Tasks; @@ -6,22 +7,22 @@ namespace SteamWebAPI2.Interfaces { public interface IGameServersService { - Task> GetAccountListAsync(); + Task> GetAccountListAsync(); - Task> CreateAccount(uint appid, string memo); + Task> CreateAccountAsync(AppId appId, string memo); - Task> SetMemo(ulong steamId, string memo); + Task SetMemoAsync(ulong steamId, string memo); - Task> ResetLoginToken(ulong steamId); + Task> ResetLoginTokenAsync(ulong steamId); - Task> DeleteAccount(ulong steamId); + Task DeleteAccountAsync(ulong steamId); - Task> GetAccountPublicInfo(ulong steamId); + Task> GetAccountPublicInfoAsync(ulong steamId); - Task> QueryLoginToken(string loginToken); + Task> QueryLoginTokenAsync(string loginToken); - Task> GetServerSteamIDsByIP(IReadOnlyCollection serverIPs); + Task> GetServerSteamIDsByIPAsync(IReadOnlyCollection serverIPs); - Task> GetServerIPsBySteamID(IReadOnlyCollection steamIds); + Task> GetServerIPsBySteamIDAsync(IReadOnlyCollection steamIds); } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/IPlayerService.cs b/src/SteamWebAPI2/Interfaces/IPlayerService.cs index c6dc0f1..963768b 100644 --- a/src/SteamWebAPI2/Interfaces/IPlayerService.cs +++ b/src/SteamWebAPI2/Interfaces/IPlayerService.cs @@ -16,7 +16,5 @@ public interface IPlayerService Task> GetRecentlyPlayedGamesAsync(ulong steamId); Task> GetSteamLevelAsync(ulong steamId); - - Task> IsPlayingSharedGameAsync(ulong steamId, uint appId); } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/ISteamNews.cs b/src/SteamWebAPI2/Interfaces/ISteamNews.cs index b26583f..af090e0 100644 --- a/src/SteamWebAPI2/Interfaces/ISteamNews.cs +++ b/src/SteamWebAPI2/Interfaces/ISteamNews.cs @@ -7,6 +7,6 @@ namespace SteamWebAPI2.Interfaces { public interface ISteamNews { - Task> GetNewsForAppAsync(uint appId, uint? maxLength = null, DateTime? endDate = null, uint? count = null); + Task> GetNewsForAppAsync(uint appId, uint? maxLength = null, DateTime? endDate = null, uint? count = null, string feeds = null, string[] tags = null); } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/ISteamRemoteStorage.cs b/src/SteamWebAPI2/Interfaces/ISteamRemoteStorage.cs index f951876..053caa9 100644 --- a/src/SteamWebAPI2/Interfaces/ISteamRemoteStorage.cs +++ b/src/SteamWebAPI2/Interfaces/ISteamRemoteStorage.cs @@ -12,7 +12,7 @@ public interface ISteamRemoteStorage Task>> GetPublishedFileDetailsAsync(IList publishedFileIds); - Task> GetPublishedFileDetailsAsync(ulong publishedFileId); + Task>> GetPublishedFileDetailsAsync(ulong publishedFileId); Task> GetUGCFileDetailsAsync(ulong ugcId, uint appId, ulong? steamId = null); } diff --git a/src/SteamWebAPI2/Interfaces/ISteamStore.cs b/src/SteamWebAPI2/Interfaces/ISteamStore.cs index db6678c..3fcbd3c 100644 --- a/src/SteamWebAPI2/Interfaces/ISteamStore.cs +++ b/src/SteamWebAPI2/Interfaces/ISteamStore.cs @@ -5,7 +5,7 @@ namespace SteamWebAPI2.Interfaces { internal interface ISteamStore { - Task GetStoreAppDetailsAsync(uint appId); + Task GetStoreAppDetailsAsync(uint appId, string cc = "", string language = ""); Task GetStoreFeaturedCategoriesAsync(); diff --git a/src/SteamWebAPI2/Interfaces/ISteamUserAuth.cs b/src/SteamWebAPI2/Interfaces/ISteamUserAuth.cs index afc7731..318e733 100644 --- a/src/SteamWebAPI2/Interfaces/ISteamUserAuth.cs +++ b/src/SteamWebAPI2/Interfaces/ISteamUserAuth.cs @@ -1,5 +1,6 @@ using SteamWebAPI2.Utilities; using System.Threading.Tasks; +using Steam.Models.SteamUserAuth; namespace SteamWebAPI2.Interfaces { @@ -11,6 +12,6 @@ public interface ISteamUserAuth /// App ID of the game to authenticate against /// Ticket from GetAuthSessionTicket /// Results of authentication request - Task> AuthenticateUserTicket(uint appId, string ticket); + Task> AuthenticateUserTicket(uint appId, string ticket); } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/PlayerService.cs b/src/SteamWebAPI2/Interfaces/PlayerService.cs index f5d5c2b..a9ea6ad 100644 --- a/src/SteamWebAPI2/Interfaces/PlayerService.cs +++ b/src/SteamWebAPI2/Interfaces/PlayerService.cs @@ -1,57 +1,31 @@ -using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Threading.Tasks; +using Newtonsoft.Json; using Steam.Models.SteamCommunity; using SteamWebAPI2.Models.SteamCommunity; using SteamWebAPI2.Models.SteamPlayer; using SteamWebAPI2.Utilities; -using System; -using System.Collections.Generic; -using System.Net; -using System.Threading.Tasks; namespace SteamWebAPI2.Interfaces { public class PlayerService : IPlayerService { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public PlayerService(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public PlayerService(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "IPlayerService") + ? new SteamWebInterface("IPlayerService", steamWebRequest) : steamWebInterface; } - /// - /// Returns a message which indicates if a player is playing a shared game (from their shared Steam library). - /// - /// - /// - /// - public async Task> IsPlayingSharedGameAsync(ulong steamId, uint appId) - { - List parameters = new List(); - - parameters.AddIfHasValue(steamId, "steamid"); - parameters.AddIfHasValue(appId, "appid_playing"); - - var steamWebResponse = await steamWebInterface.GetAsync("IsPlayingSharedGame", 1, parameters); - - if (steamWebResponse == null) - { - return null; - } - - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; - } - /// /// Returns a collection of badge meta data which indicates the progress towards a badge for a specific user. /// @@ -72,11 +46,20 @@ public async Task>> GetCo return null; } - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>>(steamWebResponse); + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return result.Quests?.Select(q => new BadgeQuestModel + { + QuestId = q.QuestId, + Completed = q.Completed + }).ToList().AsReadOnly(); + }); } /// @@ -97,11 +80,33 @@ public async Task> GetBadgesAsync(ulong ste return null; } - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new BadgesResultModel + { + Badges = result.Badges?.Select(b => new BadgeModel + { + BadgeId = b.BadgeId, + Level = b.Level, + CompletionTime = b.CompletionTime, + AppId = b.AppId, + BorderColor = b.BorderColor, + CommunityItemId = b.CommunityItemId, + Scarcity = b.Scarcity, + Xp = b.Xp + }).ToList().AsReadOnly(), + PlayerXp = result.PlayerXp, + PlayerLevel = result.PlayerLevel, + PlayerXpNeededToLevelUp = result.PlayerXpNeededToLevelUp, + PlayerXpNeededCurrentLevel = result.PlayerXpNeededCurrentLevel + }; + }); } /// @@ -120,11 +125,10 @@ public async Task> GetBadgesAsync(ulong ste return null; } - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + return from?.Result?.PlayerLevel; + }); } /// @@ -169,22 +173,42 @@ public async Task> GetOwnedGamesAsync(u } // for some reason, some games have trailing spaces in the result so let's get rid of them - if (steamWebResponse.Data != null && steamWebResponse.Data.Result != null && steamWebResponse.Data.Result.OwnedGames != null) + if (steamWebResponse.Data?.Result?.OwnedGames != null) { foreach (var ownedGame in steamWebResponse.Data.Result.OwnedGames) { - if (!String.IsNullOrWhiteSpace(ownedGame.Name)) + if (!string.IsNullOrWhiteSpace(ownedGame.Name)) { ownedGame.Name = ownedGame.Name.Trim(); } } } - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new OwnedGamesResultModel + { + GameCount = result.GameCount, + OwnedGames = result.OwnedGames?.Select(g => new OwnedGameModel + { + AppId = g.AppId, + Name = g.Name, + PlaytimeForever = TimeSpan.FromMinutes(g.PlaytimeForever), + ImgIconUrl = g.ImgIconUrl, + ImgLogoUrl = g.ImgLogoUrl, + HasCommunityVisibleStats = g.HasCommunityVisibleStats, + PlaytimeLastTwoWeeks = g.Playtime2weeks.HasValue + ? TimeSpan.FromMinutes(g.Playtime2weeks.Value) + : (TimeSpan?)null + }).ToList().AsReadOnly() + }; + }); } /// @@ -204,11 +228,28 @@ public async Task> GetRecently return null; } - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new RecentlyPlayedGamesResultModel + { + TotalCount = result.TotalCount, + RecentlyPlayedGames = result.RecentlyPlayedGames?.Select(g => new RecentlyPlayedGameModel + { + AppId = g.AppId, + Name = g.Name, + Playtime2Weeks = g.Playtime2Weeks, + PlaytimeForever = g.PlaytimeForever, + ImgIconUrl = g.ImgIconUrl, + ImgLogoUrl = g.ImgLogoUrl + }).ToList().AsReadOnly() + }; + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/SteamApps.cs b/src/SteamWebAPI2/Interfaces/SteamApps.cs index 2e8b325..db41c77 100644 --- a/src/SteamWebAPI2/Interfaces/SteamApps.cs +++ b/src/SteamWebAPI2/Interfaces/SteamApps.cs @@ -1,24 +1,25 @@ -using Steam.Models; + +using Steam.Models; using SteamWebAPI2.Models; using SteamWebAPI2.Utilities; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Threading.Tasks; +using System.Linq; namespace SteamWebAPI2.Interfaces { public class SteamApps : ISteamApps { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public SteamApps(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public SteamApps(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "ISteamApps") + ? new SteamWebInterface("ISteamApps", steamWebRequest) : steamWebInterface; } @@ -30,11 +31,20 @@ public async Task>> GetAppL { var steamWebResponse = await steamWebInterface.GetAsync("GetAppList", 2); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>>(steamWebResponse); + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return result.Apps?.Select(a => new SteamAppModel + { + AppId = a.AppId, + Name = a.Name + }).ToList().AsReadOnly(); + }); } /// @@ -52,11 +62,23 @@ public async Task> UpToDateCheckAs var steamWebResponse = await steamWebInterface.GetAsync("UpToDateCheck", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new SteamAppUpToDateCheckModel + { + Success = result.Success, + UpToDate = result.UpToDate, + VersionIsListable = result.VersionIsListable, + RequiredVersion = result.RequiredVersion, + Message = result.Message + }; + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/SteamEconomy.cs b/src/SteamWebAPI2/Interfaces/SteamEconomy.cs index bac125f..1e888be 100644 --- a/src/SteamWebAPI2/Interfaces/SteamEconomy.cs +++ b/src/SteamWebAPI2/Interfaces/SteamEconomy.cs @@ -1,24 +1,25 @@ -using Steam.Models.SteamEconomy; + +using Steam.Models.SteamEconomy; using SteamWebAPI2.Models.SteamEconomy; using SteamWebAPI2.Utilities; -using System; using System.Collections.Generic; using System.Threading.Tasks; +using System.Linq; namespace SteamWebAPI2.Interfaces { public class SteamEconomy : ISteamEconomy { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// /// - public SteamEconomy(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + public SteamEconomy(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "ISteamEconomy") + ? new SteamWebInterface("ISteamEconomy", steamWebRequest) : steamWebInterface; } @@ -39,16 +40,80 @@ public async Task> GetAssetClassInf for (int i = 0; i < classIds.Count; i++) { - parameters.AddIfHasValue(classIds[i], String.Format("classid{0}", i)); + parameters.AddIfHasValue(classIds[i], string.Format("classid{0}", i)); } var steamWebResponse = await steamWebInterface.GetAsync("GetAssetClassInfo", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new AssetClassInfoResultModel + { + Success = result.Success, + AssetClasses = result.AssetClasses?.Select(ac => new AssetClassInfoModel + { + ClassId = ac.ClassId, + Name = ac.Name, + MarketName = ac.MarketName, + Type = ac.Type, + MarketHashName = ac.MarketHashName, + Descriptions = ac.Descriptions?.Select(d => new AssetClassDescriptionModel + { + Value = d.Value, + Color = d.Color, + Type = d.Type, + AppData = d.AppData + }).ToList().AsReadOnly(), + Tradable = ac.Tradable, + Marketable = ac.Marketable, + Tags = ac.Tags?.Select(t => new AssetClassTagModel + { + Category = t.Category, + InternalName = t.InternalName, + Name = t.Name, + Color = t.Color, + CategoryName = t.CategoryName + }).ToList().AsReadOnly(), + Actions = ac.Actions?.Select(a => new AssetClassActionModel + { + Name = a.Name, + Link = a.Link + }).ToList().AsReadOnly(), + MarketActions = ac.MarketActions?.Select(ma => new AssetClassMarketActionModel + { + Name = ma.Name, + Link = ma.Link + }).ToList().AsReadOnly(), + Commodity = ac.Commodity, + BackgroundColor = ac.BackgroundColor, + IconUrl = ac.IconUrl, + IconUrlLarge = ac.IconUrlLarge, + FraudWarnings = ac.FraudWarnings, + AppData = ac.AppData == null ? null : new AssetClassAppDataModel + { + DefIndex = ac.AppData.DefIndex, + FilterData = ac.AppData.FilterData?.Select(fd => new AssetClassAppDataFilterModel + { + ElementIds = fd.ElementIds?.ToList().AsReadOnly(), + }).ToList().AsReadOnly(), + HighlightColor = ac.AppData.HighlightColor, + PlayerClassIds = ac.AppData.PlayerClassIds?.ToList().AsReadOnly(), + Quality = ac.AppData.Quality, + Slot = ac.AppData.Slot + }, + IconDragUrl = ac.IconDragUrl, + MarketMarketableRestriction = ac.MarketMarketableRestriction, + MarketTradableRestriction = ac.MarketTradableRestriction, + NameColor = ac.NameColor + }).ToList().AsReadOnly() + }; + }); } /// @@ -68,11 +133,86 @@ public async Task> GetAssetPricesAsync( var steamWebResponse = await steamWebInterface.GetAsync("GetAssetPrices", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new AssetPriceResultModel + { + Success = result.Success, + Assets = result.Assets?.Select(a => new AssetModel + { + Class = a.Class?.Select(c => new AssetClassModel + { + Name = c.Name, + Value = c.Value + }).ToList().AsReadOnly(), + ClassId = a.ClassId, + Date = a.Date, + Name = a.Name, + Prices = a.Prices == null ? null : new AssetPricesModel + { + USD = a.Prices.USD, + GBP = a.Prices.GBP, + EUR = a.Prices.EUR, + RUB = a.Prices.RUB, + CNY = a.Prices.CNY, + JPY = a.Prices.JPY, + KRW = a.Prices.KRW, + AUD = a.Prices.AUD, + CAD = a.Prices.CAD, + NZD = a.Prices.NZD, + MXN = a.Prices.MXN, + BRL = a.Prices.BRL, + SGD = a.Prices.SGD, + THB = a.Prices.THB, + VND = a.Prices.VND, + IDR = a.Prices.IDR, + MYR = a.Prices.MYR, + PHP = a.Prices.PHP, + NOK = a.Prices.NOK, + TRY = a.Prices.TRY, + UAH = a.Prices.UAH, + AED = a.Prices.AED, + SAR = a.Prices.SAR, + ZAR = a.Prices.ZAR, + HKD = a.Prices.HKD, + INR = a.Prices.INR, + TWD = a.Prices.TWD + }, + TagIds = a.TagIds.ToList().AsReadOnly(), + Tags = a.Tags.ToList().AsReadOnly() + }).ToList().AsReadOnly(), + TagIds = result.TagIds == null ? null : new AssetTagIdsModel + { + Tag0 = result.TagIds.Tag0, + Tag1 = result.TagIds.Tag1, + Tag2 = result.TagIds.Tag2, + Tag3 = result.TagIds.Tag3, + Tag4 = result.TagIds.Tag4, + Tag5 = result.TagIds.Tag5, + Tag6 = result.TagIds.Tag6, + Tag7 = result.TagIds.Tag7, + Tag8 = result.TagIds.Tag8 + }, + Tags = result.Tags == null ? null : new AssetTagsModel + { + Cosmetics = result.Tags.Cosmetics, + Bundles = result.Tags.Bundles, + Halloween = result.Tags.Halloween, + Limited = result.Tags.Limited, + Maps = result.Tags.Maps, + New = result.Tags.New, + Taunts = result.Tags.Taunts, + Tools = result.Tags.Tools, + Weapons = result.Tags.Weapons + } + }; + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/SteamNews.cs b/src/SteamWebAPI2/Interfaces/SteamNews.cs index cb5ae15..f56b71f 100644 --- a/src/SteamWebAPI2/Interfaces/SteamNews.cs +++ b/src/SteamWebAPI2/Interfaces/SteamNews.cs @@ -4,21 +4,22 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using System.Linq; namespace SteamWebAPI2.Interfaces { public class SteamNews : ISteamNews { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public SteamNews(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public SteamNews(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "ISteamNews") + ? new SteamWebInterface("ISteamNews", steamWebRequest) : steamWebInterface; } @@ -29,8 +30,10 @@ public SteamNews(string steamWebApiKey, ISteamWebInterface steamWebInterface = n /// /// /// + /// + /// /// - public async Task> GetNewsForAppAsync(uint appId, uint? maxLength = null, DateTime? endDate = null, uint? count = null) + public async Task> GetNewsForAppAsync(uint appId, uint? maxLength = null, DateTime? endDate = null, uint? count = null, string feeds = null, string[] tags = null) { ulong? endDateUnixTimeStamp = null; @@ -45,14 +48,37 @@ public async Task> GetNewsForAppAsync(ui parameters.AddIfHasValue(maxLength, "maxlength"); parameters.AddIfHasValue(endDateUnixTimeStamp, "enddate"); parameters.AddIfHasValue(count, "count"); + parameters.AddIfHasValue(feeds, "feeds"); + parameters.AddIfHasValue(tags, "tags"); var steamWebResponse = await steamWebInterface.GetAsync("GetNewsForApp", 2, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new SteamNewsResultModel + { + AppId = result.AppId, + NewsItems = result.NewsItems?.Select(n => new NewsItemModel + { + Gid = n.Gid, + Title = n.Title, + Url = n.Url, + IsExternalUrl = n.IsExternalUrl, + Author = n.Author, + Contents = n.Contents, + FeedLabel = n.FeedLabel, + Date = n.Date, + Feedname = n.Feedname, + Tags = n.Tags + }).ToList().AsReadOnly() + }; + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/SteamRemoteStorage.cs b/src/SteamWebAPI2/Interfaces/SteamRemoteStorage.cs index a6188b0..55fa2fd 100644 --- a/src/SteamWebAPI2/Interfaces/SteamRemoteStorage.cs +++ b/src/SteamWebAPI2/Interfaces/SteamRemoteStorage.cs @@ -1,4 +1,5 @@ -using Steam.Models; + +using Steam.Models; using SteamWebAPI2.Models; using SteamWebAPI2.Utilities; using System; @@ -12,16 +13,16 @@ namespace SteamWebAPI2.Interfaces { public class SteamRemoteStorage : ISteamRemoteStorage { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public SteamRemoteStorage(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public SteamRemoteStorage(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "ISteamRemoteStorage") + ? new SteamWebInterface("ISteamRemoteStorage", steamWebRequest) : steamWebInterface; } @@ -34,7 +35,8 @@ public SteamRemoteStorage(string steamWebApiKey, ISteamWebInterface steamWebInte /// A collection of the details of each file or null if the request failed. /// Thrown when is null. /// Thrown when is empty or is greater than the number of elements in . - public async Task>> GetPublishedFileDetailsAsync(uint itemCount, IList publishedFileIds) { + public async Task>> GetPublishedFileDetailsAsync(uint itemCount, IList publishedFileIds) + { if (publishedFileIds == null) { throw new ArgumentNullException(nameof(publishedFileIds)); @@ -58,7 +60,7 @@ public async Task>(parameters); + return await GetPublishedFileDetailsAsync(parameters); } /// @@ -83,14 +85,14 @@ public async Task /// The ID of the file for which to retrieve details. /// The details of the file or null if the request failed. - public async Task> GetPublishedFileDetailsAsync(ulong publishedFileId) + public async Task>> GetPublishedFileDetailsAsync(ulong publishedFileId) { List parameters = new List(); parameters.AddIfHasValue(1, "itemcount"); parameters.AddIfHasValue(publishedFileId, "publishedfileids[0]"); - return await GetPublishedFileDetailsAsync(parameters); + return await GetPublishedFileDetailsAsync(parameters); } /// @@ -114,11 +116,21 @@ public async Task> GetUGCFileDetailsAsync { var steamWebResponse = await steamWebInterface.GetAsync("GetUGCFileDetails", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return new UGCFileDetailsModel + { + FileName = result.FileName, + Size = result.Size, + URL = result.URL + }; + }); } catch (HttpRequestException) { @@ -132,16 +144,47 @@ public async Task> GetUGCFileDetailsAsync /// The type to which to map the data of the response. /// The parameters of the request. /// The response of the request to the API or null if the request failed. - private async Task> GetPublishedFileDetailsAsync(IList parameters) { + private async Task>> GetPublishedFileDetailsAsync(IList parameters) + { try { var steamWebResponse = await steamWebInterface.PostAsync("GetPublishedFileDetails", 1, parameters); - - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return result.Details?.Select(d => new PublishedFileDetailsModel + { + PublishedFileId = d.PublishedFileId, + Result = d.Result, + Title = d.Title, + Description = d.Description, + FileUrl = !string.IsNullOrWhiteSpace(d.FileUrl) ? new Uri(d.FileUrl) : null, + PreviewUrl = !string.IsNullOrWhiteSpace(d.PreviewUrl) ? new Uri(d.PreviewUrl) : null, + ConsumerAppId = d.ConsumerAppId, + CreatorAppId = d.CreatorAppId, + TimeCreated = d.TimeCreated, + TimeUpdated = d.TimeUpdated, + Visibility = (PublishedFileVisibility)d.Visibility, + Tags = d.Tags?.ToList().AsReadOnly(), + FileSize = d.FileSize, + Banned = d.Banned, + BanReason = d.BanReason, + Creator = d.Creator, + Favorited = d.Favorited, + FileContentHandle = d.FileContentHandle, + FileName = d.FileName, + LifetimeFavorited = d.LifetimeFavorited, + LifetimeSubscriptions = d.LifetimeSubscriptions, + PreviewContentHandle = d.PreviewContentHandle, + Subscriptions = d.Subscriptions, + Views = d.Views + }).ToList().AsReadOnly(); + }); } catch (HttpRequestException) { diff --git a/src/SteamWebAPI2/Interfaces/SteamStore.cs b/src/SteamWebAPI2/Interfaces/SteamStore.cs index 207562d..0e13928 100644 --- a/src/SteamWebAPI2/Interfaces/SteamStore.cs +++ b/src/SteamWebAPI2/Interfaces/SteamStore.cs @@ -2,28 +2,158 @@ using SteamWebAPI2.Models.SteamStore; using SteamWebAPI2.Utilities; using System.Collections.Generic; +using System.Linq; +using System.Net.Http; using System.Threading.Tasks; namespace SteamWebAPI2.Interfaces { public class SteamStore : SteamStoreInterface, ISteamStore { + public SteamStore(HttpClient httpClient) : base(httpClient) + { + } + /// /// Maps to the steam store api endpoint: GET http://store.steampowered.com/api/appdetails/ /// /// /// - public async Task GetStoreAppDetailsAsync(uint appId) + public async Task GetStoreAppDetailsAsync(uint appId, string cc = "", string language = "") { List parameters = new List(); parameters.AddIfHasValue(appId, "appids"); + parameters.AddIfHasValue(cc, "cc"); + parameters.AddIfHasValue(language, "l"); var appDetails = await CallMethodAsync("appdetails", parameters); + var appDetailsData = appDetails?.Data; + if (appDetailsData == null) + { + return null; + } - var appDetailsModel = AutoMapperConfiguration.Mapper.Map(appDetails.Data); - - return appDetailsModel; + return new StoreAppDetailsDataModel + { + Type = appDetailsData.Type, + Name = appDetailsData.Name, + SteamAppId = appDetailsData.SteamAppid, + RequiredAge = appDetailsData.RequiredAge, + ControllerSupport = appDetailsData.ControllerSupport, + IsFree = appDetailsData.IsFree, + Dlc = appDetailsData.Dlc, + DetailedDescription = appDetailsData.DetailedDescription, + AboutTheGame = appDetailsData.AboutTheGame, + ShortDescription = appDetailsData.ShortDescription, + SupportedLanguages = appDetailsData.SupportedLanguages, + HeaderImage = appDetailsData.HeaderImage, + Website = appDetailsData.Website, + PcRequirements = appDetailsData.PcRequirements, + MacRequirements = appDetailsData.MacRequirements, + LinuxRequirements = appDetailsData.LinuxRequirements, + Developers = appDetailsData.Developers, + Publishers = appDetailsData.Publishers, + PriceOverview = appDetailsData.PriceOverview == null ? null : new StorePriceOverview + { + Currency = appDetailsData.PriceOverview.Currency, + Initial = appDetailsData.PriceOverview.Initial, + Final = appDetailsData.PriceOverview.Final, + DiscountPercent = appDetailsData.PriceOverview.DiscountPercent, + InitialFormatted = appDetailsData.PriceOverview.InitialFormatted, + FinalFormatted = appDetailsData.PriceOverview.FinalFormatted + }, + Packages = appDetailsData.Packages, + PackageGroups = appDetailsData.PackageGroups?.Select(pg => new StorePackageGroupModel + { + Name = pg.Name, + Title = pg.Title, + Description = pg.Description, + SelectionText = pg.SelectionText, + SaveText = pg.SaveText, + DisplayType = pg.DisplayType, + IsRecurringSubscription = pg.IsRecurringSubscription, + Subs = pg.Subs?.Select(s => new StoreSubModel + { + PackageId = uint.Parse(s.Packageid), + PercentSavingsText = s.PercentSavingsText, + PercentSavings = s.PercentSavings, + OptionText = s.OptionText, + OptionDescription = s.OptionDescription, + CanGetFreeLicense = s.CanGetFreeLicense, + IsFreeLicense = s.IsFreeLicense, + PriceInCentsWithDiscount = s.PriceInCentsWithDiscount + }).ToArray() + }).ToArray(), + Platforms = appDetailsData.Platforms == null ? null : new StorePlatformsModel + { + Windows = appDetailsData.Platforms.Windows, + Mac = appDetailsData.Platforms.Mac, + Linux = appDetailsData.Platforms.Linux + }, + Metacritic = appDetailsData.Metacritic == null ? null : new StoreMetacriticModel + { + Score = appDetailsData.Metacritic.Score, + Url = appDetailsData.Metacritic.Url + }, + Categories = appDetailsData.Categories?.Select(c => new StoreCategoryModel + { + Id = c.Id, + Description = c.Description + }).ToArray(), + Genres = appDetailsData.Genres?.Select(g => new StoreGenreModel + { + Id = g.Id, + Description = g.Description + }).ToArray(), + Screenshots = appDetailsData.Screenshots?.Select(s => new StoreScreenshotModel + { + Id = s.Id, + PathThumbnail = s.PathThumbnail, + PathFull = s.PathFull + }).ToArray(), + Movies = appDetailsData.Movies?.Select(m => new StoreMovieModel + { + Id = m.Id, + Name = m.Name, + Thumbnail = m.Thumbnail, + Webm = m.Webm == null ? null : new StoreWebmModel + { + Resolution480 = m.Webm.Resolution480, + Max = m.Webm.Max + }, + Highlight = m.Highlight + }).ToArray(), + Recommendations = appDetailsData.Recommendations == null ? null : new StoreRecommendationsModel + { + Total = appDetailsData.Recommendations.Total + }, + Achievements = appDetailsData.Achievements == null ? null : new StoreAchievement + { + Total = appDetailsData.Achievements.Total, + Highlighted = appDetailsData.Achievements.Highlighted?.Select(h => new StoreHighlighted + { + Name = h.Name, + Path = h.Path + }).ToArray() + }, + ReleaseDate = appDetailsData.ReleaseDate == null ? null : new StoreReleaseDateModel + { + ComingSoon = appDetailsData.ReleaseDate.ComingSoon, + Date = appDetailsData.ReleaseDate.Date + }, + SupportInfo = appDetailsData.SupportInfo == null ? null : new StoreSupportInfoModel + { + Url = appDetailsData.SupportInfo.Url, + Email = appDetailsData.SupportInfo.Email + }, + Background = appDetailsData.Background, + ContentDescriptors = appDetailsData.ContentDescriptors == null ? null : new StoreContentDescriptor + { + Ids = appDetailsData.ContentDescriptors.Ids, + Notes = appDetailsData.ContentDescriptors.Notes + } + }; } /// @@ -33,10 +163,49 @@ public async Task GetStoreAppDetailsAsync(uint appId) public async Task GetStoreFeaturedCategoriesAsync() { var featuredCategories = await CallMethodAsync("featuredcategories"); + if (featuredCategories == null) + { + return null; + } - var featuredCategoriesModel = AutoMapperConfiguration.Mapper.Map(featuredCategories); - - return featuredCategoriesModel; + return new StoreFeaturedCategoriesModel + { + Specials = featuredCategories.Specials == null ? null : new StoreSpecialsModel + { + Id = uint.Parse(featuredCategories.Specials.Id), + Name = featuredCategories.Specials.Name, + Items = MapStoreItemModels(featuredCategories.Specials.Items) + }, + ComingSoon = featuredCategories.ComingSoon == null ? null : new StoreComingSoonModel + { + Id = uint.Parse(featuredCategories.ComingSoon.Id), + Name = featuredCategories.ComingSoon.Name, + Items = MapStoreItemModels(featuredCategories.ComingSoon.Items) + }, + TopSellers = featuredCategories.TopSellers == null ? null : new StoreTopSellersModel + { + Id = uint.Parse(featuredCategories.TopSellers.Id), + Name = featuredCategories.TopSellers.Name, + Items = MapStoreItemModels(featuredCategories.TopSellers.Items) + }, + NewReleases = featuredCategories.NewReleases == null ? null : new StoreNewReleasesModel + { + Id = uint.Parse(featuredCategories.NewReleases.Id), + Name = featuredCategories.NewReleases.Name, + Items = MapStoreItemModels(featuredCategories.NewReleases.Items) + }, + Genres = featuredCategories.Genres == null ? null : new StoreFeaturedCategoryGenreModel + { + Id = uint.Parse(featuredCategories.Genres.Id), + Name = featuredCategories.Genres.Name + }, + Trailerslideshow = featuredCategories.TrailerSlideshow == null ? null : new StoreTrailerSlideshowModel + { + Id = uint.Parse(featuredCategories.TrailerSlideshow.Id), + Name = featuredCategories.TrailerSlideshow.Name + }, + Status = featuredCategories.Status + }; } /// @@ -46,10 +215,119 @@ public async Task GetStoreFeaturedCategoriesAsync( public async Task GetStoreFeaturedProductsAsync() { var featuredProducts = await CallMethodAsync("featured"); + if(featuredProducts == null) + { + return null; + } - var featuredProductsModel = AutoMapperConfiguration.Mapper.Map(featuredProducts); + return new StoreFeaturedProductsModel + { + FeaturedLinux = featuredProducts.FeaturedLinux.Select(x => new StoreFeaturedLinuxModel + { + Id = x.Id, + Type = x.Type, + Name = x.Name, + Discounted = x.Discounted, + DiscountPercent = x.DiscountPercent, + OriginalPrice = x.OriginalPrice, + FinalPrice = x.FinalPrice, + Currency = x.Currency, + LargeCapsuleImage = x.LargeCapsuleImage, + SmallCapsuleImage = x.SmallCapsuleImage, + WindowsAvailable = x.WindowsAvailable, + MacAvailable = x.MacAvailable, + LinuxAvailable = x.LinuxAvailable, + StreamingvideoAvailable = x.StreamingvideoAvailable, + HeaderImage = x.HeaderImage, + ControllerSupport = x.ControllerSupport + }).ToArray(), + FeaturedMac = featuredProducts.FeaturedMac.Select(x => new StoreFeaturedMacModel + { + Id = x.Id, + Type = x.Type, + Name = x.Name, + Discounted = x.Discounted, + DiscountPercent = x.DiscountPercent, + OriginalPrice = x.OriginalPrice, + FinalPrice = x.FinalPrice, + Currency = x.Currency, + LargeCapsuleImage = x.LargeCapsuleImage, + SmallCapsuleImage = x.SmallCapsuleImage, + WindowsAvailable = x.WindowsAvailable, + MacAvailable = x.MacAvailable, + LinuxAvailable = x.LinuxAvailable, + StreamingvideoAvailable = x.StreamingvideoAvailable, + HeaderImage = x.HeaderImage, + ControllerSupport = x.ControllerSupport + }).ToArray(), + FeaturedWin = featuredProducts.FeaturedWin.Select(x => new StoreFeaturedWinModel + { + Id = x.Id, + Type = x.Type, + Name = x.Name, + Discounted = x.Discounted, + DiscountPercent = x.DiscountPercent, + OriginalPrice = x.OriginalPrice, + FinalPrice = x.FinalPrice, + Currency = x.Currency, + LargeCapsuleImage = x.LargeCapsuleImage, + SmallCapsuleImage = x.SmallCapsuleImage, + WindowsAvailable = x.WindowsAvailable, + MacAvailable = x.MacAvailable, + LinuxAvailable = x.LinuxAvailable, + StreamingvideoAvailable = x.StreamingvideoAvailable, + HeaderImage = x.HeaderImage, + ControllerSupport = x.ControllerSupport, + DiscountExpiration = x.DiscountExpiration + }).ToArray(), + LargeCapsules = featuredProducts.LargeCapsules.Select(x => new StoreLargeCapsuleModel + { + Id = x.Id, + Type = x.Type, + Name = x.Name, + Discounted = x.Discounted, + DiscountPercent = x.DiscountPercent, + OriginalPrice = x.OriginalPrice, + FinalPrice = x.FinalPrice, + Currency = x.Currency, + LargeCapsuleImage = x.LargeCapsuleImage, + SmallCapsuleImage = x.SmallCapsuleImage, + WindowsAvailable = x.WindowsAvailable, + MacAvailable = x.MacAvailable, + LinuxAvailable = x.LinuxAvailable, + StreamingvideoAvailable = x.StreamingvideoAvailable, + HeaderImage = x.HeaderImage, + ControllerSupport = x.ControllerSupport, + Headline = x.Headline + }).ToArray(), + Layout = featuredProducts.Layout, + Status = featuredProducts.Status + }; + } - return featuredProductsModel; + private StoreItemModel[] MapStoreItemModels(Item[] items) + { + return items?.Select(i => new StoreItemModel + { + Id = i.Id, + Type = i.Type, + Name = i.Name, + Discounted = i.Discounted, + DiscountPercent = i.DiscountPercent, + OriginalPrice = i.OriginalPrice, + FinalPrice = i.FinalPrice, + Currency = i.Currency, + LargeCapsuleImage = i.LargeCapsuleImage, + SmallCapsuleImage = i.SmallCapsuleImage, + WindowsAvailable = i.WindowsAvailable, + MacAvailable = i.MacAvailable, + LinuxAvailable = i.LinuxAvailable, + StreamingvideoAvailable = i.StreamingvideoAvailable, + DiscountExpiration = i.DiscountExpiration, + HeaderImage = i.HeaderImage, + Body = i.Body, + Url = i.Url + }).ToArray(); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/SteamUser.cs b/src/SteamWebAPI2/Interfaces/SteamUser.cs index e84b0d2..ed15abe 100644 --- a/src/SteamWebAPI2/Interfaces/SteamUser.cs +++ b/src/SteamWebAPI2/Interfaces/SteamUser.cs @@ -1,11 +1,11 @@ -using Steam.Models.SteamCommunity; + +using Steam.Models.SteamCommunity; using SteamWebAPI2.Exceptions; using SteamWebAPI2.Models.SteamCommunity; using SteamWebAPI2.Models.SteamPlayer; using SteamWebAPI2.Utilities; using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Net.Http; @@ -16,16 +16,16 @@ namespace SteamWebAPI2.Interfaces { public class SteamUser : ISteamUser { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public SteamUser(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public SteamUser(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "ISteamUser") + ? new SteamWebInterface("ISteamUser", steamWebRequest) : steamWebInterface; } @@ -50,11 +50,40 @@ public async Task> GetPlayerSummaryAsync(u return null; } - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + var players = from?.Result?.Players; + if (players == null || players.Count == 0) + { + return null; + } + + var p = players[0]; + + return new PlayerSummaryModel + { + SteamId = p.SteamId, + ProfileVisibility = p.ProfileVisibility, + ProfileState = p.ProfileState, + Nickname = p.Nickname, + LastLoggedOffDate = p.LastLoggedOffDate, + CommentPermission = p.CommentPermission, + ProfileUrl = p.ProfileUrl, + AvatarUrl = p.AvatarUrl, + AvatarMediumUrl = p.AvatarMediumUrl, + AvatarFullUrl = p.AvatarFullUrl, + UserStatus = p.UserStatus, + RealName = p.RealName, + PrimaryGroupId = p.PrimaryGroupId, + AccountCreatedDate = p.AccountCreatedDate, + CountryCode = p.CountryCode, + StateCode = p.StateCode, + CityCode = p.CityCode, + PlayingGameName = p.PlayingGameName, + PlayingGameId = p.PlayingGameId, + PlayingGameServerIP = p.PlayingGameServerIP + }; + }); } public async Task>> GetPlayerSummariesAsync(IReadOnlyCollection steamIds) @@ -75,11 +104,38 @@ public async Task>> Ge return null; } - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return result.Players?.Select(p => new PlayerSummaryModel + { + SteamId = p.SteamId, + ProfileVisibility = p.ProfileVisibility, + ProfileState = p.ProfileState, + Nickname = p.Nickname, + LastLoggedOffDate = p.LastLoggedOffDate, + CommentPermission = p.CommentPermission, + ProfileUrl = p.ProfileUrl, + AvatarUrl = p.AvatarUrl, + AvatarMediumUrl = p.AvatarMediumUrl, + AvatarFullUrl = p.AvatarFullUrl, + UserStatus = p.UserStatus, + RealName = p.RealName, + PrimaryGroupId = p.PrimaryGroupId, + AccountCreatedDate = p.AccountCreatedDate, + CountryCode = p.CountryCode, + StateCode = p.StateCode, + CityCode = p.CityCode, + PlayingGameName = p.PlayingGameName, + PlayingGameId = p.PlayingGameId, + PlayingGameServerIP = p.PlayingGameServerIP + }).ToList().AsReadOnly(); + }); } /// @@ -96,9 +152,21 @@ public async Task>> GetFriend var steamWebResponse = await steamWebInterface.GetAsync("GetFriendList", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map, ISteamWebResponse>>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return result.Friends?.Select(p => new FriendModel + { + SteamId = p.SteamId, + FriendSince = p.FriendSince, + Relationship = p.Relationship + }).ToList().AsReadOnly(); + }); } /// @@ -121,17 +189,31 @@ public async Task>> GetPl { List parameters = new List(); - string steamIdsParamValue = String.Join(",", steamIds); + string steamIdsParamValue = string.Join(",", steamIds); parameters.AddIfHasValue(steamIdsParamValue, "steamids"); var steamWebResponse = await steamWebInterface.GetAsync("GetPlayerBans", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo>((from) => + { + var result = from?.PlayerBans; + if (result == null) + { + return null; + } + + return result?.Select(p => new PlayerBansModel + { + CommunityBanned = p.CommunityBanned, + DaysSinceLastBan = p.DaysSinceLastBan, + EconomyBan = p.EconomyBan, + NumberOfVACBans = p.NumberOfVACBans, + SteamId = p.SteamId, + NumberOfGameBans = p.NumberOfGameBans, + VACBanned = p.VACBanned + }).ToList().AsReadOnly(); + }); } /// @@ -147,11 +229,19 @@ public async Task>> GetUserGroupsAs var steamWebResponse = await steamWebInterface.GetAsync("GetUserGroupList", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } + + return result?.Groups? + .Select(p => p.Gid) + .ToList() + .AsReadOnly(); + }); } /// @@ -173,12 +263,11 @@ public async Task> ResolveVanityUrlAsync(string vanityU { throw new VanityUrlNotResolvedException(ErrorMessages.VanityUrlNotResolved); } - - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + return from?.Result?.SteamId ?? 0; + }); } /// @@ -189,13 +278,51 @@ public async Task> ResolveVanityUrlAsync(string vanityU public async Task GetCommunityProfileAsync(ulong steamId) { HttpClient httpClient = new HttpClient(); - string xml = await httpClient.GetStringAsync(String.Format("http://steamcommunity.com/profiles/{0}?xml=1", steamId)); + string xml = await httpClient.GetStringAsync(string.Format("http://steamcommunity.com/profiles/{0}?xml=1", steamId)); var profile = DeserializeXML(xml); - var profileModel = AutoMapperConfiguration.Mapper.Map(profile); - - return profileModel; + return new SteamCommunityProfileModel + { + AvatarFull = new Uri(profile.AvatarFull), + Avatar = new Uri(profile.AvatarIcon), + AvatarMedium = new Uri(profile.AvatarMedium), + CustomURL = profile.CustomURL, + MostPlayedGames = profile.MostPlayedGames?.Select(mpg => new SteamCommunityProfileMostPlayedGameModel + { + HoursOnRecord = !string.IsNullOrEmpty(mpg.HoursOnRecord) ? double.Parse(mpg.HoursOnRecord) : 0d, + HoursPlayed = !string.IsNullOrEmpty(mpg.HoursPlayed) ? double.Parse(mpg.HoursPlayed) : 0d, + Icon = new Uri(mpg.GameIcon), + Link = new Uri(mpg.GameLink), + Logo = new Uri(mpg.GameLogo), + LogoSmall = new Uri(mpg.GameLogoSmall), + Name = mpg.GameName, + StatsName = mpg.StatsName + }).ToList().AsReadOnly(), + Headline = profile.Headline, + HoursPlayedLastTwoWeeks = !string.IsNullOrEmpty(profile.HoursPlayed2Wk) ? double.Parse(profile.HoursPlayed2Wk) : 0d, + InGameInfo = profile.InGameInfo == null ? null : new InGameInfoModel + { + GameIcon = profile.InGameInfo.GameIcon, + GameLink = profile.InGameInfo.GameLink, + GameLogo = profile.InGameInfo.GameLogo, + GameLogoSmall = profile.InGameInfo.GameLogoSmall, + GameName = profile.InGameInfo.GameName + }, + IsLimitedAccount = profile.IsLimitedAccount == 1 ? true : false, + Location = profile.Location, + MemberSince = profile.MemberSince, + State = profile.OnlineState, + StateMessage = profile.StateMessage, + SteamID = profile.SteamID64, + SteamRating = !string.IsNullOrEmpty(profile.SteamRating) ? double.Parse(profile.SteamRating) : 0d, + Summary = profile.Summary, + TradeBanState = profile.TradeBanState, + IsVacBanned = profile.VacBanned == 1 ? true : false, + VisibilityState = profile.VisibilityState, + InGameServerIP = profile.InGameServerIP, + RealName = profile.RealName + }; } private static T DeserializeXML(string xml) diff --git a/src/SteamWebAPI2/Interfaces/SteamUserAuth.cs b/src/SteamWebAPI2/Interfaces/SteamUserAuth.cs index 17cc185..3a82986 100644 --- a/src/SteamWebAPI2/Interfaces/SteamUserAuth.cs +++ b/src/SteamWebAPI2/Interfaces/SteamUserAuth.cs @@ -1,6 +1,8 @@ -using SteamWebAPI2.Utilities; + +using SteamWebAPI2.Utilities; using System.Collections.Generic; using System.Threading.Tasks; +using Steam.Models.SteamUserAuth; namespace SteamWebAPI2.Interfaces { @@ -11,11 +13,11 @@ public class SteamUserAuth : ISteamUserAuth /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public SteamUserAuth(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public SteamUserAuth(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "ISteamUserAuth") + ? new SteamWebInterface("ISteamUserAuth", steamWebRequest) : steamWebInterface; } @@ -25,12 +27,12 @@ public SteamUserAuth(string steamWebApiKey, ISteamWebInterface steamWebInterface /// App ID of the game to authenticate against /// Ticket from GetAuthSessionTicket /// Results of authentication request - public async Task> AuthenticateUserTicket(uint appId, string ticket) + public async Task> AuthenticateUserTicket(uint appId, string ticket) { List parameters = new List(); parameters.AddIfHasValue(appId, "appid"); parameters.AddIfHasValue(ticket, "ticket"); - var playingSharedGameResult = await steamWebInterface.GetAsync("AuthenticateUserTicket", 1, parameters); + var playingSharedGameResult = await steamWebInterface.GetAsync("AuthenticateUserTicket", 1, parameters); return playingSharedGameResult; } } diff --git a/src/SteamWebAPI2/Interfaces/SteamUserStats.cs b/src/SteamWebAPI2/Interfaces/SteamUserStats.cs index 3d36f40..7e3dd14 100644 --- a/src/SteamWebAPI2/Interfaces/SteamUserStats.cs +++ b/src/SteamWebAPI2/Interfaces/SteamUserStats.cs @@ -1,4 +1,5 @@ -using Steam.Models; + +using Steam.Models; using Steam.Models.SteamCommunity; using Steam.Models.SteamPlayer; using SteamWebAPI2.Models; @@ -7,23 +8,23 @@ using SteamWebAPI2.Utilities; using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Threading.Tasks; +using System.Linq; namespace SteamWebAPI2.Interfaces { public class SteamUserStats : ISteamUserStats { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public SteamUserStats(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public SteamUserStats(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "ISteamUserStats") + ? new SteamWebInterface("ISteamUserStats", steamWebRequest) : steamWebInterface; } @@ -39,11 +40,20 @@ public async Task("GetGlobalAchievementPercentagesForApp", 2, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>>(steamWebResponse); + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return result.AchievementPercentages?.Select(ap => new GlobalAchievementPercentageModel + { + Name = ap.Name, + Percent = ap.Percent + }).ToList().AsReadOnly(); + }); } /// @@ -77,16 +87,25 @@ public async Task>> GetGl for (int i = 0; i < statNames.Count; i++) { - parameters.AddIfHasValue(statNames[i], String.Format("name[{0}]", i)); + parameters.AddIfHasValue(statNames[i], string.Format("name[{0}]", i)); } var steamWebResponse = await steamWebInterface.GetAsync("GetGlobalStatsForGame", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>>(steamWebResponse); + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return result.GlobalStats?.Select(ap => new GlobalStatModel + { + Name = ap.Name, + Total = ap.Total + }).ToList().AsReadOnly(); + }); } /// @@ -101,11 +120,10 @@ public async Task> GetNumberOfCurrentPlayersForGameAsync var steamWebResponse = await steamWebInterface.GetAsync("GetNumberOfCurrentPlayers", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); - - return steamWebResponseModel; + return steamWebResponse.MapTo((from) => + { + return from?.Result.PlayerCount ?? 0; + }); } /// @@ -124,11 +142,29 @@ public async Task> GetPlayerAchi var steamWebResponse = await steamWebInterface.GetAsync("GetPlayerAchievements", 1, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new PlayerAchievementResultModel + { + Success = result.Success, + SteamId = result.SteamId, + GameName = result.GameName, + Achievements = result.Achievements?.Select(a => new PlayerAchievementModel + { + Achieved = a.Achieved, + UnlockTime = a.UnlockTime.ToDateTime(), + Name = a.Name, + Description = a.Description, + APIName = a.APIName + }).ToList().AsReadOnly() + }; + }); } /// @@ -145,11 +181,39 @@ public async Task> GetSchemaForGameA var steamWebResponse = await steamWebInterface.GetAsync("GetSchemaForGame", 2, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new SchemaForGameResultModel + { + GameName = result.GameName, + GameVersion = result.GameVersion, + AvailableGameStats = result.AvailableGameStats == null ? null : new AvailableGameStatsModel + { + Achievements = result.AvailableGameStats.Achievements?.Select(a => new SchemaGameAchievementModel + { + Name = a.Name, + DefaultValue = a.DefaultValue, + DisplayName = a.DisplayName, + Hidden = a.Hidden, + Description = a.Description, + Icon = a.Icon, + Icongray = a.Icongray + }).ToList().AsReadOnly(), + Stats = result.AvailableGameStats.Stats?.Select(s => new SchemaGameStatModel + { + Name = s.Name, + DefaultValue = s.DefaultValue, + DisplayName = s.DisplayName + }).ToList().AsReadOnly() + } + }; + }); } /// @@ -166,11 +230,30 @@ public async Task> GetUserStatsFo var steamWebResponse = await steamWebInterface.GetAsync("GetUserStatsForGame", 2, parameters); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamWebResponse); + return steamWebResponse.MapTo((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return new UserStatsForGameResultModel + { + GameName = result.GameName, + SteamId = ulong.Parse(result.SteamId), + Achievements = result.Achievements?.Select(a => new UserStatAchievementModel + { + Name = a.Name, + Achieved = a.Achieved, + }).ToList().AsReadOnly(), + Stats = result.Stats?.Select(s => new UserStatModel + { + Name = s.Name, + Value = s.Value + }).ToList().AsReadOnly() + }; + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/SteamWebAPIUtil.cs b/src/SteamWebAPI2/Interfaces/SteamWebAPIUtil.cs index 84cd468..b7bae2e 100644 --- a/src/SteamWebAPI2/Interfaces/SteamWebAPIUtil.cs +++ b/src/SteamWebAPI2/Interfaces/SteamWebAPIUtil.cs @@ -1,24 +1,25 @@ -using Steam.Models; + +using Steam.Models; using SteamWebAPI2.Models; using SteamWebAPI2.Utilities; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Threading.Tasks; +using System.Linq; namespace SteamWebAPI2.Interfaces { public class SteamWebAPIUtil : ISteamWebAPIUtil { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public SteamWebAPIUtil(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public SteamWebAPIUtil(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "ISteamWebAPIUtil") + ? new SteamWebInterface("ISteamWebAPIUtil", steamWebRequest) : steamWebInterface; } @@ -28,13 +29,16 @@ public SteamWebAPIUtil(string steamWebApiKey, ISteamWebInterface steamWebInterfa /// public async Task> GetServerInfoAsync() { - var steamServerInfo = await steamWebInterface.GetAsync("GetServerInfo", 1); + var steamWebResponse = await steamWebInterface.GetAsync("GetServerInfo", 1); - var steamServerInfoModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>(steamServerInfo); - - return steamServerInfoModel; + return steamWebResponse.MapTo((from) => + { + return new SteamServerInfoModel + { + ServerTime = from?.ServerTime ?? 0, + ServerTimeString = from?.ServerTimeString + }; + }); } /// @@ -45,11 +49,33 @@ public async Task>> G { var steamWebResponse = await steamWebInterface.GetAsync("GetSupportedAPIList", 1); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>>(steamWebResponse); + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return result.Interfaces?.Select(i => new SteamInterfaceModel + { + Name = i.Name, + Methods = i.Methods?.Select(m => new SteamMethodModel + { + Description = m.Description, + HttpMethod = m.HttpMethod, + Name = m.Name, + Version = m.Version, + Parameters = m.Parameters?.Select(p => new SteamParameterModel + { + Name = p.Name, + Type = p.Type, + Description = p.Description, + IsOptional = p.IsOptional + }).ToList().AsReadOnly() + }).ToList().AsReadOnly() + }).ToList().AsReadOnly(); + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Interfaces/TFItems.cs b/src/SteamWebAPI2/Interfaces/TFItems.cs index 983e0c1..293098c 100644 --- a/src/SteamWebAPI2/Interfaces/TFItems.cs +++ b/src/SteamWebAPI2/Interfaces/TFItems.cs @@ -1,24 +1,24 @@ -using Steam.Models.TF2; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Steam.Models.TF2; using SteamWebAPI2.Models.TF2; using SteamWebAPI2.Utilities; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Threading.Tasks; namespace SteamWebAPI2.Interfaces { public class TFItems : ITFItems { - private ISteamWebInterface steamWebInterface; + private readonly ISteamWebInterface steamWebInterface; /// /// Default constructor established the Steam Web API key and initializes for subsequent method calls /// - /// - public TFItems(string steamWebApiKey, ISteamWebInterface steamWebInterface = null) + /// + public TFItems(ISteamWebRequest steamWebRequest, ISteamWebInterface steamWebInterface = null) { this.steamWebInterface = steamWebInterface == null - ? new SteamWebInterface(steamWebApiKey, "ITFItems_440") + ? new SteamWebInterface("ITFItems_440", steamWebRequest) : steamWebInterface; } @@ -30,11 +30,22 @@ public async Task>> Get { var steamWebResponse = await steamWebInterface.GetAsync("GetGoldenWrenches", 2); - var steamWebResponseModel = AutoMapperConfiguration.Mapper.Map< - ISteamWebResponse, - ISteamWebResponse>>(steamWebResponse); + return steamWebResponse.MapTo>((from) => + { + var result = from?.Result; + if (result == null) + { + return null; + } - return steamWebResponseModel; + return result.GoldenWrenches?.Select(i => new GoldenWrenchModel + { + ItemId = i.ItemId, + SteamId = i.SteamId, + WrenchNumber = i.WrenchNumber, + Timestamp = i.Timestamp + }).ToList().AsReadOnly(); + }); } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/CSGO/GameMapsPlaytimeContainer.cs b/src/SteamWebAPI2/Models/CSGO/GameMapsPlaytimeContainer.cs new file mode 100644 index 0000000..adad2d1 --- /dev/null +++ b/src/SteamWebAPI2/Models/CSGO/GameMapsPlaytimeContainer.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Newtonsoft.Json; +using SteamWebAPI2.Utilities.JsonConverters; + +namespace SteamWebAPI2.Models.CSGO +{ + public class GameMapsPlaytime + { + public ulong IntervalStartTimeStamp { get; set; } + public string MapName { get; set; } + public float RelativePercentage { get; set; } + } + + public class GameMapsPlaytimeResult + { + public IEnumerable Playtimes { get; set; } + } + + public class GameMapsPlaytimeContainer + { + [JsonConverter(typeof(GameMapsPlaytimeConverter))] + public GameMapsPlaytimeResult Result { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/DOTA2/GameItemResultContainer.cs b/src/SteamWebAPI2/Models/DOTA2/GameItemResultContainer.cs index 4f8c204..447bfa9 100644 --- a/src/SteamWebAPI2/Models/DOTA2/GameItemResultContainer.cs +++ b/src/SteamWebAPI2/Models/DOTA2/GameItemResultContainer.cs @@ -20,7 +20,7 @@ internal class GameItem [JsonProperty(PropertyName = "localized_name")] public string LocalizedName { get; set; } - public bool IsAvailableAtSecretShop { get { return SecretShop == 1 ? true : false; } } + public bool IsAvailableAtSecretShop { get { return SecretShop == 1 ? true : false; } } public bool IsAvailableAtSideShop { get { return SideShop == 1 ? true : false; } } public bool IsRecipe { get { return Recipe == 1 ? true : false; } } } diff --git a/src/SteamWebAPI2/Models/DOTA2/HeroResultContainer.cs b/src/SteamWebAPI2/Models/DOTA2/HeroResultContainer.cs index 8db2f7c..397d817 100644 --- a/src/SteamWebAPI2/Models/DOTA2/HeroResultContainer.cs +++ b/src/SteamWebAPI2/Models/DOTA2/HeroResultContainer.cs @@ -7,7 +7,7 @@ internal class Hero { public string Name { get; set; } public uint Id { get; set; } - + [JsonProperty(PropertyName = "localized_name")] public string LocalizedName { get; set; } } diff --git a/src/SteamWebAPI2/Models/DOTA2/LiveLeagueGameResultContainer.cs b/src/SteamWebAPI2/Models/DOTA2/LiveLeagueGameResultContainer.cs index 78b4b42..2dbda09 100644 --- a/src/SteamWebAPI2/Models/DOTA2/LiveLeagueGameResultContainer.cs +++ b/src/SteamWebAPI2/Models/DOTA2/LiveLeagueGameResultContainer.cs @@ -1,6 +1,5 @@ using Newtonsoft.Json; using Steam.Models.DOTA2; -using SteamWebAPI2.Interfaces; using System.Collections.Generic; namespace SteamWebAPI2.Models.DOTA2 @@ -34,8 +33,8 @@ internal class LiveLeagueGameTeamRadiantDetail public IList Players { get; set; } public IList Abilities { get; set; } - public TowerStateModel TowerStates { get { return new TowerStateModel(TowerState); } } - public TowerStateModel BarracksStates { get { return new TowerStateModel(BarracksState); } } + public TowerState TowerStates { get { return new TowerState(TowerState); } } + public TowerState BarracksStates { get { return new TowerState(BarracksState); } } } internal class LiveLeagueGameTeamDireInfo @@ -67,7 +66,7 @@ internal class LiveLeagueGameTeamDireDetail public IList Players { get; set; } public IList Abilities { get; set; } - public TowerStateModel TowerStates { get { return new TowerStateModel(TowerState); } } + public TowerState TowerStates { get { return new TowerState(TowerState); } } } internal class LiveLeagueGameScoreboard @@ -193,12 +192,12 @@ internal class LiveLeagueGamePlayerDetail [JsonProperty(PropertyName = "ultimate_cooldown")] public uint UltimateCooldown { get; set; } - public uint Item0 { get; set; } - public uint Item1 { get; set; } - public uint Item2 { get; set; } - public uint Item3 { get; set; } - public uint Item4 { get; set; } - public uint Item5 { get; set; } + public int Item0 { get; set; } + public int Item1 { get; set; } + public int Item2 { get; set; } + public int Item3 { get; set; } + public int Item4 { get; set; } + public int Item5 { get; set; } [JsonProperty(PropertyName = "respawn_timer")] public uint RespawnTimer { get; set; } diff --git a/src/SteamWebAPI2/Models/DOTA2/MatchDetailResultContainer.cs b/src/SteamWebAPI2/Models/DOTA2/MatchDetailResultContainer.cs index 759911a..e2d0fa9 100644 --- a/src/SteamWebAPI2/Models/DOTA2/MatchDetailResultContainer.cs +++ b/src/SteamWebAPI2/Models/DOTA2/MatchDetailResultContainer.cs @@ -10,6 +10,41 @@ internal class MatchPlayerAbilityUpgrade public uint Level { get; set; } } + internal class MatchPlayerAdditionalUnit + { + public string Unitname { get; set; } + + [JsonProperty(PropertyName = "item_0")] + public uint Item0 { get; set; } + + [JsonProperty(PropertyName = "item_1")] + public uint Item1 { get; set; } + + [JsonProperty(PropertyName = "item_2")] + public uint Item2 { get; set; } + + [JsonProperty(PropertyName = "item_3")] + public uint Item3 { get; set; } + + [JsonProperty(PropertyName = "item_4")] + public uint Item4 { get; set; } + + [JsonProperty(PropertyName = "item_5")] + public uint Item5 { get; set; } + + [JsonProperty(PropertyName = "backpack_0")] + public uint Backpack0 { get; set; } + + [JsonProperty(PropertyName = "backpack_1")] + public uint Backpack1 { get; set; } + + [JsonProperty(PropertyName = "backpack_2")] + public uint Backpack2 { get; set; } + + [JsonProperty(PropertyName = "item_neutral")] + public uint ItemNeutral { get; set; } + } + internal class MatchPlayer { [JsonProperty(PropertyName = "account_id")] @@ -39,6 +74,18 @@ internal class MatchPlayer [JsonProperty(PropertyName = "item_5")] public uint Item5 { get; set; } + [JsonProperty(PropertyName = "backpack_0")] + public uint Backpack0 { get; set; } + + [JsonProperty(PropertyName = "backpack_1")] + public uint Backpack1 { get; set; } + + [JsonProperty(PropertyName = "backpack_2")] + public uint Backpack2 { get; set; } + + [JsonProperty(PropertyName = "item_neutral")] + public uint ItemNeutral { get; set; } + public uint Kills { get; set; } public uint Deaths { get; set; } public uint Assists { get; set; } @@ -62,6 +109,17 @@ internal class MatchPlayer [JsonProperty(PropertyName = "gold_spent")] public uint GoldSpent { get; set; } + [JsonProperty(PropertyName = "net_worth")] + public uint NetWorth { get; set; } + + [JsonProperty(PropertyName = "aghanims_scepter")] + public uint AghanimsScepter { get; set; } + + [JsonProperty(PropertyName = "aghanims_shard")] + public uint AghanimsShard { get; set; } + + public uint Moonshard { get; set; } + [JsonProperty(PropertyName = "hero_damage")] public uint HeroDamage { get; set; } @@ -71,10 +129,22 @@ internal class MatchPlayer [JsonProperty(PropertyName = "hero_healing")] public uint HeroHealing { get; set; } + [JsonProperty(PropertyName = "scaled_hero_damage")] + public uint ScaledHeroDamage { get; set; } + + [JsonProperty(PropertyName = "scaled_tower_damage")] + public uint ScaledTowerDamage { get; set; } + + [JsonProperty(PropertyName = "scaled_hero_healing")] + public uint ScaledHeroHealing { get; set; } + public uint Level { get; set; } [JsonProperty(PropertyName = "ability_upgrades")] public IList AbilityUpgrades { get; set; } + + [JsonProperty(PropertyName = "additional_units")] + public IList AdditionalUnits { get; set; } } internal class MatchPickBan @@ -96,6 +166,9 @@ internal class MatchDetailResult [JsonProperty(PropertyName = "radiant_win")] public bool RadiantWin { get; set; } + [JsonProperty(PropertyName = "pre_game_duration")] + public uint PreGameDuration { get; set; } + public uint Duration { get; set; } [JsonProperty(PropertyName = "start_time")] @@ -105,7 +178,7 @@ internal class MatchDetailResult public ulong MatchId { get; set; } [JsonProperty(PropertyName = "match_seq_num")] - public uint MatchSequenceNumber { get; set; } + public ulong MatchSequenceNumber { get; set; } [JsonProperty(PropertyName = "tower_status_radiant")] public uint TowerStatusRadiant { get; set; } @@ -174,6 +247,12 @@ internal class MatchDetailResult [JsonProperty(PropertyName = "dire_captain")] public uint DireCaptain { get; set; } + [JsonProperty(PropertyName = "radiant_score")] + public uint RadiantScore { get; set; } + + [JsonProperty(PropertyName = "dire_score")] + public uint DireScore { get; set; } + [JsonProperty(PropertyName = "picks_bans")] public IList PicksAndBans { get; set; } } diff --git a/src/SteamWebAPI2/Models/DOTA2/MatchHistoryResultContainer.cs b/src/SteamWebAPI2/Models/DOTA2/MatchHistoryResultContainer.cs index 7afc0f2..7c1204e 100644 --- a/src/SteamWebAPI2/Models/DOTA2/MatchHistoryResultContainer.cs +++ b/src/SteamWebAPI2/Models/DOTA2/MatchHistoryResultContainer.cs @@ -11,7 +11,7 @@ internal class MatchHistoryMatch public ulong MatchId { get; set; } [JsonProperty(PropertyName = "match_seq_num")] - public uint MatchSequenceNumber { get; set; } + public ulong MatchSequenceNumber { get; set; } [JsonProperty(PropertyName = "start_time")] [JsonConverter(typeof(UnixTimeJsonConverter))] diff --git a/src/SteamWebAPI2/Models/GameEconomy/SchemaItemResultContainer.cs b/src/SteamWebAPI2/Models/GameEconomy/SchemaItemResultContainer.cs new file mode 100644 index 0000000..1be24b4 --- /dev/null +++ b/src/SteamWebAPI2/Models/GameEconomy/SchemaItemResultContainer.cs @@ -0,0 +1,26 @@ +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace SteamWebAPI2.Models.GameEconomy +{ + public class SchemaItemsResult + { + [JsonProperty("status")] + public uint Status { get; set; } + + [JsonProperty("items_game_url")] + public string ItemsGameUrl { get; set; } + + [JsonProperty("items")] + public IList Items { get; set; } + + [JsonProperty("next")] + public uint? Next { get; set; } + } + + public class SchemaItemsResultContainer + { + [JsonProperty("result")] + public SchemaItemsResult Result { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/GameEconomy/SchemaOverviewResultContainer.cs b/src/SteamWebAPI2/Models/GameEconomy/SchemaOverviewResultContainer.cs new file mode 100644 index 0000000..a6b00fd --- /dev/null +++ b/src/SteamWebAPI2/Models/GameEconomy/SchemaOverviewResultContainer.cs @@ -0,0 +1,44 @@ +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace SteamWebAPI2.Models.GameEconomy +{ + public class SchemaOverviewResult + { + [JsonProperty("status")] + public uint Status { get; set; } + + [JsonProperty("items_game_url")] + public string ItemsGameUrl { get; set; } + + [JsonProperty("qualities")] + public SchemaQualities Qualities { get; set; } + + [JsonProperty("originNames")] + public IList OriginNames { get; set; } + + [JsonProperty("attributes")] + public IList Attributes { get; set; } + + [JsonProperty("item_sets")] + public IList ItemSets { get; set; } + + [JsonProperty("attribute_controlled_attached_particles")] + public IList AttributeControlledAttachedParticles { get; set; } + + [JsonProperty("item_levels")] + public IList ItemLevels { get; set; } + + [JsonProperty("kill_eater_score_types")] + public IList KillEaterScoreTypes { get; set; } + + [JsonProperty("string_lookups")] + public IList StringLookups { get; set; } + } + + public class SchemaOverviewResultContainer + { + [JsonProperty("result")] + public SchemaOverviewResult Result { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/GameEconomy/SchemaResultContainer.cs b/src/SteamWebAPI2/Models/GameEconomy/SchemaResultContainer.cs index 09635b2..814f28c 100644 --- a/src/SteamWebAPI2/Models/GameEconomy/SchemaResultContainer.cs +++ b/src/SteamWebAPI2/Models/GameEconomy/SchemaResultContainer.cs @@ -3,7 +3,7 @@ namespace SteamWebAPI2.Models.GameEconomy { - internal class SchemaQualities + public class SchemaQualities { /// /// Normal item rarity: https://wiki.teamfortress.com/wiki/Normal @@ -99,7 +99,7 @@ internal class SchemaQualities public uint PaintKitWeapon { get; set; } } - internal class SchemaOriginName + public class SchemaOriginName { [JsonProperty("origin")] public uint Origin { get; set; } @@ -108,7 +108,7 @@ internal class SchemaOriginName public string Name { get; set; } } - internal class SchemaCapabilities + public class SchemaCapabilities { [JsonProperty("nameable")] public bool Nameable { get; set; } @@ -171,7 +171,7 @@ internal class SchemaCapabilities public bool? Decodable { get; set; } } - internal class SchemaAdditionalHiddenBodygroups + public class SchemaAdditionalHiddenBodygroups { [JsonProperty("hat")] public uint Hat { get; set; } @@ -183,7 +183,7 @@ internal class SchemaAdditionalHiddenBodygroups public uint? Head { get; set; } } - internal class SchemaStyle + public class SchemaStyle { [JsonProperty("name")] public string Name { get; set; } @@ -192,7 +192,7 @@ internal class SchemaStyle public SchemaAdditionalHiddenBodygroups AdditionalHiddenBodygroups { get; set; } } - internal class SchemaItemAttribute + public class SchemaItemAttribute { [JsonProperty("name")] public string Name { get; set; } @@ -204,7 +204,7 @@ internal class SchemaItemAttribute public double Value { get; set; } } - internal class SchemaPerClassLoadoutSlots + public class SchemaPerClassLoadoutSlots { [JsonProperty("Soldier")] public string Soldier { get; set; } @@ -222,7 +222,7 @@ internal class SchemaPerClassLoadoutSlots public string Demoman { get; set; } } - internal class SchemaUsageCapabilities + public class SchemaUsageCapabilities { [JsonProperty("nameable")] public bool Nameable { get; set; } @@ -264,7 +264,7 @@ internal class SchemaUsageCapabilities public bool? CanConsume { get; set; } } - internal class SchemaTool + public class SchemaTool { [JsonProperty("type")] public string Type { get; set; } @@ -279,7 +279,7 @@ internal class SchemaTool public string Restriction { get; set; } } - internal class SchemaItem + public class SchemaItem { [JsonProperty("defindex")] public uint DefIndex { get; set; } @@ -301,7 +301,7 @@ internal class SchemaItem [JsonProperty("item_class")] public string ItemClass { get; set; } - + [JsonProperty("proper_name")] public bool ProperName { get; set; } @@ -363,7 +363,7 @@ internal class SchemaItem public SchemaTool Tool { get; set; } } - internal class SchemaAttribute + public class SchemaAttribute { [JsonProperty("name")] public string Name { get; set; } @@ -390,7 +390,7 @@ internal class SchemaAttribute public bool StoredAsInteger { get; set; } } - internal class SchemaItemSetAttribute + public class SchemaItemSetAttribute { [JsonProperty("name")] public string Name { get; set; } @@ -402,7 +402,7 @@ internal class SchemaItemSetAttribute public double Value { get; set; } } - internal class SchemaItemSet + public class SchemaItemSet { [JsonProperty("item_set")] public string ItemSet { get; set; } @@ -420,7 +420,7 @@ internal class SchemaItemSet public string StoreBundleName { get; set; } } - internal class SchemaAttributeControlledAttachedParticle + public class SchemaAttributeControlledAttachedParticle { [JsonProperty("system")] public string System { get; set; } @@ -438,7 +438,7 @@ internal class SchemaAttributeControlledAttachedParticle public string Attachment { get; set; } } - internal class SchemaLevel + public class SchemaLevel { [JsonProperty("level")] public uint Level { get; set; } @@ -450,7 +450,7 @@ internal class SchemaLevel public string Name { get; set; } } - internal class SchemaItemLevel + public class SchemaItemLevel { [JsonProperty("name")] public string Name { get; set; } @@ -459,7 +459,7 @@ internal class SchemaItemLevel public IList Levels { get; set; } } - internal class SchemaKillEaterScoreType + public class SchemaKillEaterScoreType { [JsonProperty("type")] public uint Type { get; set; } @@ -471,7 +471,7 @@ internal class SchemaKillEaterScoreType public string LevelData { get; set; } } - internal class SchemaString + public class SchemaString { [JsonProperty("index")] public uint Index { get; set; } @@ -480,7 +480,7 @@ internal class SchemaString public string String { get; set; } } - internal class SchemaStringLookup + public class SchemaStringLookup { [JsonProperty("table_name")] public string TableName { get; set; } @@ -488,46 +488,4 @@ internal class SchemaStringLookup [JsonProperty("strings")] public IList Strings { get; set; } } - - internal class SchemaResult - { - [JsonProperty("status")] - public uint Status { get; set; } - - [JsonProperty("items_game_url")] - public string ItemsGameUrl { get; set; } - - [JsonProperty("qualities")] - public SchemaQualities Qualities { get; set; } - - [JsonProperty("originNames")] - public IList OriginNames { get; set; } - - [JsonProperty("items")] - public IList Items { get; set; } - - [JsonProperty("attributes")] - public IList Attributes { get; set; } - - [JsonProperty("item_sets")] - public IList ItemSets { get; set; } - - [JsonProperty("attribute_controlled_attached_particles")] - public IList AttributeControlledAttachedParticles { get; set; } - - [JsonProperty("item_levels")] - public IList ItemLevels { get; set; } - - [JsonProperty("kill_eater_score_types")] - public IList KillEaterScoreTypes { get; set; } - - [JsonProperty("string_lookups")] - public IList StringLookups { get; set; } - } - - internal class SchemaResultContainer - { - [JsonProperty("result")] - public SchemaResult Result { get; set; } - } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/GameServers/AccountListContainer.cs b/src/SteamWebAPI2/Models/GameServers/AccountListContainer.cs new file mode 100644 index 0000000..0259f69 --- /dev/null +++ b/src/SteamWebAPI2/Models/GameServers/AccountListContainer.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace SteamWebAPI2.Models.GameServers +{ + public class AccountListContainer + { + [JsonProperty("response")] + public AccountList Response { get; set; } + } + + public class AccountList + { + [JsonProperty("servers")] + public IEnumerable Servers { get; set; } + + [JsonProperty("is_banned")] + public bool IsBanned { get; set; } + + [JsonProperty("expires")] + public uint Expires { get; set; } + + [JsonProperty("actor")] + public ulong Actor { get; set; } + + [JsonProperty("last_action_time")] + public ulong LastActionTime { get; set; } + } + + public class AccountServer + { + + [JsonProperty("steamid")] + public ulong SteamId { get; set; } + + [JsonProperty("appid")] + public uint AppId { get; set; } + + [JsonProperty("login_token")] + public string LoginToken { get; set; } + + [JsonProperty("memo")] + public string Memo { get; set; } + + [JsonProperty("is_deleted")] + public bool IsDeleted { get; set; } + + [JsonProperty("is_expired")] + public bool IsExpired { get; set; } + + [JsonProperty("rt_last_logon")] + public ulong RtLastLogon { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/GameServers/AccountPublicInfoContainer.cs b/src/SteamWebAPI2/Models/GameServers/AccountPublicInfoContainer.cs new file mode 100644 index 0000000..2c3c432 --- /dev/null +++ b/src/SteamWebAPI2/Models/GameServers/AccountPublicInfoContainer.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +namespace SteamWebAPI2.Models.GameServers +{ + public class AccountPublicInfoContainer + { + [JsonProperty("response")] + public AccountPublicInfo Response { get; set; } + } + + public class AccountPublicInfo + { + [JsonProperty("steamid")] + public ulong SteamId { get; set; } + + [JsonProperty("appid")] + public uint AppId { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/GameServers/CreateAccountContainer.cs b/src/SteamWebAPI2/Models/GameServers/CreateAccountContainer.cs new file mode 100644 index 0000000..aa9d102 --- /dev/null +++ b/src/SteamWebAPI2/Models/GameServers/CreateAccountContainer.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +namespace SteamWebAPI2.Models.GameServers +{ + public class CreateAccountContainer + { + [JsonProperty("response")] + public CreateAccount Response { get; set; } + } + + public class CreateAccount + { + [JsonProperty("steamid")] + public ulong SteamId { get; set; } + + [JsonProperty("login_token")] + public string LoginToken { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/GameServers/QueryLoginTokenContainer.cs b/src/SteamWebAPI2/Models/GameServers/QueryLoginTokenContainer.cs new file mode 100644 index 0000000..8e74e73 --- /dev/null +++ b/src/SteamWebAPI2/Models/GameServers/QueryLoginTokenContainer.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; + +namespace SteamWebAPI2.Models.GameServers +{ + public class QueryLoginTokenContainer + { + [JsonProperty("response")] + public QueryLoginTokenResponse Response { get; set; } + } + + public class QueryLoginTokenResponse + { + [JsonProperty("is_banned")] + public bool IsBanned { get; set; } + + [JsonProperty("expires")] + public uint Expires { get; set; } + + [JsonProperty("steamid")] + public ulong SteamId { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/GameServers/ResetLoginTokenContainer.cs b/src/SteamWebAPI2/Models/GameServers/ResetLoginTokenContainer.cs new file mode 100644 index 0000000..f93fca7 --- /dev/null +++ b/src/SteamWebAPI2/Models/GameServers/ResetLoginTokenContainer.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace SteamWebAPI2.Models.GameServers +{ + public class ResetLoginTokenContainer + { + [JsonProperty("response")] + public ResetLoginTokenResponse Response { get; set; } + } + + public class ResetLoginTokenResponse + { + [JsonProperty("login_token")] + public string LoginToken { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/PublishedFileDetailsResultContainer.cs b/src/SteamWebAPI2/Models/PublishedFileDetailsResultContainer.cs index 46ee2be..bdf829a 100644 --- a/src/SteamWebAPI2/Models/PublishedFileDetailsResultContainer.cs +++ b/src/SteamWebAPI2/Models/PublishedFileDetailsResultContainer.cs @@ -1,12 +1,11 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; - -using Newtonsoft.Json; +using Steam.Models; +using SteamWebAPI2.Utilities.JsonConverters; namespace SteamWebAPI2.Models { - using SteamWebAPI2.Utilities.JsonConverters; - internal class PublishedFileDetailsResultContainer { [JsonProperty("response")] @@ -46,7 +45,7 @@ internal class PublishedFileDetails public string FileName { get; set; } [JsonProperty("file_size")] - public uint FileSize { get; set; } + public ulong FileSize { get; set; } [JsonProperty("file_url")] public string FileUrl { get; set; } @@ -75,7 +74,7 @@ internal class PublishedFileDetails public DateTime TimeUpdated { get; set; } [JsonProperty("visibility")] - public uint Visibility { get; set; } + public uint Visibility { get; set; } = (uint)PublishedFileVisibility.Unknown; [JsonProperty("banned")] public bool Banned { get; set; } @@ -102,4 +101,4 @@ internal class PublishedFileDetails [JsonConverter(typeof(TagsJsonConverter))] public IList Tags { get; set; } } -} +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/SteamCommunity/BadgesResultContainer.cs b/src/SteamWebAPI2/Models/SteamCommunity/BadgesResultContainer.cs index a55c2ff..15bd852 100644 --- a/src/SteamWebAPI2/Models/SteamCommunity/BadgesResultContainer.cs +++ b/src/SteamWebAPI2/Models/SteamCommunity/BadgesResultContainer.cs @@ -27,7 +27,7 @@ internal class Badge public string CommunityItemId { get; set; } [JsonProperty("border_color")] - public int? BorderColor { get; set; } + public uint? BorderColor { get; set; } } internal class BadgesResult diff --git a/src/SteamWebAPI2/Models/SteamCommunity/PlayerSummaryResultContainer.cs b/src/SteamWebAPI2/Models/SteamCommunity/PlayerSummaryResultContainer.cs index 1884d1b..e8c1981 100644 --- a/src/SteamWebAPI2/Models/SteamCommunity/PlayerSummaryResultContainer.cs +++ b/src/SteamWebAPI2/Models/SteamCommunity/PlayerSummaryResultContainer.cs @@ -130,6 +130,12 @@ internal class PlayerSummary /// [JsonProperty(PropertyName = "gameid")] public string PlayingGameId { get; set; } + + /// + /// The IP of the server the user is currently playing on. + /// + [JsonProperty(PropertyName = "gameserverip")] + public string PlayingGameServerIP { get; set; } } /// diff --git a/src/SteamWebAPI2/Models/SteamCommunity/SteamCommunityProfile.cs b/src/SteamWebAPI2/Models/SteamCommunity/SteamCommunityProfile.cs index fd86cf5..cae248b 100644 --- a/src/SteamWebAPI2/Models/SteamCommunity/SteamCommunityProfile.cs +++ b/src/SteamWebAPI2/Models/SteamCommunity/SteamCommunityProfile.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; +using System.Collections.Generic; using System.Runtime.Serialization; -using System.Xml.Serialization; namespace SteamWebAPI2.Models.SteamCommunity { @@ -37,7 +34,7 @@ internal class SteamCommunityProfile public string AvatarFull { get; set; } [DataMember(Name = "vacBanned", Order = 9)] - public byte VacBanned {get; set; } + public byte VacBanned { get; set; } [DataMember(Name = "tradeBanState", Order = 10)] public string TradeBanState { get; set; } @@ -61,7 +58,7 @@ internal class SteamCommunityProfile public string SteamRating { get; set; } [DataMember(Name = "hoursPlayed2Wk", Order = 17)] - public decimal HoursPlayed2Wk { get; set; } + public string HoursPlayed2Wk { get; set; } [DataMember(Name = "headline", Order = 18)] public string Headline { get; set; } @@ -120,7 +117,7 @@ internal class ProfileMostPlayedGame public string GameLogoSmall { get; set; } [DataMember(Name = "hoursPlayed", Order = 5)] - public decimal HoursPlayed { get; set; } + public string HoursPlayed { get; set; } [DataMember(Name = "hoursOnRecord", Order = 6)] public string HoursOnRecord { get; set; } @@ -158,36 +155,46 @@ internal class ProfileGroup [DataMember(Name = "memberCount", Order = 8)] public uint MemberCount { get; set; } - + public bool MemberCountSpecified { get; set; } [DataMember(Name = "membersInChat", Order = 9)] public uint MembersInChat { get; set; } - + public bool MembersInChatSpecified { get; set; } [DataMember(Name = "membersInGame", Order = 10)] public uint MembersInGame { get; set; } - + public bool MembersInGameSpecified { get; set; } [DataMember(Name = "membersOnline", Order = 11)] public uint MembersOnline { get; set; } - + public bool MembersOnlineSpecified { get; set; } } [CollectionDataContract(ItemName = "mostPlayedGame", Namespace = "")] internal class ProfileMostPlayedGameList : List { - public ProfileMostPlayedGameList() { } - public ProfileMostPlayedGameList(IEnumerable collection) : base(collection) { } + public ProfileMostPlayedGameList() + { + } + + public ProfileMostPlayedGameList(IEnumerable collection) : base(collection) + { + } } [CollectionDataContract(ItemName = "group", Namespace = "")] internal class ProfileGroupList : List { - public ProfileGroupList() { } - public ProfileGroupList(IEnumerable collection) : base(collection) { } + public ProfileGroupList() + { + } + + public ProfileGroupList(IEnumerable collection) : base(collection) + { + } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/SteamEconomy/AssetClassInfoResultContainer.cs b/src/SteamWebAPI2/Models/SteamEconomy/AssetClassInfoResultContainer.cs index 31d6b85..028af44 100644 --- a/src/SteamWebAPI2/Models/SteamEconomy/AssetClassInfoResultContainer.cs +++ b/src/SteamWebAPI2/Models/SteamEconomy/AssetClassInfoResultContainer.cs @@ -44,7 +44,7 @@ internal class AssetClassTag internal class AssetClassAppDataFilter { - public IList ElementIds { get; set; } + public IList ElementIds { get; set; } } internal class AssetClassAppData diff --git a/src/SteamWebAPI2/Models/SteamEconomy/AssetPriceResultContainer.cs b/src/SteamWebAPI2/Models/SteamEconomy/AssetPriceResultContainer.cs index 0f5ebca..7c6c8e1 100644 --- a/src/SteamWebAPI2/Models/SteamEconomy/AssetPriceResultContainer.cs +++ b/src/SteamWebAPI2/Models/SteamEconomy/AssetPriceResultContainer.cs @@ -117,7 +117,7 @@ internal class Asset public IList Tags { get; set; } [JsonProperty("tag_ids")] - public IList TagIds { get; set; } + public IList TagIds { get; set; } } internal class AssetTags diff --git a/src/SteamWebAPI2/Models/SteamEconomy/CancelTradeOfferResultContainer.cs b/src/SteamWebAPI2/Models/SteamEconomy/CancelTradeOfferResultContainer.cs index cdee0ee..e59890c 100644 --- a/src/SteamWebAPI2/Models/SteamEconomy/CancelTradeOfferResultContainer.cs +++ b/src/SteamWebAPI2/Models/SteamEconomy/CancelTradeOfferResultContainer.cs @@ -1,15 +1,10 @@ using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SteamWebAPI2.Models.SteamEconomy { internal class CancelTradeOfferResult { - // ?? + // ?? TBD? } internal class CancelTradeOfferResultContainer @@ -17,4 +12,4 @@ internal class CancelTradeOfferResultContainer [JsonProperty("response")] public CancelTradeOfferResult Result { get; set; } } -} +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/SteamEconomy/DeclineTradeOfferResultContainer.cs b/src/SteamWebAPI2/Models/SteamEconomy/DeclineTradeOfferResultContainer.cs index e21e3be..e19279e 100644 --- a/src/SteamWebAPI2/Models/SteamEconomy/DeclineTradeOfferResultContainer.cs +++ b/src/SteamWebAPI2/Models/SteamEconomy/DeclineTradeOfferResultContainer.cs @@ -1,15 +1,10 @@ using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SteamWebAPI2.Models.SteamEconomy { internal class DeclineTradeOfferResult { - // ?? + // ?? TBD? } internal class DeclineTradeOfferResultContainer @@ -17,4 +12,4 @@ internal class DeclineTradeOfferResultContainer [JsonProperty("response")] public DeclineTradeOfferResult Result { get; set; } } -} +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/SteamEconomy/TradeHoldDurationResultsContainer.cs b/src/SteamWebAPI2/Models/SteamEconomy/TradeHoldDurationResultsContainer.cs new file mode 100644 index 0000000..c5f721d --- /dev/null +++ b/src/SteamWebAPI2/Models/SteamEconomy/TradeHoldDurationResultsContainer.cs @@ -0,0 +1,35 @@ +using Newtonsoft.Json; +using System; + +namespace SteamWebAPI2.Models.SteamEconomy +{ + internal class TradeHoldDurations + { + [JsonProperty("escrow_end_duration_seconds")] + public uint EscrowEndDurationSeconds { get; set; } + + [JsonProperty("escrow_end_date")] + public uint EscrowEndDate { get; set; } + + [JsonProperty("escrow_end_date_rfc3339")] + public DateTime EscrowEndDateRfc3339 { get; set;} + } + + internal class TradeHoldDurationsResult + { + [JsonProperty("my_escrow")] + public TradeHoldDurations MyEscrow { get; set; } + + [JsonProperty("their_escrow")] + public TradeHoldDurations TheirEscrow { get; set; } + + [JsonProperty("both_escrow")] + public TradeHoldDurations BothEscrow { get; set; } + } + + internal class TradeHoldDurationsResultContainer + { + [JsonProperty("response")] + public TradeHoldDurationsResult Result { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Models/SteamId.cs b/src/SteamWebAPI2/Models/SteamId.cs index ab8e0a4..62eeac3 100644 --- a/src/SteamWebAPI2/Models/SteamId.cs +++ b/src/SteamWebAPI2/Models/SteamId.cs @@ -65,6 +65,8 @@ public class SteamId { #region Members + private ISteamUser steamUser; + // Special flags for chat accounts in the high 8 bits of the Steam ID instance. Adopted from https://github.com/xPaw/SteamID.php. //private uint instanceFlagClan = 524288; // (SteamAccountInstanceMask + 1) >> 1 //private uint instanceFlagLobby = 262144; // (SteamAccountInstanceMask + 1) >> 2 @@ -182,19 +184,24 @@ public SteamId(ulong steamId64) } /// - /// Constructs a Steam Id by parsing the provided value. This constructor will try to parse the value to a 64-bit Steam Id or a Steam Community Profile URL depending on the input. + /// Constructs a Steam Id helper with deferred parsing and resolution because a fuzzy lookup will be needed. Follow up with the ResolveAsync method to + /// asynchronously resolve the Steam Id information. This is typically used when you only know the users vanity URL name or don't know what type of Steam Id + /// you have on hand. + /// + /// Required in the event that the Steam Web API is needed to resolve a Profile URL to a 64-bit Steam ID. + public SteamId(ISteamUser steamUser) + { + this.steamUser = steamUser; + } + + /// + /// Constructs a Steam Id by parsing the provided value. This will try to parse the value to a 64-bit Steam Id or a Steam Community Profile URL depending on the input. /// If a Profile URL is provided but is unable to be resolved to a 64-bit Steam ID, a VanityUrlNotResolvedException will be thrown. Network access may be required /// to receive a return value from this method in the event that the Steam Web API is required. /// /// Value to parse, can be a 64-bit Steam ID, a full Steam Community Profile URL, or the user's Steam Community Profile Name. - /// Required in the event that the Steam Web API is needed to resolve a Profile URL to a 64-bit Steam ID. - public SteamId(string value, string steamWebApiKey = "") + public async Task ResolveAsync(string value) { - if (String.IsNullOrEmpty(value)) - { - throw new ArgumentNullException("value"); - } - ulong steamId = 0; MatchCollection legacyCheckResult = null; MatchCollection modernCheckResult = null; @@ -216,7 +223,7 @@ public SteamId(string value, string steamWebApiKey = "") string accountTypeCharacter = modernCheckResult[0].Groups[1].Value; string universe = modernCheckResult[0].Groups[2].Value; string accountId = modernCheckResult[0].Groups[3].Value; - string instance = String.Empty; + string instance = string.Empty; if (modernCheckResult[0].Groups.Count == 5) { instance = modernCheckResult[0].Groups[4].Value; @@ -241,58 +248,57 @@ public SteamId(string value, string steamWebApiKey = "") bool isUri = Uri.TryCreate(value, UriKind.Absolute, out uriResult) && (uriResult.Scheme == "http" || uriResult.Scheme == "https"); - SteamUser steamUser = new SteamUser(steamWebApiKey); - try { - Task.Run(async () => + // the caller provided a uri + if (isUri) { - // the caller provided a uri - if (isUri) + // the caller provided a uri in the format we expected + if (uriResult.Segments.Length == 3) { - // the caller provided a uri in the format we expected - if (uriResult.Segments.Length == 3) - { - string profileId = uriResult.Segments[2]; + string profileId = uriResult.Segments[2]; - // try to parse the 3rd segment as a 64-bit Steam ID (http://steamcommunity.com/profiles/762541427451 for example) + // if a user has a vanity name setup in their steam profile, the steam profile url will be in the format of: + // http://steamcommunity.com/id/ + // otherwise, the format will be: + // http://steamcommunity.com/profiles/<64-bit Steam ID> + if (uriResult.Segments[1] == "id/") + { + steamId = await ResolveSteamIdFromValueAsync(steamUser, profileId); + ConstructFromSteamId64(steamId); + ResolvedFrom = SteamIdResolvedFrom.SteamCommunityUri; + } + else if (uriResult.Segments[1] == "profiles/") + { bool isSteamId64 = ulong.TryParse(profileId, out steamId); - // the third segment isn't a 64-bit Steam ID, check if it's a profile name which resolves to a 64-bit Steam ID - if (!isSteamId64) + if (isSteamId64) { - if (String.IsNullOrEmpty(steamWebApiKey)) - { - throw new InvalidOperationException(ErrorMessages.SteamWebApiKeyNotProvided); - } - - steamId = await ResolveSteamIdFromValueAsync(steamUser, profileId); + ConstructFromSteamId64(steamId); + ResolvedFrom = SteamIdResolvedFrom.SteamCommunityUri; + } + else + { + throw new InvalidSteamCommunityUriException(ErrorMessages.InvalidSteamCommunityUri); } - - ConstructFromSteamId64(steamId); } else { throw new InvalidSteamCommunityUriException(ErrorMessages.InvalidSteamCommunityUri); } - - ResolvedFrom = SteamIdResolvedFrom.SteamCommunityUri; } else { - if (String.IsNullOrEmpty(steamWebApiKey)) - { - throw new InvalidOperationException(ErrorMessages.SteamWebApiKeyNotProvided); - } - - // not a 64-bit Steam ID and not a uri, try to just resolve it as if it was a Steam Community Profile Name - steamId = await ResolveSteamIdFromValueAsync(steamUser, value); - - ConstructFromSteamId64(steamId); - - ResolvedFrom = SteamIdResolvedFrom.SteamCommunityProfileName; + throw new InvalidSteamCommunityUriException(ErrorMessages.InvalidSteamCommunityUri); } - }).Wait(); + } + else + { + // not a 64-bit Steam ID and not a uri, try to just resolve it as if it was a Steam Community Profile Name + steamId = await ResolveSteamIdFromValueAsync(steamUser, value); + ConstructFromSteamId64(steamId); + ResolvedFrom = SteamIdResolvedFrom.SteamCommunityProfileName; + } } catch (AggregateException ex) { @@ -325,7 +331,7 @@ private void ConstructFromModernSteamId(string accountTypeCharacter, string inst else { Instance = SteamInstance.All; } // override if an instance was provided - if (!String.IsNullOrEmpty(instance)) + if (!string.IsNullOrEmpty(instance)) { Instance = (SteamInstance)uint.Parse(instance); } @@ -406,7 +412,7 @@ private uint GetAccountIdFromLegacySteamId(string authServer, string partialAcco /// /// /// - private static async Task ResolveSteamIdFromValueAsync(SteamUser steamUser, string value) + private static async Task ResolveSteamIdFromValueAsync(ISteamUser steamUser, string value) { ulong steamId64 = 0; @@ -435,7 +441,7 @@ public string ToLegacyFormat() // Y = lowest bit of Account Id (always 0 or 1) uint y = AccountId & 1; - return String.Format("STEAM_{0}:{1}:{2}", x, y, z); + return string.Format("STEAM_{0}:{1}:{2}", x, y, z); } /// @@ -454,7 +460,7 @@ public string ToModernFormat() // A = account id uint a = AccountId; - return String.Format("[{0}:{1}:{2}]", c, u, a); + return string.Format("[{0}:{1}:{2}]", c, u, a); } /// diff --git a/src/SteamWebAPI2/Models/SteamNewsResultContainer.cs b/src/SteamWebAPI2/Models/SteamNewsResultContainer.cs index 61162a2..6ed3bc5 100644 --- a/src/SteamWebAPI2/Models/SteamNewsResultContainer.cs +++ b/src/SteamWebAPI2/Models/SteamNewsResultContainer.cs @@ -27,10 +27,13 @@ internal class NewsItem public string FeedLabel { get; set; } [JsonProperty("date")] - public uint Date { get; set; } + public ulong Date { get; set; } [JsonProperty("feedname")] public string Feedname { get; set; } + + [JsonProperty("tags")] + public string[] Tags { get; set; } } internal class SteamNewsResult diff --git a/src/SteamWebAPI2/Models/SteamPlayer/PlayerAchievementResultContainer.cs b/src/SteamWebAPI2/Models/SteamPlayer/PlayerAchievementResultContainer.cs index a028dbe..214d56a 100644 --- a/src/SteamWebAPI2/Models/SteamPlayer/PlayerAchievementResultContainer.cs +++ b/src/SteamWebAPI2/Models/SteamPlayer/PlayerAchievementResultContainer.cs @@ -11,6 +11,9 @@ internal class PlayerAchievement [JsonProperty("achieved")] public uint Achieved { get; set; } + [JsonProperty("unlocktime")] + public ulong UnlockTime { get; set; } + public string Name { get; set; } public string Description { get; set; } } diff --git a/src/SteamWebAPI2/Models/SteamStore/AppDetailsContainer.cs b/src/SteamWebAPI2/Models/SteamStore/AppDetailsContainer.cs index d28e288..422ced9 100644 --- a/src/SteamWebAPI2/Models/SteamStore/AppDetailsContainer.cs +++ b/src/SteamWebAPI2/Models/SteamStore/AppDetailsContainer.cs @@ -159,6 +159,27 @@ internal class SupportInfo public string Email { get; set; } } + internal class Price + { + [JsonProperty("currency")] + public string Currency { get; set; } + + [JsonProperty("initial")] + public uint Initial { get; set; } + + [JsonProperty("final")] + public uint Final { get; set; } + + [JsonProperty("discount_percent")] + public uint DiscountPercent { get; set; } + + [JsonProperty("initial_formatted")] + public string InitialFormatted { get; set; } + + [JsonProperty("final_formatted")] + public string FinalFormatted { get; set; } + } + internal class Data { [JsonProperty("type")] @@ -176,6 +197,9 @@ internal class Data [JsonProperty("is_free")] public bool IsFree { get; set; } + [JsonProperty("controller_support")] + public string ControllerSupport { get; set; } + [JsonProperty("dlc")] public uint[] Dlc { get; set; } @@ -185,6 +209,9 @@ internal class Data [JsonProperty("about_the_game")] public string AboutTheGame { get; set; } + [JsonProperty("short_description")] + public string ShortDescription { get; set; } + [JsonProperty("supported_languages")] public string SupportedLanguages { get; set; } @@ -209,6 +236,9 @@ internal class Data [JsonProperty("publishers")] public string[] Publishers { get; set; } + [JsonProperty("price_overview")] + public Price PriceOverview { get; set; } + [JsonProperty("packages")] public string[] Packages { get; set; } @@ -236,6 +266,9 @@ internal class Data [JsonProperty("recommendations")] public Recommendations Recommendations { get; set; } + [JsonProperty("achievements")] + public Achievement Achievements { get; set; } + [JsonProperty("release_date")] public ReleaseDate ReleaseDate { get; set; } @@ -244,6 +277,36 @@ internal class Data [JsonProperty("background")] public string Background { get; set; } + + [JsonProperty("content_descriptors")] + public ContentDescriptor ContentDescriptors { get; set; } + } + + public class ContentDescriptor + { + [JsonProperty("ids")] + public uint[] Ids { get; set; } + + [JsonProperty("notes")] + public string Notes { get; set; } + } + + public class Achievement + { + [JsonProperty("total")] + public uint Total { get; set; } + + [JsonProperty("highlighted")] + public Highlighted[] Highlighted { get; set; } + } + + public class Highlighted + { + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("path")] + public string Path { get; set; } } [JsonConverter(typeof(StoreAppDetailsContainerJsonConverter))] diff --git a/src/SteamWebAPI2/Models/SteamStore/FeaturedProductsContainer.cs b/src/SteamWebAPI2/Models/SteamStore/FeaturedProductsContainer.cs index fe67b90..b2ee7af 100644 --- a/src/SteamWebAPI2/Models/SteamStore/FeaturedProductsContainer.cs +++ b/src/SteamWebAPI2/Models/SteamStore/FeaturedProductsContainer.cs @@ -107,7 +107,7 @@ internal class FeaturedWin public string ControllerSupport { get; set; } [JsonProperty("discount_expiration")] - public int? DiscountExpiration { get; set; } + public uint? DiscountExpiration { get; set; } } internal class FeaturedMac diff --git a/src/SteamWebAPI2/Models/TF2/GoldenWrenchResultContainer.cs b/src/SteamWebAPI2/Models/TF2/GoldenWrenchResultContainer.cs index bc8bdf9..5043048 100644 --- a/src/SteamWebAPI2/Models/TF2/GoldenWrenchResultContainer.cs +++ b/src/SteamWebAPI2/Models/TF2/GoldenWrenchResultContainer.cs @@ -8,7 +8,7 @@ namespace SteamWebAPI2.Models.TF2 internal class GoldenWrench { [JsonProperty("steamID")] - public object SteamId { get; set; } + public ulong SteamId { get; set; } [JsonConverter(typeof(UnixTimeJsonConverter))] [JsonProperty("timestamp")] diff --git a/src/SteamWebAPI2/SteamStoreInterface.cs b/src/SteamWebAPI2/SteamStoreInterface.cs index e707033..0473188 100644 --- a/src/SteamWebAPI2/SteamStoreInterface.cs +++ b/src/SteamWebAPI2/SteamStoreInterface.cs @@ -1,9 +1,7 @@ using SteamWebAPI2.Utilities; -using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; +using System.Net.Http; using System.Threading.Tasks; namespace SteamWebAPI2 @@ -15,16 +13,14 @@ public abstract class SteamStoreInterface { private const string steamStoreApiBaseUrl = "http://store.steampowered.com/api/"; private readonly SteamStoreRequest steamStoreRequest; - private readonly string endpointName; /// - /// Constructs and maps the default objects for Steam Store Web API use + /// Constructs and maps based on a custom http client /// - public SteamStoreInterface() + /// Client to make requests with + public SteamStoreInterface(HttpClient httpClient) { - this.steamStoreRequest = new SteamStoreRequest(steamStoreApiBaseUrl); - - AutoMapperConfiguration.Initialize(); + steamStoreRequest = new SteamStoreRequest(steamStoreApiBaseUrl, httpClient); } /// @@ -33,9 +29,17 @@ public SteamStoreInterface() /// Steam Store Web API URL public SteamStoreInterface(string steamStoreApiBaseUrl) { - this.steamStoreRequest = new SteamStoreRequest(steamStoreApiBaseUrl); + steamStoreRequest = new SteamStoreRequest(steamStoreApiBaseUrl); + } - AutoMapperConfiguration.Initialize(); + /// + /// Constructs and maps based on a custom http client and custom Steam Store Web API URL + /// + /// Steam Store Web API URL + /// Client to make requests with + public SteamStoreInterface(string steamStoreApiBaseUrl, HttpClient httpClient) + { + steamStoreRequest = new SteamStoreRequest(steamStoreApiBaseUrl, httpClient); } /// @@ -47,9 +51,9 @@ public SteamStoreInterface(string steamStoreApiBaseUrl) /// Deserialized response object internal async Task CallMethodAsync(string endpointName, IList parameters = null) { - Debug.Assert(!String.IsNullOrEmpty(endpointName)); + Debug.Assert(!string.IsNullOrEmpty(endpointName)); return await steamStoreRequest.SendStoreRequestAsync(endpointName, parameters); } } -} +} \ No newline at end of file diff --git a/src/SteamWebAPI2/SteamStoreRequest.cs b/src/SteamWebAPI2/SteamStoreRequest.cs index 148947e..dd92ced 100644 --- a/src/SteamWebAPI2/SteamStoreRequest.cs +++ b/src/SteamWebAPI2/SteamStoreRequest.cs @@ -3,9 +3,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Net.Http; -using System.Text; using System.Threading.Tasks; namespace SteamWebAPI2 @@ -16,6 +14,7 @@ namespace SteamWebAPI2 internal class SteamStoreRequest { private string steamStoreApiBaseUrl; + private readonly HttpClient httpClient; /// /// Constructs a Steam Store Web API request @@ -23,7 +22,7 @@ internal class SteamStoreRequest /// Steam Store Web API URL public SteamStoreRequest(string steamStoreApiBaseUrl) { - if (String.IsNullOrEmpty(steamStoreApiBaseUrl)) + if (string.IsNullOrEmpty(steamStoreApiBaseUrl)) { throw new ArgumentNullException("steamStoreApiBaseUrl"); } @@ -31,6 +30,17 @@ public SteamStoreRequest(string steamStoreApiBaseUrl) this.steamStoreApiBaseUrl = steamStoreApiBaseUrl; } + public SteamStoreRequest(string steamStoreApiBaseUrl, HttpClient httpClient) + { + if (string.IsNullOrEmpty(steamStoreApiBaseUrl)) + { + throw new ArgumentNullException("steamStoreApiBaseUrl"); + } + + this.steamStoreApiBaseUrl = steamStoreApiBaseUrl; + this.httpClient = httpClient; + } + /// /// Sends a request to a Steam Store Web API endpoint /// @@ -39,7 +49,7 @@ public SteamStoreRequest(string steamStoreApiBaseUrl) /// public async Task SendStoreRequestAsync(string endpointName) { - Debug.Assert(!String.IsNullOrEmpty(endpointName)); + Debug.Assert(!string.IsNullOrEmpty(endpointName)); return await SendStoreRequestAsync(endpointName, null); } @@ -53,7 +63,7 @@ public async Task SendStoreRequestAsync(string endpointName) /// Deserialized response object public async Task SendStoreRequestAsync(string endpointName, IList parameters) { - Debug.Assert(!String.IsNullOrEmpty(endpointName)); + Debug.Assert(!string.IsNullOrEmpty(endpointName)); if (parameters == null) { @@ -73,10 +83,10 @@ public async Task SendStoreRequestAsync(string endpointName, IList /// Command (method endpoint) to send to an interface /// HTTP response as a string without tabs and newlines - private static async Task GetHttpStringResponseAsync(string command) + private async Task GetHttpStringResponseAsync(string command) { - HttpClient httpClient = new HttpClient(); - string response = await httpClient.GetStringAsync(command); + HttpClient client = httpClient ?? new HttpClient(); + string response = await client.GetStringAsync(command); response = response.Replace("\n", ""); response = response.Replace("\t", ""); return response; @@ -90,23 +100,23 @@ private static async Task GetHttpStringResponseAsync(string command) /// Deserialized response object public string BuildRequestCommand(string endpointName, IList parameters) { - Debug.Assert(!String.IsNullOrEmpty(endpointName)); + Debug.Assert(!string.IsNullOrEmpty(endpointName)); if (steamStoreApiBaseUrl.EndsWith("/")) { steamStoreApiBaseUrl = steamStoreApiBaseUrl.Remove(steamStoreApiBaseUrl.Length - 1, 1); } - string commandUrl = String.Format("{0}/{1}/", steamStoreApiBaseUrl, endpointName); + string commandUrl = string.Format("{0}/{1}/", steamStoreApiBaseUrl, endpointName); // if we have parameters, join them together with & delimiter and append them to the command URL if (parameters != null && parameters.Count > 0) { - string parameterString = String.Join("&", parameters); - commandUrl += String.Format("?{0}", parameterString); + string parameterString = string.Join("&", parameters); + commandUrl += string.Format("?{0}", parameterString); } return commandUrl; } } -} +} \ No newline at end of file diff --git a/src/SteamWebAPI2/SteamWebAPI2.csproj b/src/SteamWebAPI2/SteamWebAPI2.csproj index 49841d9..6592bbb 100644 --- a/src/SteamWebAPI2/SteamWebAPI2.csproj +++ b/src/SteamWebAPI2/SteamWebAPI2.csproj @@ -2,19 +2,32 @@ This is a .NET library that makes it easy to use the Steam Web API. It conveniently wraps around all of the JSON data and ugly API details with clean methods, structures and classes. - 4.0.8 + 5.0.0 Justin Skiles SteamWebAPI2 SteamWebAPI2 https://github.com/babelshift/SteamWebAPI2 - https://raw.githubusercontent.com/babelshift/SteamWebAPI2/master/LICENSE - netstandard2.0 + MIT + netstandard2.0;netstandard2.1 + + + $(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage + + + + + + - - - + + + + + + + diff --git a/src/SteamWebAPI2/Utilities/ISteamWebHttpClient.cs b/src/SteamWebAPI2/Utilities/ISteamWebHttpClient.cs deleted file mode 100644 index 9c4f1f9..0000000 --- a/src/SteamWebAPI2/Utilities/ISteamWebHttpClient.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Net.Http; -using System.Threading.Tasks; - -namespace SteamWebAPI2.Utilities -{ - public interface ISteamWebHttpClient - { - /// - /// Performs an HTTP GET with the passed URL command. - /// - /// URL command for GET operation - /// String response such as JSON or XML - Task GetAsync(string uri); - - /// - /// Performs an HTTP POST with the passed URL command. - /// - /// URL command for POST operation - /// The HTTP request content sent to the server. - /// String response such as JSON or XML - Task PostAsync(string uri, HttpContent content); - } -} \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/ISteamWebInterfaceFactory.cs b/src/SteamWebAPI2/Utilities/ISteamWebInterfaceFactory.cs new file mode 100644 index 0000000..3eae8d9 --- /dev/null +++ b/src/SteamWebAPI2/Utilities/ISteamWebInterfaceFactory.cs @@ -0,0 +1,12 @@ +using System.Net.Http; +using SteamWebAPI2.Interfaces; + +namespace SteamWebAPI2.Utilities +{ + public interface ISteamWebInterfaceFactory + { + SteamStore CreateSteamStoreInterface(HttpClient httpClient = null); + T CreateSteamWebInterface(HttpClient httpClient = null); + T CreateSteamWebInterface(AppId appId, HttpClient httpClient = null); + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/ISteamWebResponse.cs b/src/SteamWebAPI2/Utilities/ISteamWebResponse.cs index f59f910..95f7055 100644 --- a/src/SteamWebAPI2/Utilities/ISteamWebResponse.cs +++ b/src/SteamWebAPI2/Utilities/ISteamWebResponse.cs @@ -4,11 +4,18 @@ namespace SteamWebAPI2.Utilities { public interface ISteamWebResponse { + // Data returned from Steam Web API (this is probably what you care about) T Data { get; set; } + // Content length from the HTTP response long? ContentLength { get; set; } + // Content type of the HTTP response string ContentType { get; set; } + // Charset of the content type of the HTTP response string ContentTypeCharSet { get; set; } + // Expires header from the HTTP response DateTimeOffset? Expires { get; set; } + // Last modified header from the HTTP response DateTimeOffset? LastModified { get; set; } + SteamWebResponse MapTo(Func mapFunction); } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/JsonConverters/AssetClassInfoJsonConverter.cs b/src/SteamWebAPI2/Utilities/JsonConverters/AssetClassInfoJsonConverter.cs index 730e135..13aec3b 100644 --- a/src/SteamWebAPI2/Utilities/JsonConverters/AssetClassInfoJsonConverter.cs +++ b/src/SteamWebAPI2/Utilities/JsonConverters/AssetClassInfoJsonConverter.cs @@ -200,11 +200,11 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { if (assetClassAppDataFilterDetailProperty.Name == "element_ids") { - List elementIds = new List(); + List elementIds = new List(); foreach (var elementId in assetClassAppDataFilterDetailProperty.Value.Children()) { - elementIds.Add(long.Parse(elementId.Value.ToString())); + elementIds.Add(ulong.Parse(elementId.Value.ToString())); } filter.ElementIds = elementIds; diff --git a/src/SteamWebAPI2/Utilities/JsonConverters/GameMapsPlaytimeConverter.cs b/src/SteamWebAPI2/Utilities/JsonConverters/GameMapsPlaytimeConverter.cs new file mode 100644 index 0000000..b443a33 --- /dev/null +++ b/src/SteamWebAPI2/Utilities/JsonConverters/GameMapsPlaytimeConverter.cs @@ -0,0 +1,86 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using SteamWebAPI2.Models.CSGO; +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace SteamWebAPI2.Utilities.JsonConverters +{ + internal class GameMapsPlaytimeConverter : JsonConverter + { + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new NotImplementedException(); + } + + /// + /// Custom deserialization required because raw API response is awful. Instead of returning real JSON objects, the API + /// returns an array of "keys" and a matrix of "rows". We need to match up the keys to the columns within the rows + /// to figure out which value goes with which key. + /// + /// Example response: + /// + /// "Keys": ["Key 1", "Key 2", "Key 3"], + /// "Rows": [ + /// ["A 1", "A 2", "A 3"], + /// ["B 1", "B 2", "B 3"] + /// ] + /// + /// + /// + /// + /// + /// + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Null) + { + return null; + } + + List playtimes = new List(); + + JObject o = JObject.Load(reader); + + var keys = o["Keys"]; + var rows = o["Rows"]; + + foreach (var row in rows) + { + int columnIndex = 0; + GameMapsPlaytime playtime = new GameMapsPlaytime(); + foreach (var value in row) + { + var key = keys[columnIndex]; + if (key.ToString() == "IntervalStartTimeStamp") + { + playtime.IntervalStartTimeStamp = ulong.Parse(value.ToString()); + } + else if (key.ToString() == "MapName") + { + playtime.MapName = value.ToString(); + } + else if (key.ToString() == "RelativePercentage") + { + playtime.RelativePercentage = float.Parse(value.ToString()); + } + columnIndex++; + } + playtimes.Add(playtime); + } + + return new GameMapsPlaytimeResult() + { + Playtimes = playtimes + }; + } + + public override bool CanWrite { get { return false; } } + + public override bool CanConvert(Type objectType) + { + return typeof(GameMapsPlaytimeResult).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo()); + } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/JsonConverters/TagsJsonConverter.cs b/src/SteamWebAPI2/Utilities/JsonConverters/TagsJsonConverter.cs index 91a19a5..039f00d 100644 --- a/src/SteamWebAPI2/Utilities/JsonConverters/TagsJsonConverter.cs +++ b/src/SteamWebAPI2/Utilities/JsonConverters/TagsJsonConverter.cs @@ -1,9 +1,8 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Reflection; -using Newtonsoft.Json; - namespace SteamWebAPI2.Utilities.JsonConverters { /// @@ -35,4 +34,4 @@ public override bool CanConvert(Type objectType) return typeof(IList>).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo()); } } -} +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/ServiceCollectionExtensions.cs b/src/SteamWebAPI2/Utilities/ServiceCollectionExtensions.cs new file mode 100644 index 0000000..4caeba3 --- /dev/null +++ b/src/SteamWebAPI2/Utilities/ServiceCollectionExtensions.cs @@ -0,0 +1,22 @@ +using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace SteamWebAPI2.Utilities +{ + public static class ServiceCollectionExtensions + { + public static IServiceCollection AddSteamWebInterfaceFactory(this IServiceCollection services, Action options) + { + if (services == null) + { + throw new ArgumentNullException(nameof(services)); + } + + services.TryAdd(ServiceDescriptor.Singleton()); + services.Configure(options); + + return services; + } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/SteamWebHttpClient.cs b/src/SteamWebAPI2/Utilities/SteamWebHttpClient.cs deleted file mode 100644 index 3823eae..0000000 --- a/src/SteamWebAPI2/Utilities/SteamWebHttpClient.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Diagnostics; -using System.Net; -using System.Net.Http; -using System.Threading.Tasks; - -namespace SteamWebAPI2.Utilities -{ - /// - /// Wraps HttpClient for convenience and testability. Note that newlines and tabs are stripped from responses. - /// - internal class SteamWebHttpClient : ISteamWebHttpClient - { - /// - /// Performs an HTTP GET with the passed URL command. - /// - /// URL command for GET operation - /// String response such as JSON or XML - public async Task GetAsync(string command) - { - Debug.Assert(!String.IsNullOrWhiteSpace(command)); - - HttpClient httpClient = new HttpClient(); - - var response = await httpClient.GetAsync(command); - - response.EnsureSuccessStatusCode(); - - if (response.Content == null) - { - return new HttpResponseMessage(HttpStatusCode.NoContent); - } - - return response; - } - - /// - /// Performs an HTTP POST with the passed URL command. - /// - /// URL command for POST operation - /// The HTTP request content sent to the server. - /// String response such as JSON or XML - public async Task PostAsync(string command, HttpContent content) - { - Debug.Assert(!String.IsNullOrWhiteSpace(command)); - - HttpClient httpClient = new HttpClient(); - - var response = await httpClient.PostAsync(command, content); - - response.EnsureSuccessStatusCode(); - - if (response.Content == null) - { - return new HttpResponseMessage(HttpStatusCode.NoContent); - } - - return response; - } - } -} \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/SteamWebInterface.cs b/src/SteamWebAPI2/Utilities/SteamWebInterface.cs index 6d55847..11e0584 100644 --- a/src/SteamWebAPI2/Utilities/SteamWebInterface.cs +++ b/src/SteamWebAPI2/Utilities/SteamWebInterface.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Threading.Tasks; namespace SteamWebAPI2.Utilities @@ -11,7 +10,7 @@ namespace SteamWebAPI2.Utilities /// internal sealed class SteamWebInterface : ISteamWebInterface { - private const string steamWebApiBaseUrl = "https://api.steampowered.com/"; + private readonly string steamWebApiBaseUrl = "https://api.steampowered.com/"; private readonly ISteamWebRequest steamWebRequest; private readonly string interfaceName; @@ -21,22 +20,20 @@ internal sealed class SteamWebInterface : ISteamWebInterface /// Steam Web API key (secret to each developer) /// Name for this web interface (such as "IDOTA2Match_570). Must match the Steam Web API interface name exactly as this value /// is used to construct the URL to perform the GET or POST. - public SteamWebInterface(string steamWebApiKey, string interfaceName, ISteamWebRequest steamWebRequest = null) + public SteamWebInterface(string interfaceName, ISteamWebRequest steamWebRequest) { - if (String.IsNullOrWhiteSpace(steamWebApiKey)) + if (string.IsNullOrWhiteSpace(interfaceName)) { - throw new ArgumentNullException("steamWebApiKey"); + throw new ArgumentNullException(nameof(interfaceName)); } - Debug.Assert(!String.IsNullOrWhiteSpace(interfaceName)); + if (steamWebRequest == null) + { + throw new ArgumentNullException(nameof(steamWebRequest)); + } this.interfaceName = interfaceName; - - this.steamWebRequest = steamWebRequest == null - ? new SteamWebRequest(steamWebApiBaseUrl, steamWebApiKey) - : steamWebRequest; - - AutoMapperConfiguration.Initialize(); + this.steamWebRequest = steamWebRequest; } /// @@ -46,22 +43,15 @@ public SteamWebInterface(string steamWebApiKey, string interfaceName, ISteamWebR /// Steam Web API key (secret to each developer) /// Name for this web interface (such as "IDOTA2Match_570). Must match the Steam Web API interface name exactly as this value /// is used to construct the URL to perform the GET or POST. - public SteamWebInterface(string steamWebApiBaseUrl, string steamWebApiKey, string interfaceName, ISteamWebRequest steamWebRequest = null) + public SteamWebInterface(string steamWebApiBaseUrl, string interfaceName, ISteamWebRequest steamWebRequest) + : this(interfaceName, steamWebRequest) { - if (String.IsNullOrWhiteSpace(steamWebApiKey)) + if (string.IsNullOrWhiteSpace(steamWebApiBaseUrl)) { - throw new ArgumentNullException("steamWebApiKey"); + throw new ArgumentNullException(nameof(steamWebApiBaseUrl)); } - Debug.Assert(!String.IsNullOrWhiteSpace(interfaceName)); - - this.interfaceName = interfaceName; - - this.steamWebRequest = steamWebRequest == null - ? new SteamWebRequest(steamWebApiBaseUrl, steamWebApiKey) - : steamWebRequest; - - AutoMapperConfiguration.Initialize(); + this.steamWebApiBaseUrl = steamWebApiBaseUrl; } /// @@ -74,8 +64,15 @@ public SteamWebInterface(string steamWebApiBaseUrl, string steamWebApiKey, strin /// public async Task> GetAsync(string methodName, int version, IList parameters = null) { - Debug.Assert(!String.IsNullOrWhiteSpace(methodName)); - Debug.Assert(version > 0); + if (string.IsNullOrWhiteSpace(methodName)) + { + throw new ArgumentNullException(nameof(methodName)); + } + + if (version <= 0) + { + throw new ArgumentOutOfRangeException(nameof(version)); + } return await steamWebRequest.GetAsync(interfaceName, methodName, version, parameters); } @@ -90,8 +87,15 @@ public async Task> GetAsync(string methodName, int versi /// public async Task> PostAsync(string methodName, int version, IList parameters = null) { - Debug.Assert(!String.IsNullOrWhiteSpace(methodName)); - Debug.Assert(version > 0); + if (string.IsNullOrWhiteSpace(methodName)) + { + throw new ArgumentNullException(nameof(methodName)); + } + + if (version <= 0) + { + throw new ArgumentOutOfRangeException(nameof(version)); + } return await steamWebRequest.PostAsync(interfaceName, methodName, version, parameters); } diff --git a/src/SteamWebAPI2/Utilities/SteamWebInterfaceFactory.cs b/src/SteamWebAPI2/Utilities/SteamWebInterfaceFactory.cs new file mode 100644 index 0000000..a05175b --- /dev/null +++ b/src/SteamWebAPI2/Utilities/SteamWebInterfaceFactory.cs @@ -0,0 +1,87 @@ +using Microsoft.Extensions.Options; +using SteamWebAPI2.Interfaces; +using System; +using System.Net.Http; + +namespace SteamWebAPI2.Utilities +{ + public class SteamWebInterfaceFactory : ISteamWebInterfaceFactory + { + private readonly string steamWebApiBaseUrl = "https://api.steampowered.com/"; + private readonly string steamWebApiKey; + + /// + /// Backwards compatible constructor that works with just a Steam Web API key instead of forcing + /// all consumers to use the IOptions constructor with dependency injection. + /// + /// + public SteamWebInterfaceFactory(string steamWebApiKey) + : this(Options.Create(new SteamWebInterfaceFactoryOptions() + { + SteamWebApiKey = steamWebApiKey + }) + ) { } + + /// + /// Factory to create web interface objects to communicate with Steam Web API + /// + /// Unique Steam Web API key issued to you (do not share this with anyone!) + /// Base URL of the Steam Web API (optional) + public SteamWebInterfaceFactory(IOptions options) + { + if (options == null) + { + throw new ArgumentNullException(nameof(options)); + } + + if (string.IsNullOrWhiteSpace(options.Value.SteamWebApiKey)) + { + throw new ArgumentNullException(nameof(options.Value.SteamWebApiKey)); + } + + this.steamWebApiKey = options.Value.SteamWebApiKey; + + if (!string.IsNullOrWhiteSpace(options.Value.SteamWebApiBaseUrl)) + { + this.steamWebApiBaseUrl = options.Value.SteamWebApiBaseUrl; + } + } + + public SteamStore CreateSteamStoreInterface(HttpClient httpClient = null) + { + return new SteamStore(httpClient); + } + + /// + /// Creates a web interface object connected to a specific Steam Web API interface endpoint + /// + /// Custom http client injected with your customization (if necessary). + /// If null, new instance is created with all defaults. + /// Type of the web interface to create + /// Instance of the web interface + public T CreateSteamWebInterface(HttpClient httpClient = null) + { + var steamWebRequest = CreateSteamWebRequest(httpClient); + return (T)Activator.CreateInstance(typeof(T), steamWebRequest, null); + } + + /// + /// Creates a web interface object connected to a specific Steam Web API interface endpoint + /// + /// Indicates which app to use + /// Custom http client injected with your customization (if necessary). + /// If null, new instance is created with all defaults. + /// Type of the web interface to create + /// Instance of the web interface + public T CreateSteamWebInterface(AppId appId, HttpClient httpClient = null) + { + var steamWebRequest = CreateSteamWebRequest(httpClient); + return (T)Activator.CreateInstance(typeof(T), steamWebRequest, appId, null); + } + + private ISteamWebRequest CreateSteamWebRequest(HttpClient httpClient) + { + return new SteamWebRequest(steamWebApiBaseUrl, steamWebApiKey, httpClient ?? new HttpClient()); + } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/SteamWebInterfaceFactoryOptions.cs b/src/SteamWebAPI2/Utilities/SteamWebInterfaceFactoryOptions.cs new file mode 100644 index 0000000..c11605b --- /dev/null +++ b/src/SteamWebAPI2/Utilities/SteamWebInterfaceFactoryOptions.cs @@ -0,0 +1,8 @@ +namespace SteamWebAPI2.Utilities +{ + public class SteamWebInterfaceFactoryOptions + { + public string SteamWebApiKey { get; set; } + public string SteamWebApiBaseUrl { get; set; } + } +} \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/SteamWebRequest.cs b/src/SteamWebAPI2/Utilities/SteamWebRequest.cs index 4e148e7..d7ff24c 100644 --- a/src/SteamWebAPI2/Utilities/SteamWebRequest.cs +++ b/src/SteamWebAPI2/Utilities/SteamWebRequest.cs @@ -1,7 +1,6 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Net; using System.Net.Http; @@ -22,32 +21,31 @@ internal enum HttpMethod /// internal class SteamWebRequest : ISteamWebRequest { - private string steamWebApiBaseUrl; + private readonly string steamWebApiBaseUrl; private readonly string steamWebApiKey; - private ISteamWebHttpClient httpClient; + private readonly HttpClient httpClient; /// /// Every web request requires a secret Steam Web API key /// /// Base URL for the API (such as http://api.steampowered.com) /// Secret Steam Web API key provided at the Valve developer website - /// Optional custom http client implementation for dependency injection - public SteamWebRequest(string steamWebApiBaseUrl, string steamWebApiKey, ISteamWebHttpClient httpClient = null) + /// Optional custom http client implementation for dependency injection + public SteamWebRequest(string steamWebApiBaseUrl, string steamWebApiKey, HttpClient httpClient = null) { - this.httpClient = httpClient == null ? new SteamWebHttpClient() : httpClient; - - if (String.IsNullOrWhiteSpace(steamWebApiBaseUrl)) + if (string.IsNullOrWhiteSpace(steamWebApiBaseUrl)) { - throw new ArgumentNullException("steamWebApiBaseUrl"); + throw new ArgumentNullException(nameof(steamWebApiBaseUrl)); } - if (String.IsNullOrWhiteSpace(steamWebApiKey)) + if (string.IsNullOrWhiteSpace(steamWebApiKey)) { - throw new ArgumentNullException("steamWebApiKey"); + throw new ArgumentNullException(nameof(steamWebApiKey)); } this.steamWebApiBaseUrl = steamWebApiBaseUrl; this.steamWebApiKey = steamWebApiKey; + this.httpClient = httpClient ?? new HttpClient(); } /// @@ -61,10 +59,6 @@ public SteamWebRequest(string steamWebApiBaseUrl, string steamWebApiKey, ISteamW /// Deserialized object from JSON response public async Task> GetAsync(string interfaceName, string methodName, int methodVersion, IList parameters = null) { - Debug.Assert(!String.IsNullOrWhiteSpace(interfaceName)); - Debug.Assert(!String.IsNullOrWhiteSpace(methodName)); - Debug.Assert(methodVersion > 0); - return await SendWebRequestAsync(HttpMethod.GET, interfaceName, methodName, methodVersion, parameters); } @@ -79,10 +73,6 @@ public async Task> GetAsync(string interfaceName, string /// Deserialized object from JSON response public async Task> PostAsync(string interfaceName, string methodName, int methodVersion, IList parameters = null) { - Debug.Assert(!String.IsNullOrWhiteSpace(interfaceName)); - Debug.Assert(!String.IsNullOrWhiteSpace(methodName)); - Debug.Assert(methodVersion > 0); - return await SendWebRequestAsync(HttpMethod.POST, interfaceName, methodName, methodVersion, parameters); } @@ -98,9 +88,20 @@ public async Task> PostAsync(string interfaceName, strin /// Deserialized object from JSON response private async Task> SendWebRequestAsync(HttpMethod httpMethod, string interfaceName, string methodName, int methodVersion, IList parameters = null) { - Debug.Assert(!String.IsNullOrWhiteSpace(interfaceName)); - Debug.Assert(!String.IsNullOrWhiteSpace(methodName)); - Debug.Assert(methodVersion > 0); + if (string.IsNullOrWhiteSpace(interfaceName)) + { + throw new ArgumentNullException(nameof(interfaceName)); + } + + if (string.IsNullOrWhiteSpace(methodName)) + { + throw new ArgumentNullException(nameof(methodName)); + } + + if (methodVersion <= 0) + { + throw new ArgumentOutOfRangeException(nameof(methodVersion)); + } if (parameters == null) { @@ -108,6 +109,8 @@ private async Task> SendWebRequestAsync(HttpMethod httpM } parameters.Insert(0, new SteamWebRequestParameter("key", steamWebApiKey)); + //parameters.Insert(0, new SteamWebRequestParameter("feeds", "SteamDB")); -- Demonstration of Implementing Feeds Parameter + //parameters.Insert(0, new SteamWebRequestParameter("tags", "halloween")); -- Demonstration of Implementing Tags Parameter HttpResponseMessage httpResponse = null; @@ -116,6 +119,11 @@ private async Task> SendWebRequestAsync(HttpMethod httpM string command = BuildRequestCommand(interfaceName, methodName, methodVersion, parameters); httpResponse = await httpClient.GetAsync(command).ConfigureAwait(false); + httpResponse.EnsureSuccessStatusCode(); + if (httpResponse.Content == null) + { + httpResponse = new HttpResponseMessage(HttpStatusCode.NoContent); + } } else if (httpMethod == HttpMethod.POST) { @@ -126,6 +134,11 @@ private async Task> SendWebRequestAsync(HttpMethod httpM FormUrlEncodedContent content = BuildRequestContent(parameters); httpResponse = await httpClient.PostAsync(command, content).ConfigureAwait(false); + httpResponse.EnsureSuccessStatusCode(); + if (httpResponse.Content == null) + { + httpResponse = new HttpResponseMessage(HttpStatusCode.NoContent); + } } var headers = httpResponse.Content?.Headers; @@ -141,7 +154,7 @@ private async Task> SendWebRequestAsync(HttpMethod httpM }; // deserialize the content if we have any as indicated by the response code - if (httpResponse.StatusCode != HttpStatusCode.NoContent) + if (httpResponse.StatusCode != HttpStatusCode.NoContent && httpResponse.Content != null) { string responseContent = await httpResponse.Content.ReadAsStringAsync(); responseContent = CleanupResponseString(responseContent); @@ -162,22 +175,39 @@ private async Task> SendWebRequestAsync(HttpMethod httpM /// private string BuildRequestCommand(string interfaceName, string methodName, int methodVersion, IEnumerable parameters) { - Debug.Assert(!String.IsNullOrWhiteSpace(interfaceName)); - Debug.Assert(!String.IsNullOrWhiteSpace(methodName)); - Debug.Assert(methodVersion > 0); + if (string.IsNullOrWhiteSpace(interfaceName)) + { + throw new ArgumentNullException(nameof(interfaceName)); + } + + if (string.IsNullOrWhiteSpace(methodName)) + { + throw new ArgumentNullException(nameof(methodName)); + } + if (methodVersion <= 0) + { + throw new ArgumentOutOfRangeException(nameof(methodVersion)); + } + + if (parameters == null) + { + parameters = new List(); + } + + string steamWebApiUrl = steamWebApiBaseUrl; if (steamWebApiBaseUrl.EndsWith("/")) { - steamWebApiBaseUrl = steamWebApiBaseUrl.Remove(steamWebApiBaseUrl.Length - 1, 1); + steamWebApiUrl = steamWebApiUrl.Remove(steamWebApiUrl.Length - 1, 1); } - string commandUrl = String.Format("{0}/{1}/{2}/v{3}/", steamWebApiBaseUrl, interfaceName, methodName, methodVersion); + string commandUrl = $"{steamWebApiUrl}/{interfaceName}/{methodName}/v{methodVersion}/"; // if we have parameters, join them together with & delimiter and append them to the command URL if (parameters != null && parameters.Count() > 0) { - string parameterString = String.Join("&", parameters); - commandUrl += String.Format("?{0}", parameterString); + string parameterString = string.Join("&", parameters); + commandUrl += $"?{parameterString}"; } return commandUrl; @@ -191,6 +221,16 @@ private string BuildRequestCommand(string interfaceName, string methodName, int /// private static FormUrlEncodedContent BuildRequestContent(IEnumerable parameters) { + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + if (!parameters.Any()) + { + parameters = new List(); + } + if (parameters != null && parameters.Count() > 0) { return new FormUrlEncodedContent(parameters.ToDictionary(p => p.Name, p => p.Value)); @@ -206,9 +246,9 @@ private static FormUrlEncodedContent BuildRequestContent(IEnumerableString containing the http endpoint response contents private static string CleanupResponseString(string stringToClean) { - if (String.IsNullOrWhiteSpace(stringToClean)) + if (string.IsNullOrWhiteSpace(stringToClean)) { - return String.Empty; + return string.Empty; } stringToClean = stringToClean.Replace("\n", ""); diff --git a/src/SteamWebAPI2/Utilities/SteamWebRequestParameter.cs b/src/SteamWebAPI2/Utilities/SteamWebRequestParameter.cs index b70e891..f2fab77 100644 --- a/src/SteamWebAPI2/Utilities/SteamWebRequestParameter.cs +++ b/src/SteamWebAPI2/Utilities/SteamWebRequestParameter.cs @@ -25,13 +25,13 @@ public class SteamWebRequestParameter /// Value to give this parameter public SteamWebRequestParameter(string name, string value) { - if (String.IsNullOrWhiteSpace(name)) + if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } - this.Name = name; - this.Value = value; + Name = name; + Value = value; } /// @@ -39,7 +39,7 @@ public SteamWebRequestParameter(string name, string value) /// public override string ToString() { - return String.Format("{0}={1}", Name, Value.ToString()); + return $"{Name}={Value}"; } } } \ No newline at end of file diff --git a/src/SteamWebAPI2/Utilities/SteamWebRequestParameterExtensions.cs b/src/SteamWebAPI2/Utilities/SteamWebRequestParameterExtensions.cs index 0dfda27..af44925 100644 --- a/src/SteamWebAPI2/Utilities/SteamWebRequestParameterExtensions.cs +++ b/src/SteamWebAPI2/Utilities/SteamWebRequestParameterExtensions.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace SteamWebAPI2.Utilities { @@ -43,7 +42,7 @@ internal static void AddIfHasValue(this IList list, /// List of web request parameters that will be used in the building of the request URL internal static void AddIfHasValue(this IList list, string value, string name) { - if (!String.IsNullOrEmpty(value)) + if (!string.IsNullOrEmpty(value)) { list.Add(new SteamWebRequestParameter(name, value)); } diff --git a/src/SteamWebAPI2/Utilities/SteamWebResponse.cs b/src/SteamWebAPI2/Utilities/SteamWebResponse.cs index 841c7f3..9c6112d 100644 --- a/src/SteamWebAPI2/Utilities/SteamWebResponse.cs +++ b/src/SteamWebAPI2/Utilities/SteamWebResponse.cs @@ -10,5 +10,26 @@ public class SteamWebResponse : ISteamWebResponse public string ContentTypeCharSet { get; set; } public DateTimeOffset? Expires { get; set; } public DateTimeOffset? LastModified { get; set; } + + public SteamWebResponse MapTo(Func mapFunction) + { + var mappedTo = new SteamWebResponse + { + ContentLength = this.ContentLength, + ContentType = this.ContentType, + ContentTypeCharSet = this.ContentTypeCharSet, + Expires = this.Expires, + LastModified = this.LastModified + }; + + if (this.Data == null) + { + return mappedTo; + } + + mappedTo.Data = mapFunction(this.Data); + + return mappedTo; + } } } \ No newline at end of file