-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
Tests/Examples/Template.PipeScript.Rest.examples.tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
|