Scripts/Get-CoinbaseCurrencyList.ps1


Function Get-CoinbaseCurrencyList {

    <#
 
    .SYNOPSIS
 
    Gets a list of all known currencies. Note: Not all currencies may be currently in use for trading
 
    .DESCRIPTION
 
    Gets a list of all known currencies. Note: Not all currencies may be currently in use for trading
 
    .EXAMPLE
 
    Get-CoinbaseCurrencyList
 
    .NOTES
 
    N/A
 
    .LINK
 
    N/A
 
    #>


    [CmdletBinding ()]

    Param ()

    BEGIN {

        Function Show-Output ($Values) {

            [PSCustomObject]@{

                Name = $Values.Name
                Id = $Values.Id
                Type = $Values.Details.Type
                DefaultNetwork = $Values.Default_Network
                MinimumSize = $Values.Min_Size
                MaximumPrecision = $Values.Max_Precision
                Status = $Status

            }

        }

    }

    PROCESS {

        Try {

            $Headers = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]'
            $Headers.Add('Content-Type', 'application/json')

            $Response = Invoke-RestMethod 'https://api.exchange.coinbase.com/currencies' -Method 'GET' -Headers $Headers

            ForEach ($Item In $Response) {

                $Status = 'Ok'

                Show-Output ($Item)

            }

        }

        Catch {

            $Status = $PSItem.Exception.Message

            Show-Output ('')

        }

    }

    END {}

}