dependencies {
implementation("org.researchforyounow.core:publishing-automation:1.0.2")
}Create a keys.properties file in your project root:
# WordPress OAuth Configuration
wordpress.client.id=your_client_id
wordpress.client.secret=your_client_secret
wordpress.redirect.uri=your_redirect_uri
# WordPress API Configuration
wordpress.access.token=your_access_token
wordpress.blog.id=your_blog_idimport model.WordPressConfig
val config = WordPressConfig(
clientId = "your_client_id",
clientSecret = "your_client_secret",
accessToken = "your_access_token",
blogId = "your_blog_id",
redirectUri = "your_redirect_uri"
)import api.PublishingAutomationFactory
import model.*
import kotlinx.coroutines.runBlocking
fun main() = runBlocking {
// Create factory instance
val factory = PublishingAutomationFactory.create()
// Create publishing service (uses keys.properties)
val publishingService = factory.createWordPressPublishingService()
// Create content to publish
val content = PublishableContent(
title = "My First Blog Post",
content = "This is the content of my blog post. It supports **Markdown** and HTML!",
excerpt = "A brief summary of the post",
author = "John Doe"
)
// Configure publishing settings
val settings = PublishSettings(
status = PublishStatus.PUBLISHED,
tags = listOf("kotlin", "programming", "automation"),
categories = listOf("Technology", "Development")
)
// Create publishing input
val input = PublishingInput(
content = content,
publishSettings = settings
)
// Publish the content
publishingService.publish(input).fold(
onSuccess = { },
onFailure = { }
)
}Main entry point for creating services.
class PublishingAutomationFactory {
fun createWordPressPublishingService(): WordPressPublishingService
fun createWordPressPublishingService(config: WordPressConfig): WordPressPublishingService
// ... other factory methods
}Primary service interface for publishing operations.
interface WordPressPublishingService {
suspend fun publish(publishingInput: PublishingInput): Result<PublishingOutput>
suspend fun validateToken(accessToken: String): Boolean
}