Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Modules/AuthenticationHelper/AuthenticationHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function Get-AccessKey
Set-BaseUri -uri $baseUri
}

# Define the token file path in the same directory as the script
$tokenFile = Join-Path -Path $PSScriptRoot -ChildPath "accessToken.json"
# Cache the token in the system temp folder (not the module directory)
$tokenFile = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath "lc-toolkit-accessToken.json"

# Check if JSON file exists
if (Test-Path $tokenFile) {
Expand All @@ -74,7 +74,7 @@ function Get-AccessKey
-and $tokenData.client_id -eq $id `
-and $tokenData.expires_at) {
$currentTime = Get-Date
$tokenExpiration = [datetime]::Parse($tokenData.expires_at)
$tokenExpiration = [datetime]::Parse($tokenData.expires_at, [System.Globalization.CultureInfo]::InvariantCulture)

# If token is valid, return it
if ($currentTime -lt $tokenExpiration) {
Expand Down Expand Up @@ -117,7 +117,7 @@ function Get-AccessKey
"expires_at" = $expirationTime.ToString("yyyy-MM-ddTHH:mm:ss")
}

# Write the token data to accessToken.json (create or update)
# Write the token data to the temp folder
$accessKeyData | ConvertTo-Json | Set-Content -Path $tokenFile

return @{
Expand All @@ -135,4 +135,4 @@ function Get-AccessKey
}
}

Export-ModuleMember Get-AccessKey
Export-ModuleMember Get-AccessKey
6 changes: 3 additions & 3 deletions Modules/CommonHelper/CommonHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ function Get-AllItems
The matching item object, or $null if not found.

.EXAMPLE
$template = Get-Item -accessKey $accessKey -uri "$baseUri/project-templates" -id "12345" -propertyName "Project template"
$template = Get-SingleItem -accessKey $accessKey -uri "$baseUri/project-templates" -id "12345" -propertyName "Project template"
#>
function Get-Item
function Get-SingleItem
{
param (
[Parameter(Mandatory=$true)]
Expand Down Expand Up @@ -572,7 +572,7 @@ Export-ModuleMember -Function Get-BaseUri
Export-ModuleMember -Function Set-BaseUri
Export-ModuleMember -Function Get-RequestHeader
Export-ModuleMember -Function Get-AllItems
Export-ModuleMember -Function Get-Item
Export-ModuleMember -Function Get-SingleItem
Export-ModuleMember -Function Get-StringUri
Export-ModuleMember -Function Get-FilterString
Export-ModuleMember -Function Invoke-SafeMethod
Expand Down
3 changes: 2 additions & 1 deletion Modules/ProjectHelper/ProjectHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ function New-Project
-description $description;

# return @($projectBody | ConvertTo-Json -Depth 10);
# Write-Host ($projectBody | ConvertTo-Json -Depth 10) -ForegroundColor Magenta
$projectCreateResponse = Get-ProjectCreationRequest -accessKey $accessKey -project $projectBody

Write-Host "Creating the project..." -ForegroundColor Green
Expand Down Expand Up @@ -375,7 +376,7 @@ function Get-Project
[string] $projectName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/projects" -id $projectId -name $projectName `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/projects" -id $projectId -name $projectName `
-uriQuery "?fields=id,name" `
-propertyName "Project"
}
Expand Down
26 changes: 13 additions & 13 deletions Modules/ResourcesHelper/ResourcesHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function Get-ProjectTemplate
[String] $projectTemplateName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/project-templates" -uriQuery "?fields=id,name,description,languageDirections,location" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/project-templates" -uriQuery "?fields=id,name,description,languageDirections,location" `
-id $projectTemplateId -name $projectTemplateName -propertyName "Project template";
}

Expand Down Expand Up @@ -1151,7 +1151,7 @@ function Get-TranslationEngine
[String] $translationEngineName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/translation-engines" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/translation-engines" `
-uriQuery "?fields=name,description,location,definition" -id $translationEngineId `
-name $translationEngineName -propertyName "Translation engine"
}
Expand Down Expand Up @@ -1274,7 +1274,7 @@ function Get-Customer
[string] $customerName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/customers" -uriQuery "?fields=id,name,location" -id $customerId -name $customerName -propertyName "Customer";
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/customers" -uriQuery "?fields=id,name,location" -id $customerId -name $customerName -propertyName "Customer";
}

