Skip to content

Commit cf4f95c

Browse files
committed
Address PR comments
1 parent 49f7863 commit cf4f95c

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

Diff for: GitHubComments.ps1

+38-30
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function Get-GitHubIssueComment
2626
Issue number to receive comments for.
2727
2828
.PARAMETER Since
29-
Only comments updated at or after this time are returned. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
29+
Only comments updated at or after this time are returned.
3030
3131
.PARAMETER AccessToken
3232
If provided, this will be used as the AccessToken for authentication with the
@@ -62,33 +62,37 @@ function Get-GitHubIssueComment
6262
[Parameter(Mandatory)]
6363
[int] $IssueNumber,
6464

65-
[string] $Since,
65+
[DateTime] $Since,
6666

6767
[string] $AccessToken,
6868

6969
[switch] $NoStatus
7070
)
7171

72-
Write-InvocationLog -Invocation $MyInvocation
72+
Write-InvocationLog
7373

74-
$elements = Resolve-RepositoryElements -BoundParameters $PSBoundParameters
74+
$elements = Resolve-RepositoryElements
7575
$OwnerName = $elements.ownerName
7676
$RepositoryName = $elements.repositoryName
7777

78+
if ($Since -ne $null) {
79+
$SinceFormattedTime = $Since.ToUniversalTime().ToString('o')
80+
}
81+
7882
$telemetryProperties = @{
7983
'OwnerName' = (Get-PiiSafeString -PlainText $OwnerName)
8084
'RepositoryName' = (Get-PiiSafeString -PlainText $RepositoryName)
81-
'Number' = $IssueNumber
82-
'Since' = $Since
85+
'IssueNumber' = $IssueNumber
86+
'Since' = $SinceFormattedTime
8387
}
8488

8589
$params = @{
86-
'UriFragment' = "repos/$OwnerName/$RepositoryName/issues/$IssueNumber/comments`?since=$Since"
90+
'UriFragment' = "repos/$OwnerName/$RepositoryName/issues/$IssueNumber/comments`?since=$SinceFormattedTime"
8791
'Description' = "Getting comments for issue $IssueNumber in $RepositoryName"
8892
'AccessToken' = $AccessToken
8993
'TelemetryEventName' = $MyInvocation.MyCommand.Name
9094
'TelemetryProperties' = $telemetryProperties
91-
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -BoundParameters $PSBoundParameters -Name NoStatus -ConfigValueName DefaultNoStatus)
95+
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus -ConfigValueName DefaultNoStatus)
9296
}
9397

9498
return Invoke-GHRestMethodMultipleResult @params
@@ -122,7 +126,7 @@ function Get-GitHubRepositoryComment
122126
How to list the results, either asc or desc. Ignored without the sort parameter.
123127
124128
.PARAMETER Since
125-
Only comments updated at or after this time are returned. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
129+
Only comments updated at or after this time are returned.
126130
127131
.PARAMETER AccessToken
128132
If provided, this will be used as the AccessToken for authentication with the
@@ -161,32 +165,36 @@ function Get-GitHubRepositoryComment
161165
[ValidateSet('asc', 'desc')]
162166
[string] $Direction,
163167

164-
[string] $Since,
168+
[DateTime] $Since,
165169

166170
[string] $AccessToken,
167171

168172
[switch] $NoStatus
169173
)
170174

171-
Write-InvocationLog -Invocation $MyInvocation
175+
Write-InvocationLog
172176

173-
$elements = Resolve-RepositoryElements -BoundParameters $PSBoundParameters
177+
$elements = Resolve-RepositoryElements
174178
$OwnerName = $elements.ownerName
175179
$RepositoryName = $elements.repositoryName
176180

181+
if ($Since -ne $null) {
182+
$SinceFormattedTime = $Since.ToUniversalTime().ToString('o')
183+
}
184+
177185
$telemetryProperties = @{
178186
'OwnerName' = (Get-PiiSafeString -PlainText $OwnerName)
179187
'RepositoryName' = (Get-PiiSafeString -PlainText $RepositoryName)
180-
'Number' = $IssueNumber
181-
'Sort' = $State
182-
'Direction' = $Sort
183-
'Since' = $Direction
188+
'IssueNumber' = $IssueNumber
189+
'Sort' = $Sort
190+
'Direction' = $Direction
191+
'Since' = $SinceFormattedTime
184192
}
185193

186194
$getParams = @(
187195
"sort=$Sort",
188196
"direction=$Direction",
189-
"since=$Since"
197+
"since=$SinceFormattedTime"
190198
)
191199

