@@ -126,6 +126,74 @@ Updates item values in a GitHub project
126126This is an integration function that is not intended to be used directly by the user.
127127Updates the values of specific fields for an item in a GitHub project.
128128#>
129+ # function Invoke-GitHubUpdateItemValues{
130+ # param(
131+ # [Parameter(Mandatory=$true)] [string]$ProjectId,
132+ # [Parameter(Mandatory=$true)] [string]$ItemId,
133+ # [Parameter(Mandatory=$true)] [string]$FieldId,
134+ # [Parameter(Mandatory=$true)] [object]$Value,
135+ # [Parameter(Mandatory=$true)] [ValidateSet("singleSelectOptionId", "text", "number", "date", "iterationId")]
136+ # [string]$Type
137+ # )
138+
139+ # "ProjectId: $ProjectId, ItemId: $ItemId, FieldId: $FieldId, Value: $Value, Type: $Type" | Write-MyDebug -section "driver_gh"
140+
141+ # # Use the environmentraviable
142+ # $token = Get-GithubToken
143+ # if(-not $token){
144+ # throw "GH Cli Auth Token not available. Run 'gh auth login' in your terminal."
145+ # }
146+
147+ # # Define the GraphQL query with variables
148+ # $mutation = Get-GraphQLString "updateItemValues.mutant"
149+
150+
151+
152+ # # Define the headers for the request
153+ # $headers = @{
154+ # "Authorization" = "Bearer $token"
155+ # "Content-Type" = "application/json"
156+ # }
157+
158+ # # Ensure that if the $type is number the value is a number
159+ # # API fails if when updaring a number the value type in the Input payload s not a number
160+ # if($Type -eq "number"){
161+ # $Value = [decimal]$Value
162+ # }
163+
164+ # # Define the variables for the request
165+ # $variables = @{
166+ # input = @{
167+ # projectId = $ProjectId
168+ # itemId = $ItemId
169+ # fieldId = $FieldId
170+ # value = @{
171+ # $Type=$Value
172+ # }
173+ # }
174+ # }
175+
176+ # # Define the body for the request
177+ # $body = @{
178+ # query= $mutation
179+ # variables = $variables
180+ # } | ConvertTo-Json -Depth 10
181+
182+ # # Send the request
183+ # $response = Invoke-RestMethod -Uri 'https://api.github.com/graphql' -Method Post -Body $body -Headers $headers
184+
185+ # # Check if here are errors
186+ # if($response.errors){
187+ # $response.errors | ForEach-Object {
188+ # getErrrorString -Errors $response.errors | Write-MyError
189+ # }
190+ # return $null
191+ # }
192+
193+ # # Return the field names
194+ # return $response
195+ # } Export-ModuleMember -Function Invoke-GitHubUpdateItemValues
196+
129197function Invoke-GitHubUpdateItemValues {
130198 param (
131199 [Parameter (Mandatory = $true )] [string ]$ProjectId ,
@@ -138,23 +206,9 @@ function Invoke-GitHubUpdateItemValues{
138206
139207 " ProjectId: $ProjectId , ItemId: $ItemId , FieldId: $FieldId , Value: $Value , Type: $Type " | Write-MyDebug - section " driver_gh"
140208
141- # Use the environmentraviable
142- $token = Get-GithubToken
143- if (-not $token ){
144- throw " GH Cli Auth Token not available. Run 'gh auth login' in your terminal."
145- }
146-
147209 # Define the GraphQL query with variables
148210 $mutation = Get-GraphQLString " updateItemValues.mutant"
149211
150-
151-
152- # Define the headers for the request
153- $headers = @ {
154- " Authorization" = " Bearer $token "
155- " Content-Type" = " application/json"
156- }
157-
158212 # Ensure that if the $type is number the value is a number
159213 # API fails if when updaring a number the value type in the Input payload s not a number
160214 if ($Type -eq " number" ){
@@ -173,22 +227,7 @@ function Invoke-GitHubUpdateItemValues{
173227 }
174228 }
175229
176- # Define the body for the request
177- $body = @ {
178- query = $mutation
179- variables = $variables
180- } | ConvertTo-Json - Depth 10
181-
182- # Send the request
183- $response = Invoke-RestMethod - Uri ' https://api.github.com/graphql' - Method Post - Body $body - Headers $headers
184-
185- # Check if here are errors
186- if ($response.errors ){
187- $response.errors | ForEach-Object {
188- getErrrorString - Errors $response.errors | Write-MyError
189- }
190- return $null
191- }
230+ $response = Invoke-GraphQL - Query $mutation - Variables $variables
192231
193232 # Return the field names
194233 return $response
0 commit comments