Structure
WFPost
public struct WFPost
Relationships
Conforms To
Decodable
Initializers
init(body:title:appearance:language:rtl:createdDate:)
public init(
body: String,
title: String? = nil,
appearance: String? = nil,
language: String? = nil,
rtl: Bool? = nil,
createdDate: Date? = nil
)
Creates a basic WFPost
object.
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
Name | Type | Description |
---|---|---|
body | String |
The body text for the post. |
title | String? |
The title for the post. |
appearance | String? |
The appearance for the post; one of |
language | String? |
An ISO 639-1 language code. |
rtl | Bool? |
Set to |
createdDate | Date? |
The published date for the post. |
init(from:)
public init(from decoder: Decoder) throws
Creates a WFPost
object from the server response.
Primarily used by the WFClient
to create a WFPost
object from the JSON returned by the server.
Parameters
Name | Type | Description |
---|---|---|
decoder | 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?