2024-05-07 22:03:15 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-05-08 22:48:13 +00:00
|
|
|
"federated.computer/wp-sync-slowtwitch/services/wordpress"
|
2024-05-07 22:03:15 +00:00
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
const baseUrl = "https://go-api-playground.local/wp-json/wp/v2/"
|
2024-05-08 00:52:47 +00:00
|
|
|
const wordpressKey = "admin"
|
|
|
|
const wordpressSecret = "S34E keY1 A1uX 6ncs Rx4T f21W"
|
2024-05-07 22:03:15 +00:00
|
|
|
|
|
|
|
var appCache AppCache
|
|
|
|
|
|
|
|
func main() {
|
2024-05-09 20:06:01 +00:00
|
|
|
// TODO Create Category with or without parent + add to cache
|
|
|
|
// TODO Use cached data to correctly build post form submissions
|
|
|
|
|
|
|
|
categoryNames := []string{"testcat", "testcat3", "you wont find me"}
|
|
|
|
|
|
|
|
for _, categoryName := range categoryNames {
|
|
|
|
categoryData, ok := wordpress.GetCategory(categoryName, baseUrl, wordpressKey, wordpressSecret)
|
|
|
|
|
|
|
|
if ok {
|
|
|
|
appCache.SetCategory(categoryData)
|
|
|
|
fmt.Println(categoryData.Name, categoryData.Id, categoryData.ParentId)
|
|
|
|
} else {
|
|
|
|
fmt.Println("not found on website: ", categoryName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, categoryName := range categoryNames {
|
|
|
|
category, ok := appCache.GetCategory(categoryName)
|
|
|
|
|
|
|
|
if ok {
|
|
|
|
fmt.Println("Found single in cache: ", category.Name)
|
|
|
|
} else {
|
|
|
|
fmt.Println("Not found in cache:", categoryName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, category := range appCache.CategoryCache {
|
|
|
|
fmt.Println("From Cache: ", category.Name)
|
2024-05-08 22:48:13 +00:00
|
|
|
}
|
2024-05-07 22:03:15 +00:00
|
|
|
}
|