Skip to content

Commit

Permalink
Post object can now handle different types for original post identifi…
Browse files Browse the repository at this point in the history
…er (#54)
  • Loading branch information
hamiltonalex authored and michaeleustace committed Dec 19, 2018
1 parent 567cc71 commit 3342a6d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions DigiMeSDK/Repository/Classes/Objects/Social/Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,25 @@ public class Post: NSObject, BaseObjectDecodable {
public let likeCount: Int
public let links: [Link]?
public let longitude: Double
public let originalPostIdentifier: String?
public var originalPostIdentifier: String? {
guard let originalPostId = originalPostIdentifierRaw else {
return nil
}

return String(describing: originalPostId)
}
public let originalPostUrl: String
public let personIdentifier: String
public let personFileUrl: String
public let personFullname: String
public let personUsername: String
public let postIdentifier: String
public var postReplyCount: String? {
return String(describing: postReplyCountRaw)
guard let replyCount = postReplyCountRaw else {
return nil
}

return String(describing: replyCount)
}

public let postUrl: String
Expand All @@ -88,7 +98,11 @@ public class Post: NSObject, BaseObjectDecodable {
public let postEntityIdentifier: String?
public let personFileRelativePath: String?
public var originalCrossPostIdentifier: String? {
return String(describing: originalCrossPostIdentifierRaw)
guard let originalCrossPostId = originalCrossPostIdentifierRaw else {
return nil
}

return String(describing: originalCrossPostId)
}

// MARK: - Objective-C Representations of non-optional primitives
Expand All @@ -109,6 +123,7 @@ public class Post: NSObject, BaseObjectDecodable {
private let typeRaw: Int
private let postReplyCountRaw: AnyJSONType?
private let originalCrossPostIdentifierRaw: AnyJSONType?
private let originalPostIdentifierRaw: AnyJSONType?

// MARK: - Decodable
enum CodingKeys: String, CodingKey {
Expand All @@ -129,7 +144,7 @@ public class Post: NSObject, BaseObjectDecodable {
case links = "links"
case longitude = "longitude"
case originalCrossPostIdentifierRaw = "originalcrosspostid"
case originalPostIdentifier = "originalpostid"
case originalPostIdentifierRaw = "originalpostid"
case originalPostUrl = "originalposturl"
case personIdentifier = "personentityid"
case personFileUrl = "personfileurl"
Expand Down

0 comments on commit 3342a6d

Please sign in to comment.