Skip to content

Commit

Permalink
Add URL push (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
thekamilpro authored Mar 24, 2024
1 parent 8531a71 commit 1139938
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/public/URL/New-PwpushUrl.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
function New-PwpushUrl
{
<#
.SYNOPSIS
Create a new URL push.
.DESCRIPTION
Create a new URL push.
.LINK
https://pwpush.com/api/1.0/urls/create.en.html
.EXAMPLE
New-KpPwpushFile -Payload mySecret
Creates a new push with payload of mySecret
#>

[cmdletbinding()]
param (
[Parameter(Mandatory)]
[string]$Payload,

[string]$Passphrase,

[string]$Note = "",

[ValidateRange(1, 90)]
[int]$ExpireAfterDays = 7,

[ValidateRange(1, 100)]
[int]$ExpireAfterViews = 5,

[bool]$DeletableByViewer = $true,

[bool]$RetrievalStep = $false
)

$endpoint = "r.json"

$data = @{
url = @{
"payload" = $Payload
"expire_after_days" = $ExpireAfterDays
"expire_after_views" = $ExpireAfterViews
"deletable_by_viewer" = $DeletableByViewer
"retrieval_step" = $RetrievalStep
}
}

switch ($PSBoundParameters.GetEnumerator() )
{
{ $_.Key -eq "Note" } { $data.url[$_.Key.ToLower()] = $_.Value }
{ $_.Key -eq "Passphrase" } { $data.url[$_.Key.ToLower()] = $_.Value }
}

$body = $data | ConvertTo-Json

$params = @{
Endpoint = $endpoint
Method = "Post"
Body = $body
}
Invoke-PwpushRequest @params
}

0 comments on commit 1139938

Please sign in to comment.