Skip to content

Commit

Permalink
feat: Out-JSON ( Fixes #727 )
Browse files Browse the repository at this point in the history
    Adding Example
  • Loading branch information
StartAutomating authored and StartAutomating committed Mar 9, 2024
1 parent 3f31cc6 commit 9c7f2e4
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions Tests/Examples/Template.PipeScript.Rest.examples.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

describe 'Template.PipeScript.Rest' {
it 'Template.PipeScript.Rest Example 1' {
{
function Get-Sentiment {
[Rest("http://text-processing.com/api/sentiment/",
ContentType="application/x-www-form-urlencoded",
Method = "POST",
BodyParameter="Text",
ForeachOutput = {
$_ | Select-Object -ExpandProperty Probability -Property Label
}
)]
param()
}
} | .>PipeScript | Set-Content .\Get-Sentiment.ps1
}
it 'Template.PipeScript.Rest Example 2' {
Invoke-PipeScript {
[Rest("http://text-processing.com/api/sentiment/",
ContentType="application/x-www-form-urlencoded",
Method = "POST",
BodyParameter="Text",
ForeachOutput = {
$_ | Select-Object -ExpandProperty Probability -Property Label
}
)]
param()
} -Parameter @{Text='wow!'}
}
it 'Template.PipeScript.Rest Example 3' {
{
[Rest("https://api.github.com/users/{username}/repos",
QueryParameter={"type", "sort", "direction", "page", "per_page"}
)]
param()
} | .>PipeScript
}
it 'Template.PipeScript.Rest Example 4' {
Invoke-PipeScript {
[Rest("https://api.github.com/users/{username}/repos",
QueryParameter={"type", "sort", "direction", "page", "per_page"}
)]
param()
} -UserName StartAutomating
}
it 'Template.PipeScript.Rest Example 5' {
{
[Rest("http://text-processing.com/api/sentiment/",
ContentType="application/x-www-form-urlencoded",
Method = "POST",
BodyParameter={@{
Text = '
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[string]
$Text
'
}})]
param()
} | .>PipeScript
}
}

0 comments on commit 9c7f2e4

Please sign in to comment.