<#
Expand Down Expand Up @@ -1711,7 +1711,7 @@ function Get-FileTypeConfiguration
[string] $fileTypeName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/file-processing-configurations" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/file-processing-configurations" `
-uriQuery "?fields=id,name,location" -id $fileTypeId -name $fileTypeName `
-propertyName "File processing configuration"
}
Expand Down Expand Up @@ -1833,7 +1833,7 @@ function Get-Workflow
[string] $workflowName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/workflows" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/workflows" `
-uriQuery "?fields=id,name,description,location,workflowTemplate,languageDirections" `
-id $workflowId -name $workflowName -propertyName "Workflow";
}
Expand Down Expand Up @@ -1949,7 +1949,7 @@ function Get-PricingModel {
[String] $pricingModelName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/pricing-models" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/pricing-models" `
-uriQuery "?fields=id,name,description,currencyCode,location" -id $pricingModelId -name $pricingModelName `
-propertyName "Pricing model"
}
Expand Down Expand Up @@ -2066,7 +2066,7 @@ function Get-ScheduleTemplate
[string] $scheduleTemplateName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/schedule-templates" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/schedule-templates" `
-uriQuery "?fields=name,description,location" -id $scheduleTemplateId -name $scheduleTemplateName `
-propertyName "Schedule template"
}
Expand Down Expand Up @@ -2203,7 +2203,7 @@ function Get-Location
[String] $locationName
)

return Get-Item -accessKey $accessKey -id $locationId -name $locationName -uri "$(Get-LCBaseUri)/folders" -propertyName "Folder";
return Get-SingleItem -accessKey $accessKey -id $locationId -name $locationName -uri "$(Get-LCBaseUri)/folders" -propertyName "Folder";
}

<#
Expand Down Expand Up @@ -2323,7 +2323,7 @@ function Get-CustomField
[String] $customFieldName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/custom-field-definitions" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/custom-field-definitions" `
-propertyName "Custom field definition" `
-uriQuery "?fields=id,name,key,description,defaultValue,type,location,resourceType,isMandatory,pickListOptions" `
-id $customFieldId -name $customFieldName;
Expand Down Expand Up @@ -2441,7 +2441,7 @@ function Get-TranslationMemory
[string] $translationMemoryName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/translation-memory" -id $translationMemoryId -name $translationMemoryName -propertyName "Translation memory";
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/translation-memory" -id $translationMemoryId -name $translationMemoryName -propertyName "Translation memory";
}

<#
Expand Down Expand Up @@ -3284,7 +3284,7 @@ function Get-TranslationQualityAssessment
[string] $tqaName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/tqa-profiles" -id $tqaId -name $tqaName -propertyName "Tqa profile";
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/tqa-profiles" -id $tqaId -name $tqaName -propertyName "Tqa profile";
}

<#
Expand Down Expand Up @@ -3399,7 +3399,7 @@ function Get-LanguageProcessingRule
[string] $languageProcessingName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/language-processing-rules" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/language-processing-rules" `
-uriQuery "?fields=id,name,description" -id $languageProcessingId -name $languageProcessingName `
-propertyName "Language processing rule"
}
Expand Down Expand Up @@ -3526,7 +3526,7 @@ function Get-FieldTemplate
[string] $fieldTemplateName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/translation-memory/field-templates" -uriQuery "?fields=id,name,description,location" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/translation-memory/field-templates" -uriQuery "?fields=id,name,description,location" `
-id $fieldTemplateId -name $fieldTemplateName -propertyName "Field template";
}

Expand Down
4 changes: 2 additions & 2 deletions Modules/TerminologyHelper/TerminologyHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function Get-Termbase
[string] $termbaseName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/termbases" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/termbases" `
-uriQuery "?fields=id,name,description,copyright,location,termbaseStructure" `
-id $termbaseId -name $termbaseName -propertyName "Termbase"
}
Expand Down Expand Up @@ -841,7 +841,7 @@ function Get-TermbaseTemplate
[string] $termbaseTemplateName
)

return Get-Item -accessKey $accessKey -uri "$(Get-LCBaseUri)/termbase-templates" `
return Get-SingleItem -accessKey $accessKey -uri "$(Get-LCBaseUri)/termbase-templates" `
-uriQuery "?fields=id,name,description,copyright,location,type,languages,fields.name,fields.level,fields.dataType,fields.pickListValues,fields.allowCustomValues,fields.allowMultiple,fields.isMandatory" `
-id $termbaseTemplateId -name $termbaseTemplateName -propertyName "Termbase template"
}
Expand Down
6 changes: 3 additions & 3 deletions Modules/UsersHelper/UsersHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ function Get-Group

$baseUri = Get-BaseUri

return Get-Item -accessKey $accessKey -uri "$baseUri/groups" `
return Get-SingleItem -accessKey $accessKey -uri "$baseUri/groups" `
-id $groupId -name $groupName -propertyName "Group"
}

Expand Down Expand Up @@ -1045,7 +1045,7 @@ function Get-Role

$baseUri = Get-BaseUri

return Get-Item -accessKey $accessKey -uri "$baseUri/roles" `
return Get-SingleItem -accessKey $accessKey -uri "$baseUri/roles" `
-id $roleId -name $roleName -propertyName "Role"
}

Expand Down Expand Up @@ -1348,7 +1348,7 @@ function Get-Application

$baseUri = Get-BaseUri

return Get-Item -accessKey $accessKey -uri "$baseUri/applications" `
return Get-SingleItem -accessKey $accessKey -uri "$baseUri/applications" `
-id $applicationId -name $applicationName -propertyName "Application"
}

Expand Down