ApiEndpoints.psm1

<#
.SYNOPSIS
    This function retrieves the Tech Data API Endpoint URL for the specified scenario.
#>

function Get-TechDataApiEndpointUrl {
    param (
        # Select the endpoint environment.
        [Parameter(Mandatory=$true)]
        [ValidateSet("production", "test")]
        [String]$environment,

        # Select the endpoint to retrieve customers.
        [Parameter(Mandatory=$true, ParameterSetName="getCustomer")]
        [Switch]$getCustomer,

        # Select the endpoint to retrieve a customer's details.
        [Parameter(Mandatory=$true, ParameterSetName="getCustomerDetails")]
        [Switch]$getCustomerDetails,

        # Select the endpoint to create a customer.
        [Parameter(Mandatory=$true, ParameterSetName="newCustomer")]
        [Switch]$newCustomer,

        # Select the endpoint to create an order.
        [Parameter(Mandatory=$true, ParameterSetName="newOrder")]
        [Switch]$newOrder,

        # Select the endpoint to retrieve products.
        [Parameter(Mandatory=$true, ParameterSetName="getProduct")]
        [Switch]$getProduct
    )

    # Return the endpoint URL that matches the inputs
    if ($PSCmdlet.ParameterSetName -eq "getCustomer") {
        if ($environment -eq "production") {
            return "https://partnerapi.tdstreamone.com/endCustomer/details/{0}"
        }
        else {
            return "https://us-uat-partnerapi.tdmarketplace.net/endCustomer/details/{0}"
        }
    }
    elseif ($PSCmdlet.ParameterSetName -eq "getCustomerDetails") {
        if ($environment -eq "production") {
            return "https://partnerapi.tdstreamone.com/endCustomer/{0}"
        }
        else {
            return "https://us-uat-partnerapi.tdmarketplace.net/endCustomer/{0}"
        }
    }
    elseif ($PSCmdlet.ParameterSetName -eq "newCustomer") {
        if ($environment -eq "production") {
            return "https://partnerapi.tdstreamone.com/endCustomer/"
        }
        else {
            return "https://us-uat-partnerapi.tdmarketplace.net/endCustomer/"
        }
    }
    elseif ($PSCmdlet.ParameterSetName -eq "newOrder") {
        if ($environment -eq "production") {
            return "https://partnerapi.tdstreamone.com/order/"
        }
        else {
            return "https://us-uat-partnerapi.tdmarketplace.net/order/"
        }
    }
    elseif ($PSCmdlet.ParameterSetName -eq "getProduct") {
        if ($environment -eq "production") {
            return "https://partnerapi.tdstreamone.com/catalog/products/{0}"
        }
        else {
            return "https://us-uat-partnerapi.tdmarketplace.net/catalog/products/{0}"
        }
    }
}