Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adbertram committed Jul 4, 2019
1 parent 6527101 commit 459774c
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 0 deletions.
20 changes: 20 additions & 0 deletions PSGhost.psd1
@@ -0,0 +1,20 @@
@{
RootModule = 'PSGhost.psm1'
ModuleVersion = '*'
GUID = '3b4869fa-45a9-41a1-a412-bd07c84559dc'
Author = 'Adam Bertram'
CompanyName = 'Adam the Automator, LLC'
Copyright = '(c) 2017 Adam Bertram. All rights reserved.'
Description = "This module is used to interact with the blogging platform, Ghost's API."
PowerShellVersion = '5.0'
FunctionsToExport = '*'
CmdletsToExport = '*'
VariablesToExport = '*'
AliasesToExport = '*'
PrivateData = @{
PSData = @{
Tags = @('PSModule', 'Ghost')
ProjectUri = 'https://github.com/adbertram/PSGhost'
}
}
}
19 changes: 19 additions & 0 deletions PSGhost.psm1
@@ -0,0 +1,19 @@
Set-StrictMode -Version Latest

# Get public and private function definition files.
$Public = @(Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue)
$Private = @(Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue)

# Dot source the files.
foreach ($import in @($Public + $Private)) {
try {
Write-Verbose "Importing $($import.FullName)"
. $import.FullName
} catch {
Write-Error "Failed to import function $($import.FullName): $_"
}
}

foreach ($file in $Public) {
Export-ModuleMember -Function $file.BaseName
}
Empty file added Private/InvokeGhostAPICall.ps1
Empty file.
33 changes: 33 additions & 0 deletions Public/Get-GhostApiKey.ps1
@@ -0,0 +1,33 @@
function Get-GhostApiKey {
<#
.SYNOPSIS
Queries the API key configuration to return the API key set earlier via the Save-GhostApiKey command.
.EXAMPLE
PS> Get-GhostApiKey
This example pulls the API key from the configuration file.
#>
[CmdletBinding()]
param
()

$ErrorActionPreference = 'Stop'

function decrypt([string]$TextToDecrypt) {
$secure = ConvertTo-SecureString $TextToDecrypt
$hook = New-Object system.Management.Automation.PSCredential("test", $secure)
$plain = $hook.GetNetworkCredential().Password
return $plain
}

try {
$atKey = decrypt $encApiKey
$script:GhostApiKey = $atKey
$script:GhostApiKey
} catch {
$PSCmdlet.ThrowTerminatingError($_)
}
}
29 changes: 29 additions & 0 deletions Public/Save-GhostAPIKey.ps1
@@ -0,0 +1,29 @@
function Save-GhostApiKey {
<#
.SYNOPSIS
Saves the API key to the configuration file obtained from your Ghost account integration
.EXAMPLE
PS> Save-GhostApiKey -ApiKey foobar
Saves the value 'foobar' in the configuration APIKey value.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$ApiKey
)

function encrypt([string]$TextToEncrypt) {
$secure = ConvertTo-SecureString $TextToEncrypt -AsPlainText -Force
$encrypted = $secure | ConvertFrom-SecureString
return $encrypted
}

throw 'finish this'
# $config = Get-PSAirTableConfiguration
# $config.Application.ApiKey = encrypt($ApiKey)
# $config | ConvertTo-Json | Set-Content -Path "$WorkingDir\Configuration.json"
}
3 changes: 3 additions & 0 deletions configuration.json
@@ -0,0 +1,3 @@
{
"ApiKey": "XXXXXX"
}

0 comments on commit 459774c

Please sign in to comment.