Public/ClockTimes/New-AspireClockTime.ps1
|
<#
.SYNOPSIS Creates a new clock time entry in the Aspire API. .DESCRIPTION Uses Invoke-AspireRequest to perform a POST request to the /ClockTimes endpoint. .PARAMETER ContactID The ID of the contact (integer). .PARAMETER ClockStartLat The latitude for clock start (double). .PARAMETER ClockStartLong The longitude for clock start (double). .PARAMETER ClockStartDateTime The start date and time (required, string in date-time format). .PARAMETER BreakTime The break time in hours (decimal). .PARAMETER RouteID The ID of the route (integer, nullable). .PARAMETER CrewLeaderContactID The ID of the crew leader contact (integer, nullable). .PARAMETER ClockEndLat The latitude for clock end (double). .PARAMETER ClockEndLong The longitude for clock end (double). .PARAMETER ClockEndDateTime The end date and time (required, string in date-time format). .OUTPUTS The response from the API, typically the ID of the created clock time. .EXAMPLE New-AspireClockTime -ContactID 123 -ClockStartDateTime "2023-01-01T08:00:00Z" -ClockEndDateTime "2023-01-01T17:00:00Z" #> function New-AspireClockTime { [CmdletBinding()] param( [Parameter(Mandatory = $true)] [int]$ContactID, [double]$ClockStartLat = $null, [double]$ClockStartLong = $null, [Parameter(Mandatory = $true)] [string]$ClockStartDateTime, [decimal]$BreakTime = $null, [int]$RouteID = $null, [int]$CrewLeaderContactID = $null, [double]$ClockEndLat = $null, [double]$ClockEndLong = $null, [Parameter(Mandatory = $true)] [string]$ClockEndDateTime ) $body = @{ ContactID = $ContactID ClockStartDateTime = $ClockStartDateTime ClockEndDateTime = $ClockEndDateTime } if ($ClockStartLat) { $body.ClockStartLat = $ClockStartLat } if ($ClockStartLong) { $body.ClockStartLong = $ClockStartLong } if ($BreakTime) { $body.BreakTime = $BreakTime } if ($RouteID) { $body.RouteID = $RouteID } if ($CrewLeaderContactID) { $body.CrewLeaderContactID = $CrewLeaderContactID } if ($ClockEndLat) { $body.ClockEndLat = $ClockEndLat } if ($ClockEndLong) { $body.ClockEndLong = $ClockEndLong } return Invoke-AspireRequest -Method POST -Path "/ClockTimes" -Body $body } |