writefreely-swift/docs/WFPost.md

134 lines
2.1 KiB
Markdown

# WFPost
``` swift
public struct WFPost
```
## Inheritance
`Decodable`
## Initializers
### `init(body:title:appearance:language:rtl:createdDate:)`
Creates a basic `WFPost` object.
``` swift
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.
``` swift
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`
``` swift
public var postId: String?
```
### `slug`
``` swift
public var slug: String?
```
### `appearance`
``` swift
public var appearance: String?
```
### `language`
``` swift
public var language: String?
```
### `rtl`
``` swift
public var rtl: Bool?
```
### `createdDate`
``` swift
public var createdDate: Date?
```
### `updatedDate`
``` swift
public var updatedDate: Date?
```
### `title`
``` swift
public var title: String?
```
### `body`
``` swift
public var body: String
```
### `tags`
``` swift
public var tags: [String]?
```
### `views`
``` swift
public var views: Int?
```
### `collectionAlias`
``` swift
public var collectionAlias: String?
```