-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47c049c
commit 96a60f0
Showing
8 changed files
with
329 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
Sources/code/application/Models/Cart/OrderTagCartAppModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
|
||
import Foundation | ||
public extension ApplicationClient.Cart { | ||
/* | ||
Model: OrderTag | ||
Used By: Cart | ||
*/ | ||
class OrderTag: Codable { | ||
|
||
public var displayText: String? | ||
|
||
public var slug: String? | ||
|
||
|
||
public enum CodingKeys: String, CodingKey { | ||
|
||
case displayText = "display_text" | ||
|
||
case slug = "slug" | ||
|
||
} | ||
|
||
public init(displayText: String? = nil, slug: String? = nil) { | ||
|
||
self.displayText = displayText | ||
|
||
self.slug = slug | ||
|
||
} | ||
|
||
required public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
|
||
|
||
do { | ||
displayText = try container.decode(String.self, forKey: .displayText) | ||
|
||
} catch DecodingError.typeMismatch(let type, let context) { | ||
print("Type '\(type)' mismatch:", context.debugDescription) | ||
print("codingPath:", context.codingPath) | ||
} catch { | ||
|
||
} | ||
|
||
|
||
|
||
do { | ||
slug = try container.decode(String.self, forKey: .slug) | ||
|
||
} catch DecodingError.typeMismatch(let type, let context) { | ||
print("Type '\(type)' mismatch:", context.debugDescription) | ||
print("codingPath:", context.codingPath) | ||
} catch { | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
|
||
|
||
try? container.encodeIfPresent(displayText, forKey: .displayText) | ||
|
||
|
||
|
||
try? container.encodeIfPresent(slug, forKey: .slug) | ||
|
||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.