192200
$params = @{
@@ -196,7 +204,7 @@ function Get-GitHubRepositoryComment
196204
'AccessToken' = $AccessToken
197205
'TelemetryEventName' = $MyInvocation.MyCommand.Name
198206
'TelemetryProperties' = $telemetryProperties
199-
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -BoundParameters $PSBoundParameters -Name NoStatus -ConfigValueName DefaultNoStatus)
207+
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus -ConfigValueName DefaultNoStatus)
200208
}
201209

202210
return Invoke-GHRestMethod @params
@@ -264,9 +272,9 @@ function Get-GitHubComment
264272
[switch] $NoStatus
265273
)
266274

267-
Write-InvocationLog -Invocation $MyInvocation
275+
Write-InvocationLog
268276

269-
$elements = Resolve-RepositoryElements -BoundParameters $PSBoundParameters
277+
$elements = Resolve-RepositoryElements
270278
$OwnerName = $elements.ownerName
271279
$RepositoryName = $elements.repositoryName
272280

@@ -283,7 +291,7 @@ function Get-GitHubComment
283291
'AccessToken' = $AccessToken
284292
'TelemetryEventName' = $MyInvocation.MyCommand.Name
285293
'TelemetryProperties' = $telemetryProperties
286-
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -BoundParameters $PSBoundParameters -Name NoStatus -ConfigValueName DefaultNoStatus)
294+
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus -ConfigValueName DefaultNoStatus)
287295
}
288296

289297
return Invoke-GHRestMethod @params
@@ -358,9 +366,9 @@ function New-GitHubComment
358366
[switch] $NoStatus
359367
)
360368

361-
Write-InvocationLog -Invocation $MyInvocation
369+
Write-InvocationLog
362370

363-
$elements = Resolve-RepositoryElements -BoundParameters $PSBoundParameters
371+
$elements = Resolve-RepositoryElements
364372
$OwnerName = $elements.ownerName
365373
$RepositoryName = $elements.repositoryName
366374

@@ -382,7 +390,7 @@ function New-GitHubComment
382390
'AccessToken' = $AccessToken
383391
'TelemetryEventName' = $MyInvocation.MyCommand.Name
384392
'TelemetryProperties' = $telemetryProperties
385-
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -BoundParameters $PSBoundParameters -Name NoStatus -ConfigValueName DefaultNoStatus)
393+
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus -ConfigValueName DefaultNoStatus)
386394
}
387395

388396
return Invoke-GHRestMethod @params
@@ -457,9 +465,9 @@ function Edit-GitHubComment
457465
[switch] $NoStatus
458466
)
459467

460-
Write-InvocationLog -Invocation $MyInvocation
468+
Write-InvocationLog
461469

462-
$elements = Resolve-RepositoryElements -BoundParameters $PSBoundParameters
470+
$elements = Resolve-RepositoryElements
463471
$OwnerName = $elements.ownerName
464472
$RepositoryName = $elements.repositoryName
465473

@@ -481,7 +489,7 @@ function Edit-GitHubComment
481489
'AccessToken' = $AccessToken
482490
'TelemetryEventName' = $MyInvocation.MyCommand.Name
483491
'TelemetryProperties' = $telemetryProperties
484-
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -BoundParameters $PSBoundParameters -Name NoStatus -ConfigValueName DefaultNoStatus)
492+
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus -ConfigValueName DefaultNoStatus)
485493
}
486494

487495
return Invoke-GHRestMethod @params
@@ -550,9 +558,9 @@ function Remove-GitHubComment
550558
[switch] $NoStatus
551559
)
552560

553-
Write-InvocationLog -Invocation $MyInvocation
561+
Write-InvocationLog
554562

555-
$elements = Resolve-RepositoryElements -BoundParameters $PSBoundParameters
563+
$elements = Resolve-RepositoryElements
556564
$OwnerName = $elements.ownerName
557565
$RepositoryName = $elements.repositoryName
558566

@@ -569,7 +577,7 @@ function Remove-GitHubComment
569577
'AccessToken' = $AccessToken
570578
'TelemetryEventName' = $MyInvocation.MyCommand.Name
571579
'TelemetryProperties' = $telemetryProperties
572-
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -BoundParameters $PSBoundParameters -Name NoStatus -ConfigValueName DefaultNoStatus)
580+
'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus -ConfigValueName DefaultNoStatus)
573581
}
574582

575583
return Invoke-GHRestMethod @params

0 commit comments

Comments
 (0)