writefreely-swift/docs/WFPost.md

2.1 KiB

WFPost

public struct WFPost 

Inheritance

Decodable

Initializers

init(body:title:appearance:language:rtl:createdDate:)

Creates a basic WFPost object.

public init(
        body: String,
        title: String? = nil,
        appearance: String? = nil,
        language: String? = nil,
        rtl: Bool? = nil,
        createdDate: Date? = nil
    ) 

This initializer creates a bare-minimum WFPost object for sending to the server; use the decoder-based initializer to populate its other properties from the server response.

Only the body parameter is required. If other properties are not provided, they will be generated by the server.

Parameters

  • body: The body text for the post.
  • title: The title for the post.
  • appearance: The appearance for the post; one of sans, serif/norm, wrap, mono, or code. Defaults to serif.
  • language: An ISO 639-1 language code.
  • rtl: Set to true to show content right-to-left.
  • createdDate: The published date for the post.

init(from:)

Creates a WFPost object from the server response.

public init(from decoder: Decoder) throws 

Primarily used by the WFClient to create a WFPost object from the JSON returned by the server.

Parameters

  • decoder: The decoder to use for translating the server response to a Swift object.

Throws

Error thrown by the try attempt when decoding any given property.

Properties

postId

public var postId: String?

slug

public var slug: String?

appearance

public var appearance: String?

language

public var language: String?

rtl

public var rtl: Bool?

createdDate

public var createdDate: Date?

updatedDate

public var updatedDate: Date?

title

public var title: String?

body

public var body: String

tags

public var tags: [String]?

views

public var views: Int?

collectionAlias

public var collectionAlias: String?