[go: nahoru, domu]

Skip to content

Commit

Permalink
adding public init to models
Browse files Browse the repository at this point in the history
  • Loading branch information
SobhanST96 committed Jun 13, 2022
1 parent b65fcfa commit f145bde
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/EVStories/Models/IGSnap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ public struct IGSnap: Codable {
}
}

public init(id: String,
mediaType: String,
url: String,
isViewed: Bool) {

self.id = id
self.mediaType = mediaType
self.url = url
self.isViewed = url
}

var isDeleted: Bool {
set{
UserDefaults.standard.set(newValue, forKey: id)
Expand Down
4 changes: 4 additions & 0 deletions Sources/EVStories/Models/IGStories.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import Foundation
public struct IGStories: Codable {
public let stories: [IGStory]

public init(stories: [IGStory]) {
self.stories = stories
}

public func copy() throws -> IGStories {
let data = try JSONEncoder().encode(self)
let copy = try JSONDecoder().decode(IGStories.self, from: data)
Expand Down
17 changes: 17 additions & 0 deletions Sources/EVStories/Models/IGStory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ public struct IGStory: Codable {
public var isCompletelyVisible = false
public var isCancelledAbruptly = false

public init(id: String,
expiresAt: String,
createdAt: String,
updatedAt: String,
snaps: [IGSnap],
thumbnailUrl: String,
title: String) {

self.id = id
self.expiresAt = expiresAt
self.createdAt = createdAt
self.updatedAt = updatedAt
self.snaps: = snaps
self.thumbnailUrl = thumbnailUrl
self.title = title
}

enum CodingKeys: String, CodingKey {
case id = "_id"
case expiresAt
Expand Down

0 comments on commit f145bde

Please sign in to comment.