From 6b54f2980c497b4371a177b3947f584be49cc866 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Mon, 17 Aug 2020 09:53:47 -0400 Subject: [PATCH 1/6] Rename WriteFreelyClient to WFClient --- .../{WriteFreelyClient.swift => WFClient.swift} | 8 ++++---- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) rename Sources/WriteFreely/{WriteFreelyClient.swift => WFClient.swift} (99%) create mode 100644 WFPackagePlayground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Sources/WriteFreely/WriteFreelyClient.swift b/Sources/WriteFreely/WFClient.swift similarity index 99% rename from Sources/WriteFreely/WriteFreelyClient.swift rename to Sources/WriteFreely/WFClient.swift index 791538f..ef54326 100644 --- a/Sources/WriteFreely/WriteFreelyClient.swift +++ b/Sources/WriteFreely/WFClient.swift @@ -35,13 +35,13 @@ struct NestedPostsJson: Decodable { let data: [Post] } -public class WriteFreelyClient { +public class WFClient { let decoder = JSONDecoder() public var requestURL: URL public var user: User? - /// Initializes the WriteFreelyClient. + /// Initializes the WriteFreely client. /// /// Required for connecting to the API endpoints of a WriteFreely instance. /// @@ -877,7 +877,7 @@ public class WriteFreelyClient { /// Logs the user in to their account on the WriteFreely instance. /// - /// On successful login, the `WriteFreelyClient`'s `user` property is set to the returned `User` object; this allows + /// On successful login, the `WFClient`'s `user` property is set to the returned `User` object; this allows /// authenticated requests to be made without having to provide an access token. /// /// It is otherwise not necessary to login the user if their access token is provided to the calling function. @@ -1081,7 +1081,7 @@ public class WriteFreelyClient { } } -private extension WriteFreelyClient { +private extension WFClient { func translateWriteFreelyError(fromServerResponse response: Data) -> WriteFreelyError? { do { let error = try self.decoder.decode(ErrorMessage.self, from: response) diff --git a/WFPackagePlayground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/WFPackagePlayground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/WFPackagePlayground.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + From 5dfe6c7077cde7351c5cd1604c5a0110a730596c Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Mon, 17 Aug 2020 10:02:53 -0400 Subject: [PATCH 2/6] Rename WriteFreelyError to WFError --- Sources/WriteFreely/WFClient.swift | 108 +++++++++--------- .../{WriteFreelyError.swift => WFError.swift} | 2 +- 2 files changed, 55 insertions(+), 55 deletions(-) rename Sources/WriteFreely/{WriteFreelyError.swift => WFError.swift} (93%) diff --git a/Sources/WriteFreely/WFClient.swift b/Sources/WriteFreely/WFClient.swift index ef54326..d0b64b2 100644 --- a/Sources/WriteFreely/WFClient.swift +++ b/Sources/WriteFreely/WFClient.swift @@ -107,7 +107,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 201 CREATED, return the Collection as success; if not, return a WriteasError as failure. + // If we get a 201 CREATED, return the Collection as success; if not, return a WFError as failure. if response.statusCode == 201 { do { let collection = try self.decoder.decode(ServerData.self, from: data) @@ -117,8 +117,8 @@ public class WFClient { completion(.failure(error)) } } else { - // We didn't get a 200 OK, so return a WriteasError - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -159,7 +159,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the User as success; if not, return a WFError as failure. if response.statusCode == 200 { do { let collection = try self.decoder.decode(ServerData.self, from: data) @@ -169,8 +169,8 @@ public class WFClient { completion(.failure(error)) } } else { - // We didn't get a 200 OK, so return a WriteasError - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -217,9 +217,9 @@ public class WFClient { do { _ = try result.get() completion(.failure(error)) - } catch WriteFreelyError.notFound { + } catch WFError.notFound { completion(.success(true)) - } catch WriteFreelyError.unauthorized { + } catch WFError.unauthorized { completion(.success(true)) } catch { completion(.failure(error)) @@ -232,10 +232,10 @@ public class WFClient { if let response = response as? HTTPURLResponse { // We got a response. If it's a 204 NO CONTENT, return true as success; - // if not, return a WriteasError as failure. + // if not, return a WFError as failure. if response.statusCode != 204 { guard let data = data else { return } - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } else { completion(.success(true)) @@ -291,7 +291,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the User as success; if not, return a WFError as failure. if response.statusCode == 200 { do { // The response is formatted differently depending on if we're getting user posts or collection @@ -308,8 +308,8 @@ public class WFClient { completion(.failure(error)) } } else { - // We didn't get a 200 OK, so return a WriteasError. - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError. + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -378,12 +378,12 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return true as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return true as success; if not, return a WFError as failure. if response.statusCode == 200 { completion(.success(true)) } else { - // We didn't get a 200 OK, so return a WriteasError - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -452,12 +452,12 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the User as success; if not, return a WFError as failure. if response.statusCode == 200 { completion(.success(true)) } else { - // We didn't get a 200 OK, so return a WriteasError - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -513,12 +513,12 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the User as success; if not, return a WFError as failure. if response.statusCode == 200 { completion(.success(true)) } else { - // We didn't get a 200 OK, so return a WriteasError - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -591,7 +591,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the Post as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the Post as success; if not, return a WFError as failure. if response.statusCode == 201 { do { let post = try self.decoder.decode(ServerData.self, from: data) @@ -601,8 +601,8 @@ public class WFClient { completion(.failure(error)) } } else { - // We didn't get a 200 OK, so return a WriteasError - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -642,7 +642,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the User as success; if not, return a WFError as failure. if response.statusCode == 200 { do { let post = try self.decoder.decode(ServerData.self, from: data) @@ -652,8 +652,8 @@ public class WFClient { completion(.failure(error)) } } else { - // We didn't get a 200 OK, so return a WriteasError - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -699,7 +699,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the User as success; if not, return a WFError as failure. if response.statusCode == 200 { do { let post = try self.decoder.decode(ServerData.self, from: data) @@ -709,8 +709,8 @@ public class WFClient { completion(.failure(error)) } } else { - // We didn't get a 200 OK, so return a WriteasError - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -772,7 +772,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the Post as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the Post as success; if not, return a WFError as failure. if response.statusCode == 200 { do { let post = try self.decoder.decode(ServerData.self, from: data) @@ -782,8 +782,8 @@ public class WFClient { completion(.failure(error)) } } else { - // We didn't get a 200 OK, so return a WriteasError - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -833,11 +833,11 @@ public class WFClient { do { _ = try result.get() completion(.failure(error)) - } catch WriteFreelyError.notFound { + } catch WFError.notFound { completion(.success(true)) - } catch WriteFreelyError.unauthorized { + } catch WFError.unauthorized { completion(.success(true)) - } catch WriteFreelyError.internalServerError { + } catch WFError.internalServerError { // If you try to delete a non-existent post, the API returns a 500 Internal Server Error. completion(.success(true)) } catch { @@ -851,10 +851,10 @@ public class WFClient { if let response = response as? HTTPURLResponse { // We got a response. If it's a 204 NO CONTENT, return true as success; - // if not, return a WriteasError as failure. + // if not, return a WFError as failure. if response.statusCode != 204 { guard let data = data else { return } - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } else { completion(.success(true)) @@ -913,7 +913,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the User as success; if not, return a WFError as failure. if response.statusCode == 200 { do { let user = try self.decoder.decode(User.self, from: data) @@ -923,8 +923,8 @@ public class WFClient { completion(.failure(error)) } } else { - // We didn't get a 200 OK, so return a WriteasError - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -965,10 +965,10 @@ public class WFClient { do { _ = try result.get() completion(.failure(error)) - } catch WriteFreelyError.notFound { + } catch WFError.notFound { self.user = nil completion(.success(true)) - } catch WriteFreelyError.unauthorized { + } catch WFError.unauthorized { self.user = nil completion(.success(true)) } catch { @@ -982,10 +982,10 @@ public class WFClient { if let response = response as? HTTPURLResponse { // We got a response. If it's a 204 NO CONTENT, return true as success; - // if not, return a WriteasError as failure. + // if not, return a WFError as failure. if response.statusCode != 204 { guard let data = data else { return } - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } else { self.user = nil @@ -1022,12 +1022,12 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the User as success; if not, return a WFError as failure. if response.statusCode == 200 { completion(.success(data)) } else { - // We didn't get a 200 OK, so return a WriteasError. - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError. + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -1061,7 +1061,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WriteasError as failure. + // If we get a 200 OK, return the User as success; if not, return a WFError as failure. if response.statusCode == 200 { do { let collection = try self.decoder.decode(ServerData<[Collection]>.self, from: data) @@ -1070,8 +1070,8 @@ public class WFClient { completion(.failure(error)) } } else { - // We didn't get a 200 OK, so return a WriteasError. - guard let error = self.translateWriteFreelyError(fromServerResponse: data) else { return } + // We didn't get a 200 OK, so return a WFError. + guard let error = self.translateWFError(fromServerResponse: data) else { return } completion(.failure(error)) } } @@ -1082,11 +1082,11 @@ public class WFClient { } private extension WFClient { - func translateWriteFreelyError(fromServerResponse response: Data) -> WriteFreelyError? { + func translateWFError(fromServerResponse response: Data) -> WFError? { do { let error = try self.decoder.decode(ErrorMessage.self, from: response) print("⛔️ \(error.message)") - return WriteFreelyError(rawValue: error.code) + return WFError(rawValue: error.code) } catch { return nil } diff --git a/Sources/WriteFreely/WriteFreelyError.swift b/Sources/WriteFreely/WFError.swift similarity index 93% rename from Sources/WriteFreely/WriteFreelyError.swift rename to Sources/WriteFreely/WFError.swift index 9882110..2fa933c 100644 --- a/Sources/WriteFreely/WriteFreelyError.swift +++ b/Sources/WriteFreely/WFError.swift @@ -1,6 +1,6 @@ import Foundation -enum WriteFreelyError: Int, Error { +enum WFError: Int, Error { case badRequest = 400 case unauthorized = 401 case forbidden = 403 From f30c0fbda5b6d5d577a7ff875a9580d096f7b51f Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Mon, 17 Aug 2020 10:30:09 -0400 Subject: [PATCH 3/6] Rename User to WFUser --- Sources/WriteFreely/WFClient.swift | 28 +++++++++---------- .../WriteFreely/{User.swift => WFUser.swift} | 8 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) rename Sources/WriteFreely/{User.swift => WFUser.swift} (85%) diff --git a/Sources/WriteFreely/WFClient.swift b/Sources/WriteFreely/WFClient.swift index d0b64b2..c5db4a4 100644 --- a/Sources/WriteFreely/WFClient.swift +++ b/Sources/WriteFreely/WFClient.swift @@ -39,7 +39,7 @@ public class WFClient { let decoder = JSONDecoder() public var requestURL: URL - public var user: User? + public var user: WFUser? /// Initializes the WriteFreely client. /// @@ -159,7 +159,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { do { let collection = try self.decoder.decode(ServerData.self, from: data) @@ -291,7 +291,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { do { // The response is formatted differently depending on if we're getting user posts or collection @@ -452,7 +452,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { completion(.success(true)) } else { @@ -513,7 +513,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { completion(.success(true)) } else { @@ -642,7 +642,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { do { let post = try self.decoder.decode(ServerData.self, from: data) @@ -699,7 +699,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { do { let post = try self.decoder.decode(ServerData.self, from: data) @@ -877,7 +877,7 @@ public class WFClient { /// Logs the user in to their account on the WriteFreely instance. /// - /// On successful login, the `WFClient`'s `user` property is set to the returned `User` object; this allows + /// On successful login, the `WFClient`'s `user` property is set to the returned `WFUser` object; this allows /// authenticated requests to be made without having to provide an access token. /// /// It is otherwise not necessary to login the user if their access token is provided to the calling function. @@ -885,8 +885,8 @@ public class WFClient { /// - Parameters: /// - username: The user's username. /// - password: The user's password. - /// - completion: A handler for the `User` object returned on success, or `Error` on failure. - public func login(username: String, password: String, completion: @escaping (Result) -> Void) { + /// - completion: A handler for the `WFUser` object returned on success, or `Error` on failure. + public func login(username: String, password: String, completion: @escaping (Result) -> Void) { guard let url = URL(string: "auth/login", relativeTo: requestURL) else { return } var request = URLRequest(url: url) @@ -913,10 +913,10 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { do { - let user = try self.decoder.decode(User.self, from: data) + let user = try self.decoder.decode(WFUser.self, from: data) self.user = user completion(.success(user)) } catch { @@ -1022,7 +1022,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { completion(.success(data)) } else { @@ -1061,7 +1061,7 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the User as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { do { let collection = try self.decoder.decode(ServerData<[Collection]>.self, from: data) diff --git a/Sources/WriteFreely/User.swift b/Sources/WriteFreely/WFUser.swift similarity index 85% rename from Sources/WriteFreely/User.swift rename to Sources/WriteFreely/WFUser.swift index 574af51..51476d6 100644 --- a/Sources/WriteFreely/User.swift +++ b/Sources/WriteFreely/WFUser.swift @@ -1,13 +1,13 @@ import Foundation -public struct User { +public struct WFUser { public var token: String public var username: String? public var email: String? public var createdDate: Date? } -extension User: Decodable { +extension WFUser: Decodable { enum RootKeys: String, CodingKey { case data } @@ -23,9 +23,9 @@ extension User: Decodable { case createdDate = "created" } - /// Creates a `User` object from the server response. + /// Creates a `WFUser` object from the server response. /// - /// Primarily used by the `WriteFreelyClient` to create a `User` object from the JSON returned by the server. + /// Primarily used by the `WFClient` to create a `WFUser` object from the JSON returned by the server. /// /// - Parameter 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. From 2a4ec91a94d587045f96f1a121bbff148156c857 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Mon, 17 Aug 2020 10:35:14 -0400 Subject: [PATCH 4/6] Rename Post to WFPost --- Sources/WriteFreely/WFClient.swift | 52 +++++++++---------- .../WriteFreely/{Post.swift => WFPost.swift} | 12 ++--- 2 files changed, 32 insertions(+), 32 deletions(-) rename Sources/WriteFreely/{Post.swift => WFPost.swift} (90%) diff --git a/Sources/WriteFreely/WFClient.swift b/Sources/WriteFreely/WFClient.swift index c5db4a4..10645e8 100644 --- a/Sources/WriteFreely/WFClient.swift +++ b/Sources/WriteFreely/WFClient.swift @@ -29,10 +29,10 @@ struct NestedPostsJson: Decodable { init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let postsContainer = try container.nestedContainer(keyedBy: CodingKeys.PostKeys.self, forKey: .data) - data = try postsContainer.decode([Post].self, forKey: .posts) + data = try postsContainer.decode([WFPost].self, forKey: .posts) } - let data: [Post] + let data: [WFPost] } public class WFClient { @@ -259,11 +259,11 @@ public class WFClient { /// - Parameters: /// - token: The access token for the user retrieving the posts. /// - collectionAlias: The alias for the collection whose posts are to be retrieved. - /// - completion: A handler for the returned `[Post]` on success, or `Error` on failure. + /// - completion: A handler for the returned `[WFPost]` on success, or `Error` on failure. public func getPosts( token: String? = nil, in collectionAlias: String? = nil, - completion: @escaping (Result<[Post], Error>) -> Void + completion: @escaping (Result<[WFPost], Error>) -> Void ) { if token == nil && user == nil { return } @@ -301,7 +301,7 @@ public class WFClient { let post = try self.decoder.decode(NestedPostsJson.self, from: data) completion(.success(post.data)) } else { - let post = try self.decoder.decode(ServerData<[Post]>.self, from: data) + let post = try self.decoder.decode(ServerData<[WFPost]>.self, from: data) completion(.success(post.data)) } } catch { @@ -321,7 +321,7 @@ public class WFClient { /// Moves a post to a collection. /// /// - Attention: ⚠️ **INCOMPLETE IMPLEMENTATION** ⚠️ - /// - The closure should return a result type of `<[Post], Error>`. + /// - The closure should return a result type of `<[WFPost], Error>`. /// - The modifyToken for the post is currently ignored. /// /// - Parameters: @@ -534,14 +534,14 @@ public class WFClient { /// /// - Parameters: /// - token: The access token of the user creating the post. - /// - post: The `Post` object to be published. + /// - post: The `WFPost` object to be published. /// - collectionAlias: The collection to which the post should be published. - /// - completion: A handler for the `Post` object returned on success, or `Error` on failure. + /// - completion: A handler for the `WFPost` object returned on success, or `Error` on failure. public func createPost( token: String? = nil, - post: Post, + post: WFPost, in collectionAlias: String? = nil, - completion: @escaping (Result) -> Void + completion: @escaping (Result) -> Void ) { if token == nil && user == nil { return } guard let tokenToVerify = token ?? user?.token else { return } @@ -591,10 +591,10 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the Post as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFPost as success; if not, return a WFError as failure. if response.statusCode == 201 { do { - let post = try self.decoder.decode(ServerData.self, from: data) + let post = try self.decoder.decode(ServerData.self, from: data) completion(.success(post.data)) } catch { @@ -613,16 +613,16 @@ public class WFClient { /// Retrieves a post. /// - /// The `Post` object returned may include additional data, including page views and extracted tags. + /// The `WFPost` object returned may include additional data, including page views and extracted tags. /// /// - Parameters: /// - token: The access token of the user retrieving the post. /// - postId: The ID of the post to be retrieved. - /// - completion: A handler for the `Post` object returned on success, or `Error` on failure. + /// - completion: A handler for the `WFPost` object returned on success, or `Error` on failure. public func getPost( token: String? = nil, byId postId: String, - completion: @escaping (Result) -> Void + completion: @escaping (Result) -> Void ) { if token == nil && user == nil { return } guard let tokenToVerify = token ?? user?.token else { return } @@ -645,7 +645,7 @@ public class WFClient { // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { do { - let post = try self.decoder.decode(ServerData.self, from: data) + let post = try self.decoder.decode(ServerData.self, from: data) completion(.success(post.data)) } catch { @@ -667,18 +667,18 @@ public class WFClient { /// Collection posts can be retrieved without authentication. However, authentication is required for retrieving a /// post from a private collection. /// - /// The `Post` object returned may include additional data, including page views and extracted tags. + /// The `WFPost` object returned may include additional data, including page views and extracted tags. /// /// - Parameters: /// - token: The access token of the user retrieving the post. /// - slug: The slug of the post to be retrieved. /// - collectionAlias: The alias of the collection from which the post should be retrieved. - /// - completion: A handler for the `Post` object returned on success, or `Error` on failure. + /// - completion: A handler for the `WFPost` object returned on success, or `Error` on failure. public func getPost( token: String? = nil, bySlug slug: String, from collectionAlias: String, - completion: @escaping (Result) -> Void + completion: @escaping (Result) -> Void ) { if token == nil && user == nil { return } guard let tokenToVerify = token ?? user?.token else { return } @@ -702,7 +702,7 @@ public class WFClient { // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { do { - let post = try self.decoder.decode(ServerData.self, from: data) + let post = try self.decoder.decode(ServerData.self, from: data) completion(.success(post.data)) } catch { @@ -729,15 +729,15 @@ public class WFClient { /// - Parameters: /// - token: The access token for the user updating the post. /// - postId: The ID of the post to be updated. - /// - updatedPost: The `Post` object with which to update the existing post. + /// - updatedPost: The `WFPost` object with which to update the existing post. /// - modifyToken: The post's modify token; required if the post doesn't belong to the requesting user. - /// - completion: A handler for the `Post` object returned on success, or `Error` on failure. + /// - completion: A handler for the `WFPost` object returned on success, or `Error` on failure. public func updatePost( token: String? = nil, postId: String, - updatedPost: Post, + updatedPost: WFPost, with modifyToken: String? = nil, - completion: @escaping (Result) -> Void + completion: @escaping (Result) -> Void ) { if token == nil && user == nil { return } guard let tokenToVerify = token ?? user?.token else { return } @@ -772,10 +772,10 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 200 OK, return the Post as success; if not, return a WFError as failure. + // If we get a 200 OK, return the WFPost as success; if not, return a WFError as failure. if response.statusCode == 200 { do { - let post = try self.decoder.decode(ServerData.self, from: data) + let post = try self.decoder.decode(ServerData.self, from: data) completion(.success(post.data)) } catch { diff --git a/Sources/WriteFreely/Post.swift b/Sources/WriteFreely/WFPost.swift similarity index 90% rename from Sources/WriteFreely/Post.swift rename to Sources/WriteFreely/WFPost.swift index fb3bbc2..32344d3 100644 --- a/Sources/WriteFreely/Post.swift +++ b/Sources/WriteFreely/WFPost.swift @@ -1,6 +1,6 @@ import Foundation -public struct Post { +public struct WFPost { public var postId: String? public var slug: String? public var appearance: String? @@ -15,7 +15,7 @@ public struct Post { public var collectionAlias: String? } -extension Post: Decodable { +extension WFPost: Decodable { enum CodingKeys: String, CodingKey { case postId = "id" case slug @@ -35,9 +35,9 @@ extension Post: Decodable { } } - /// Creates a basic `Post` object. + /// Creates a basic `WFPost` object. /// - /// This initializer creates a bare-minimum `Post` object for sending to the server; use the decoder-based + /// 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 @@ -76,9 +76,9 @@ extension Post: Decodable { self.collectionAlias = nil } - /// Creates a `Post` object from the server response. + /// Creates a `WFPost` object from the server response. /// - /// Primarily used by the `WriteFreelyClient` to create a `Post` object from the JSON returned by the server. + /// Primarily used by the `WFClient` to create a `WFPost` object from the JSON returned by the server. /// /// - Parameter 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. From 67bf664d49a95f8e4e4561073c58af322552741e Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Mon, 17 Aug 2020 10:39:24 -0400 Subject: [PATCH 5/6] Rename Collection to WFCollection --- Sources/WriteFreely/WFClient.swift | 20 +++++++++---------- .../{Collection.swift => WFCollection.swift} | 12 +++++------ 2 files changed, 16 insertions(+), 16 deletions(-) rename Sources/WriteFreely/{Collection.swift => WFCollection.swift} (83%) diff --git a/Sources/WriteFreely/WFClient.swift b/Sources/WriteFreely/WFClient.swift index 10645e8..ced0ed8 100644 --- a/Sources/WriteFreely/WFClient.swift +++ b/Sources/WriteFreely/WFClient.swift @@ -63,12 +63,12 @@ public class WFClient { /// - token: The access token for the user creating the collection. /// - title: The title of the new collection. /// - alias: The alias of the collection. - /// - completion: A handler for the returned `Collection` on success, or `Error` on failure. + /// - completion: A handler for the returned `WFCollection` on success, or `Error` on failure. public func createCollection( token: String? = nil, withTitle title: String, alias: String? = nil, - completion: @escaping (Result) -> Void + completion: @escaping (Result) -> Void ) { if token == nil && user == nil { return } guard let tokenToVerify = token ?? user?.token else { return } @@ -107,10 +107,10 @@ public class WFClient { if let response = response as? HTTPURLResponse { guard let data = data else { return } - // If we get a 201 CREATED, return the Collection as success; if not, return a WFError as failure. + // If we get a 201 CREATED, return the WFCollection as success; if not, return a WFError as failure. if response.statusCode == 201 { do { - let collection = try self.decoder.decode(ServerData.self, from: data) + let collection = try self.decoder.decode(ServerData.self, from: data) completion(.success(collection.data)) } catch { @@ -135,11 +135,11 @@ public class WFClient { /// - Parameters: /// - token: The access token for the user retrieving the collection. /// - alias: The alias for the collection to be retrieved. - /// - completion: A handler for the returned `Collection` on success, or `Error` on failure. + /// - completion: A handler for the returned `WFCollection` on success, or `Error` on failure. public func getCollection( token: String? = nil, withAlias alias: String, - completion: @escaping (Result) -> Void + completion: @escaping (Result) -> Void ) { if token == nil && user == nil { return } guard let tokenToVerify = token ?? user?.token else { return } @@ -162,7 +162,7 @@ public class WFClient { // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { do { - let collection = try self.decoder.decode(ServerData.self, from: data) + let collection = try self.decoder.decode(ServerData.self, from: data) completion(.success(collection.data)) } catch { @@ -1040,8 +1040,8 @@ public class WFClient { /// /// - Parameters: /// - token: The access token for the user whose collections are to be retrieved. - /// - completion: A handler for the `[Collection]` object returned on success, or `Error` on failure. - public func getUserCollections(token: String? = nil, completion: @escaping (Result<[Collection], Error>) -> Void) { + /// - completion: A handler for the `[WFCollection]` object returned on success, or `Error` on failure. + public func getUserCollections(token: String? = nil, completion: @escaping (Result<[WFCollection], Error>) -> Void) { if token == nil && user == nil { return } guard let tokenToVerify = token ?? user?.token else { return } @@ -1064,7 +1064,7 @@ public class WFClient { // If we get a 200 OK, return the WFUser as success; if not, return a WFError as failure. if response.statusCode == 200 { do { - let collection = try self.decoder.decode(ServerData<[Collection]>.self, from: data) + let collection = try self.decoder.decode(ServerData<[WFCollection]>.self, from: data) completion(.success(collection.data)) } catch { completion(.failure(error)) diff --git a/Sources/WriteFreely/Collection.swift b/Sources/WriteFreely/WFCollection.swift similarity index 83% rename from Sources/WriteFreely/Collection.swift rename to Sources/WriteFreely/WFCollection.swift index 5d6018b..4232f02 100644 --- a/Sources/WriteFreely/Collection.swift +++ b/Sources/WriteFreely/WFCollection.swift @@ -1,6 +1,6 @@ import Foundation -public struct Collection { +public struct WFCollection { public var alias: String? public var title: String public var description: String? @@ -11,7 +11,7 @@ public struct Collection { public var url: String? } -extension Collection: Decodable { +extension WFCollection: Decodable { enum CodingKeys: String, CodingKey { case alias case title @@ -23,9 +23,9 @@ extension Collection: Decodable { case url } - /// Creates a basic `Collection` object. + /// Creates a basic `WFCollection` object. /// - /// This initializer creates a bare-minimum `Collection` object for sending to the server; use the decoder-based + /// This initializer creates a bare-minimum `WFCollection` object for sending to the server; use the decoder-based /// initializer to populate its other properties from the server response. /// /// If no `alias` parameter is provided, one will be generated by the server. @@ -47,9 +47,9 @@ extension Collection: Decodable { self.url = nil } - /// Creates a `Collection` object from the server response. + /// Creates a `WFCollection` object from the server response. /// - /// Primarily used by the `WriteFreelyClient` to create a `Collection` object from the JSON returned by the server. + /// Primarily used by the `WFClient` to create a `WFCollection` object from the JSON returned by the server. /// /// - Parameter 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. From 7badb9d34b8f46aa442622cbf9de4d9215ae051f Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Mon, 17 Aug 2020 10:46:38 -0400 Subject: [PATCH 6/6] Update documentation to use the renamed types --- README.md | 6 +-- docs/Home.md | 8 +-- docs/{WriteFreelyClient.md => WFClient.md} | 60 +++++++++++----------- docs/{Collection.md => WFCollection.md} | 12 ++--- docs/{Post.md => WFPost.md} | 12 ++--- docs/{User.md => WFUser.md} | 8 +-- docs/_Footer.md | 2 +- docs/_Sidebar.md | 8 +-- 8 files changed, 58 insertions(+), 58 deletions(-) rename docs/{WriteFreelyClient.md => WFClient.md} (80%) rename docs/{Collection.md => WFCollection.md} (75%) rename docs/{Post.md => WFPost.md} (84%) rename docs/{User.md => WFUser.md} (75%) diff --git a/README.md b/README.md index cf396f9..62030b2 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,10 @@ Once you've done that, just import the library into whichever files should consu // The rest of the Swift file goes here ``` -Use public methods on the `WriteFreelyClient` to send and receive data from the server. The methods leverage completion blocks and the `Result` type, so you'd call them like so: +Use public methods on the `WFClient` to send and receive data from the server. The methods leverage completion blocks and the `Result` type, so you'd call them like so: ```swift -func loginHandler(result: (Result)) { +func loginHandler(result: (Result)) { do { let user = try result.get() print("Hello, \(user.username)!") @@ -53,7 +53,7 @@ func loginHandler(result: (Result)) { guard let instanceURL = URL(string: "https://your.writefreely.host/") else { fatalError() } -let client = WriteFreelyClient(for: instanceURL) +let client = WFClient(for: instanceURL) client.login(username: "username", password: "password", completion: loginHandler) ``` diff --git a/docs/Home.md b/docs/Home.md index 70f15ca..0cf8b65 100755 --- a/docs/Home.md +++ b/docs/Home.md @@ -1,6 +1,6 @@ # Types - - [Collection](/Collection) - - [Post](/Post) - - [User](/User) - - [WriteFreelyClient](/WriteFreelyClient) + - [WFClient](/WFClient) + - [WFCollection](/WFCollection) + - [WFPost](/WFPost) + - [WFUser](/WFUser) diff --git a/docs/WriteFreelyClient.md b/docs/WFClient.md similarity index 80% rename from docs/WriteFreelyClient.md rename to docs/WFClient.md index 6a38b3c..9c7a2ce 100755 --- a/docs/WriteFreelyClient.md +++ b/docs/WFClient.md @@ -1,14 +1,14 @@ -# WriteFreelyClient +# WFClient ``` swift -public class WriteFreelyClient +public class WFClient ``` ## Initializers ### `init(for:)` -Initializes the WriteFreelyClient. +Initializes the WriteFreely client. ``` swift public init(for instanceURL: URL) @@ -37,7 +37,7 @@ var requestURL: URL ### `user` ``` swift -var user: User? +var user: WFUser? ``` ## Methods @@ -47,7 +47,7 @@ var user: User? Creates a new collection. ``` swift -public func createCollection(token: String? = nil, withTitle title: String, alias: String? = nil, completion: @escaping (Result) -> Void) +public func createCollection(token: String? = nil, withTitle title: String, alias: String? = nil, completion: @escaping (Result) -> Void) ``` If only a `title` is given, the server will generate and return an alias; in this case, clients should store @@ -58,14 +58,14 @@ the returned `alias` for future operations. - token: - token: The access token for the user creating the collection. - title: - title: The title of the new collection. - alias: - alias: The alias of the collection. - - completion: - completion: A handler for the returned `Collection` on success, or `Error` on failure. + - completion: - completion: A handler for the returned `WFCollection` on success, or `Error` on failure. ### `getCollection(token:withAlias:completion:)` Retrieves a collection's metadata. ``` swift -public func getCollection(token: String? = nil, withAlias alias: String, completion: @escaping (Result) -> Void) +public func getCollection(token: String? = nil, withAlias alias: String, completion: @escaping (Result) -> Void) ``` Collections can be retrieved without authentication. However, authentication is required for retrieving a @@ -75,7 +75,7 @@ private collection or one with scheduled posts. - token: - token: The access token for the user retrieving the collection. - alias: - alias: The alias for the collection to be retrieved. - - completion: - completion: A handler for the returned `Collection` on success, or `Error` on failure. + - completion: - completion: A handler for the returned `WFCollection` on success, or `Error` on failure. ### `deleteCollection(token:withAlias:completion:)` @@ -98,7 +98,7 @@ Any posts in the collection are not deleted; rather, they are made anonymous. Retrieves an array of posts. ``` swift -public func getPosts(token: String? = nil, in collectionAlias: String? = nil, completion: @escaping (Result<[Post], Error>) -> Void) +public func getPosts(token: String? = nil, in collectionAlias: String? = nil, completion: @escaping (Result<[WFPost], Error>) -> Void) ``` If the `collectionAlias` argument is provided, an array of all posts in that collection is retrieved; if @@ -111,7 +111,7 @@ private collection or one with scheduled posts. - token: - token: The access token for the user retrieving the posts. - collectionAlias: - collectionAlias: The alias for the collection whose posts are to be retrieved. - - completion: - completion: A handler for the returned `[Post]` on success, or `Error` on failure. + - completion: - completion: A handler for the returned `[WFPost]` on success, or `Error` on failure. ### `movePost(token:postId:with:to:completion:)` @@ -121,7 +121,7 @@ Moves a post to a collection. public func movePost(token: String? = nil, postId: String, with modifyToken: String? = nil, to collectionAlias: String, completion: @escaping (Result) -> Void) ``` -> Attention: - The closure should return a result type of \`\<\[Post\], Error\>\`. +> Attention: - The closure should return a result type of \`\<\[WFPost\], Error\>\`. > - The modifyToken for the post is currently ignored. > @@ -176,7 +176,7 @@ array of posts, this function only accepts a single post. Creates a new post. ``` swift -public func createPost(token: String? = nil, post: Post, in collectionAlias: String? = nil, completion: @escaping (Result) -> Void) +public func createPost(token: String? = nil, post: WFPost, in collectionAlias: String? = nil, completion: @escaping (Result) -> Void) ``` Creates a new post. If a `collectionAlias` is provided, the post is published to that collection; otherwise, it @@ -185,52 +185,52 @@ is posted to the user's Drafts. #### Parameters - token: - token: The access token of the user creating the post. - - post: - post: The `Post` object to be published. + - post: - post: The `WFPost` object to be published. - collectionAlias: - collectionAlias: The collection to which the post should be published. - - completion: - completion: A handler for the `Post` object returned on success, or `Error` on failure. + - completion: - completion: A handler for the `WFPost` object returned on success, or `Error` on failure. ### `getPost(token:byId:completion:)` Retrieves a post. ``` swift -public func getPost(token: String? = nil, byId postId: String, completion: @escaping (Result) -> Void) +public func getPost(token: String? = nil, byId postId: String, completion: @escaping (Result) -> Void) ``` -The `Post` object returned may include additional data, including page views and extracted tags. +The `WFPost` object returned may include additional data, including page views and extracted tags. #### Parameters - token: - token: The access token of the user retrieving the post. - postId: - postId: The ID of the post to be retrieved. - - completion: - completion: A handler for the `Post` object returned on success, or `Error` on failure. + - completion: - completion: A handler for the `WFPost` object returned on success, or `Error` on failure. ### `getPost(token:bySlug:from:completion:)` Retrieves a post from a collection. ``` swift -public func getPost(token: String? = nil, bySlug slug: String, from collectionAlias: String, completion: @escaping (Result) -> Void) +public func getPost(token: String? = nil, bySlug slug: String, from collectionAlias: String, completion: @escaping (Result) -> Void) ``` Collection posts can be retrieved without authentication. However, authentication is required for retrieving a post from a private collection. -The `Post` object returned may include additional data, including page views and extracted tags. +The `WFPost` object returned may include additional data, including page views and extracted tags. #### Parameters - token: - token: The access token of the user retrieving the post. - slug: - slug: The slug of the post to be retrieved. - collectionAlias: - collectionAlias: The alias of the collection from which the post should be retrieved. - - completion: - completion: A handler for the `Post` object returned on success, or `Error` on failure. + - completion: - completion: A handler for the `WFPost` object returned on success, or `Error` on failure. ### `updatePost(token:postId:updatedPost:with:completion:)` Updates an existing post. ``` swift -public func updatePost(token: String? = nil, postId: String, updatedPost: Post, with modifyToken: String? = nil, completion: @escaping (Result) -> Void) +public func updatePost(token: String? = nil, postId: String, updatedPost: WFPost, with modifyToken: String? = nil, completion: @escaping (Result) -> Void) ``` Note that if the `updatedPost` object is provided without a title, the original post's title will be removed. @@ -242,9 +242,9 @@ Note that if the `updatedPost` object is provided without a title, the original - token: - token: The access token for the user updating the post. - postId: - postId: The ID of the post to be updated. - - updatedPost: - updatedPost: The `Post` object with which to update the existing post. + - updatedPost: - updatedPost: The `WFPost` object with which to update the existing post. - modifyToken: - modifyToken: The post's modify token; required if the post doesn't belong to the requesting user. - - completion: - completion: A handler for the `Post` object returned on success, or `Error` on failure. + - completion: - completion: A handler for the `WFPost` object returned on success, or `Error` on failure. ### `deletePost(token:postId:with:completion:)` @@ -269,10 +269,10 @@ public func deletePost(token: String? = nil, postId: String, with modifyToken: S Logs the user in to their account on the WriteFreely instance. ``` swift -public func login(username: String, password: String, completion: @escaping (Result) -> Void) +public func login(username: String, password: String, completion: @escaping (Result) -> Void) ``` -On successful login, the `WriteFreelyClient`'s `user` property is set to the returned `User` object; this allows +On successful login, the `WFClient`'s `user` property is set to the returned `WFUser` object; this allows authenticated requests to be made without having to provide an access token. It is otherwise not necessary to login the user if their access token is provided to the calling function. @@ -281,7 +281,7 @@ It is otherwise not necessary to login the user if their access token is provide - username: - username: The user's username. - password: - password: The user's password. - - completion: - completion: A handler for the `User` object returned on success, or `Error` on failure. + - completion: - completion: A handler for the `WFUser` object returned on success, or `Error` on failure. ### `logout(token:completion:)` @@ -314,16 +314,16 @@ public func getUserData(token: String? = nil, completion: @escaping (Result) -> Void) +public func getUserCollections(token: String? = nil, completion: @escaping (Result<[WFCollection], Error>) -> Void) ``` #### Parameters - token: - token: The access token for the user whose collections are to be retrieved. - - completion: - completion: A handler for the `[Collection]` object returned on success, or `Error` on failure. + - completion: - completion: A handler for the `[WFCollection]` object returned on success, or `Error` on failure. -### `translateWriteFreelyError(fromServerResponse:)` +### `translateWFError(fromServerResponse:)` ``` swift -func translateWriteFreelyError(fromServerResponse response: Data) -> WriteFreelyError? +func translateWFError(fromServerResponse response: Data) -> WFError? ``` diff --git a/docs/Collection.md b/docs/WFCollection.md similarity index 75% rename from docs/Collection.md rename to docs/WFCollection.md index 071c6c0..6f9879e 100755 --- a/docs/Collection.md +++ b/docs/WFCollection.md @@ -1,7 +1,7 @@ -# Collection +# WFCollection ``` swift -public struct Collection +public struct WFCollection ``` ## Inheritance @@ -12,13 +12,13 @@ public struct Collection ### `init(title:alias:)` -Creates a basic `Collection` object. +Creates a basic `WFCollection` object. ``` swift public init(title: String, alias: String?) ``` -This initializer creates a bare-minimum `Collection` object for sending to the server; use the decoder-based +This initializer creates a bare-minimum `WFCollection` object for sending to the server; use the decoder-based initializer to populate its other properties from the server response. If no `alias` parameter is provided, one will be generated by the server. @@ -30,13 +30,13 @@ If no `alias` parameter is provided, one will be generated by the server. ### `init(from:)` -Creates a `Collection` object from the server response. +Creates a `WFCollection` object from the server response. ``` swift public init(from decoder: Decoder) throws ``` -Primarily used by the `WriteFreelyClient` to create a `Collection` object from the JSON returned by the server. +Primarily used by the `WFClient` to create a `WFCollection` object from the JSON returned by the server. #### Parameters diff --git a/docs/Post.md b/docs/WFPost.md similarity index 84% rename from docs/Post.md rename to docs/WFPost.md index d8088c5..864eb06 100755 --- a/docs/Post.md +++ b/docs/WFPost.md @@ -1,7 +1,7 @@ -# Post +# WFPost ``` swift -public struct Post +public struct WFPost ``` ## Inheritance @@ -12,13 +12,13 @@ public struct Post ### `init(body:title:appearance:language:rtl:createdDate:)` -Creates a basic `Post` object. +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 `Post` object for sending to the server; use the decoder-based +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 @@ -35,13 +35,13 @@ the server. ### `init(from:)` -Creates a `Post` object from the server response. +Creates a `WFPost` object from the server response. ``` swift public init(from decoder: Decoder) throws ``` -Primarily used by the `WriteFreelyClient` to create a `Post` object from the JSON returned by the server. +Primarily used by the `WFClient` to create a `WFPost` object from the JSON returned by the server. #### Parameters diff --git a/docs/User.md b/docs/WFUser.md similarity index 75% rename from docs/User.md rename to docs/WFUser.md index fbad98b..a2821d1 100755 --- a/docs/User.md +++ b/docs/WFUser.md @@ -1,7 +1,7 @@ -# User +# WFUser ``` swift -public struct User +public struct WFUser ``` ## Inheritance @@ -12,13 +12,13 @@ public struct User ### `init(from:)` -Creates a `User` object from the server response. +Creates a `WFUser` object from the server response. ``` swift public init(from decoder: Decoder) throws ``` -Primarily used by the `WriteFreelyClient` to create a `User` object from the JSON returned by the server. +Primarily used by the `WFClient` to create a `WFUser` object from the JSON returned by the server. #### Parameters diff --git a/docs/_Footer.md b/docs/_Footer.md index 63bc613..98baa8f 100755 --- a/docs/_Footer.md +++ b/docs/_Footer.md @@ -1 +1 @@ -Generated at 2020-07-01T10:43:01-0400 using [swift-doc](https://github.com/SwiftDocOrg/swift-doc) 1.0.0-beta.3. +Generated at 2020-08-17T10:42:50-0400 using [swift-doc](https://github.com/SwiftDocOrg/swift-doc) 1.0.0-beta.3. diff --git a/docs/_Sidebar.md b/docs/_Sidebar.md index 479cc96..fea5f86 100755 --- a/docs/_Sidebar.md +++ b/docs/_Sidebar.md @@ -1,9 +1,9 @@
Types - - [Collection](/Collection) - - [Post](/Post) - - [User](/User) - - [WriteFreelyClient](/WriteFreelyClient) + - [WFClient](/WFClient) + - [WFCollection](/WFCollection) + - [WFPost](/WFPost) + - [WFUser](/WFUser)