Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented WMTTemplates #162

Open
wants to merge 32 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
21375c4
Implement `WMTTemplates`
Hopsaheysa Jun 27, 2024
17b190c
Extend ListTemplate types to accommodate more information than just A…
Hopsaheysa Jun 27, 2024
68d843d
Merge branch 'develop' into issues/161-templates
Hopsaheysa Jun 27, 2024
8f154c7
Change internal classes properties access
Hopsaheysa Jul 4, 2024
2b7059a
Add formated templates - same as Id but to be distinguieshed that it …
Hopsaheysa Jul 9, 2024
227449f
DRAFT: hardcoded data for testing
Hopsaheysa Jul 9, 2024
7fc395f
Merge branch 'develop' into issues/161-templates
Hopsaheysa Jul 9, 2024
0302bb0
Revert "Merge branch 'develop' into issues/161-templates"
Hopsaheysa Jul 9, 2024
37e38d3
Fix tests and swiftlint
Hopsaheysa Jul 9, 2024
3975843
Update tamplate image to be AttributeId, rename automatic
Hopsaheysa Jul 9, 2024
e36dc05
Merge branch 'develop' into issues/161-templates
Hopsaheysa Jul 15, 2024
311c7dc
Introduce Templates parser
Hopsaheysa Jul 15, 2024
345786d
Inverse showTitleAndMessage check to have true as a default
Hopsaheysa Jul 15, 2024
6ccd45a
Remove lint warnings and errors
Hopsaheysa Jul 15, 2024
e348511
Change accessing attributes
Hopsaheysa Jul 17, 2024
80749e9
Improve Visual parser
Hopsaheysa Jul 18, 2024
588d4f3
Fix tests
Hopsaheysa Jul 18, 2024
662a919
Minor refactoring of pop functions
Hopsaheysa Jul 18, 2024
2c073ab
Divide code to separate files
Hopsaheysa Jul 18, 2024
84658a0
Fixed podspec
kober32 Jul 18, 2024
a62bba4
Fix issues after incorrect merge
Hopsaheysa Jul 18, 2024
7a227fa
Remove image downloader, rename parsers, add docs
Hopsaheysa Jul 23, 2024
abf9b32
Add logging when decoding of optionals throws
Hopsaheysa Jul 26, 2024
a5d8c4a
Add centered Cell property
Hopsaheysa Jul 26, 2024
4bee9c3
Fix `WPNLogger.verboseLevel` after incorrect merge
Hopsaheysa Jul 29, 2024
033148e
Remove generated .swiftpm contents file
Hopsaheysa Jul 31, 2024
bab7f75
Simplify decoding with decodeIfPresent & improve decoding of the Sect…
Hopsaheysa Jul 31, 2024
12900c0
Implement remarks
Hopsaheysa Jul 31, 2024
b2327e2
Update docs
Hopsaheysa Aug 1, 2024
46f639c
Add style for the whole detail in visual parser
Hopsaheysa Aug 5, 2024
593ba89
Add visual parser to docs
Hopsaheysa Aug 14, 2024
0e88fef
Remove hardcoded template which was used for development
Hopsaheysa Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions WultraMobileTokenSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
EA6DDF1C29F807230011E234 /* OperationUIDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA6DDF1B29F807230011E234 /* OperationUIDataTests.swift */; };
EA74F7B32C2561BB004340B9 /* WMTResultTexts.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA74F7B22C2561BB004340B9 /* WMTResultTexts.swift */; };
EA7A6E582B0E639800C1D4F4 /* WMTOperationDetailRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7A6E572B0E639800C1D4F4 /* WMTOperationDetailRequest.swift */; };
EA7EA22D2C494478000ECA41 /* WMTTemplateVisualParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA951B4F2C412E43006C76B5 /* WMTTemplateVisualParser.swift */; };
EA7EA22E2C49447B000ECA41 /* WMTTemplateListVisual.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA392BB62C4941CE00B6ADB7 /* WMTTemplateListVisual.swift */; };
EA7EA2302C494546000ECA41 /* WMTTemplateDetailVisual.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7EA22F2C494546000ECA41 /* WMTTemplateDetailVisual.swift */; };
EA9795132C2C18450073E861 /* WMTTemplates.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA9795122C2C18450073E861 /* WMTTemplates.swift */; };
EA9CE2BE2AEAA9FD00FE4E35 /* WMTProximityCheck.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA9CE2BD2AEAA9FD00FE4E35 /* WMTProximityCheck.swift */; };
EA9CE2C22AEBDB0D00FE4E35 /* WMTPACUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA9CE2C12AEBDB0D00FE4E35 /* WMTPACUtils.swift */; };
EAB7054A2AF1161500756AC2 /* PACParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB705492AF1161500756AC2 /* PACParserTests.swift */; };
Expand Down Expand Up @@ -153,6 +157,7 @@
DCE660D024CEBECA00870E53 /* IntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntegrationTests.swift; sourceTree = "<group>"; };
DCE660D224CEF56400870E53 /* IntegrationProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntegrationProxy.swift; sourceTree = "<group>"; };
EA294F3C29F6A07A00A0494E /* WMTOperationUIData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTOperationUIData.swift; sourceTree = "<group>"; };
EA392BB62C4941CE00B6ADB7 /* WMTTemplateListVisual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTTemplateListVisual.swift; sourceTree = "<group>"; };
EA44366929F9294600DDEC1C /* WMTPostApprovaScreenReview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTPostApprovaScreenReview.swift; sourceTree = "<group>"; };
EA44366B29F9297100DDEC1C /* WMTPostApprovaScreenRedirect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTPostApprovaScreenRedirect.swift; sourceTree = "<group>"; };
EA44366D29F9298100DDEC1C /* WMTPostApprovaScreenGeneric.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTPostApprovaScreenGeneric.swift; sourceTree = "<group>"; };
Expand All @@ -161,6 +166,9 @@
EA6DDF1B29F807230011E234 /* OperationUIDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationUIDataTests.swift; sourceTree = "<group>"; };
EA74F7B22C2561BB004340B9 /* WMTResultTexts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTResultTexts.swift; sourceTree = "<group>"; };
EA7A6E572B0E639800C1D4F4 /* WMTOperationDetailRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTOperationDetailRequest.swift; sourceTree = "<group>"; };
EA7EA22F2C494546000ECA41 /* WMTTemplateDetailVisual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTTemplateDetailVisual.swift; sourceTree = "<group>"; };
EA951B4F2C412E43006C76B5 /* WMTTemplateVisualParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTTemplateVisualParser.swift; sourceTree = "<group>"; };
EA9795122C2C18450073E861 /* WMTTemplates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WMTTemplates.swift; sourceTree = "<group>"; };
EA9CE2BD2AEAA9FD00FE4E35 /* WMTProximityCheck.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WMTProximityCheck.swift; sourceTree = "<group>"; };
EA9CE2C12AEBDB0D00FE4E35 /* WMTPACUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WMTPACUtils.swift; sourceTree = "<group>"; };
EAB705492AF1161500756AC2 /* PACParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PACParserTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -226,6 +234,7 @@
DC3D0B352480F368000DC4D9 /* UserOperation */ = {
isa = PBXGroup;
children = (
EA951B512C412F84006C76B5 /* TemplateParser */,
EA6DDF0D29F8031F0011E234 /* Screens */,
DC059A3C244DD30900B24878 /* Attributes */,
DCC5CCAD2449F7AC004679AC /* WMTUserOperation.swift */,
Expand All @@ -235,6 +244,7 @@
EA294F3C29F6A07A00A0494E /* WMTOperationUIData.swift */,
EA9CE2BD2AEAA9FD00FE4E35 /* WMTProximityCheck.swift */,
EA74F7B22C2561BB004340B9 /* WMTResultTexts.swift */,
EA9795122C2C18450073E861 /* WMTTemplates.swift */,
);
path = UserOperation;
sourceTree = "<group>";
Expand Down Expand Up @@ -455,6 +465,16 @@
path = Screens;
sourceTree = "<group>";
};
EA951B512C412F84006C76B5 /* TemplateParser */ = {
isa = PBXGroup;
children = (
EA951B4F2C412E43006C76B5 /* WMTTemplateVisualParser.swift */,
EA392BB62C4941CE00B6ADB7 /* WMTTemplateListVisual.swift */,
EA7EA22F2C494546000ECA41 /* WMTTemplateDetailVisual.swift */,
);
path = TemplateParser;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -608,6 +628,7 @@
DC0268DF29965495000BB9FA /* WMTOperationListResponse.swift in Sources */,
DC8CB202244DCBE2009DDAA3 /* WMTOperations.swift in Sources */,
DC48803E292282FF00DB844B /* WMTInboxMessage.swift in Sources */,
EA7EA22E2C49447B000ECA41 /* WMTTemplateListVisual.swift in Sources */,
DCC5CCB52449F8E9004679AC /* WMTOperationAttributeAmount.swift in Sources */,
DCC5CCD6244DBB7F004679AC /* WMTPushRegistrationData.swift in Sources */,
DC3D0B392480F886000DC4D9 /* WMTLocalOperation.swift in Sources */,
Expand All @@ -621,6 +642,8 @@
DC81D1CD244F640600F80CD6 /* WMTPush.swift in Sources */,
DC6E52D6259C964600FC25BE /* WMTOperationExpirationWatcher.swift in Sources */,
DCC5CCDA244DBBE2004679AC /* WMTRejectionData.swift in Sources */,
EA9795132C2C18450073E861 /* WMTTemplates.swift in Sources */,
EA7EA22D2C494478000ECA41 /* WMTTemplateVisualParser.swift in Sources */,
DC48803F292282FF00DB844B /* WMTInboxMessageDetail.swift in Sources */,
EA6DDF0F29F8036B0011E234 /* WMTPreApprovalScreen.swift in Sources */,
DCAB7BC824580B4C0006989D /* WMTQROperationParser.swift in Sources */,
Expand Down Expand Up @@ -649,6 +672,7 @@
DCE5EAB026BD81150061861A /* WMTOperationHistoryEntry.swift in Sources */,
EACAF7B02A126B7D0021CA54 /* WMTJsonValue.swift in Sources */,
DCAB7BCA24580BAC0006989D /* WMTQROperation.swift in Sources */,
EA7EA2302C494546000ECA41 /* WMTTemplateDetailVisual.swift in Sources */,
DCC5CCBF2449F981004679AC /* WMTOperationAttributePartyInfo.swift in Sources */,
DC81D1CB244F451E00F80CD6 /* WMTPushImpl.swift in Sources */,
EA9CE2BE2AEAA9FD00FE4E35 /* WMTProximityCheck.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ public class WMTOperationListResponse<T: WMTUserOperation>: WPNResponseArray<T>
public required init(from decoder: Decoder) throws {

let c = try decoder.container(keyedBy: Keys.self)
currentTimestamp = try? c.decode(Date.self, forKey: Keys.currentTimestamp)

do {
currentTimestamp = try c.decodeIfPresent(Date.self, forKey: .currentTimestamp)
} catch {
D.error("Failed to decode \(Keys.currentTimestamp) - \(error), setting to null")
currentTimestamp = nil
}
try super.init(from: decoder)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ public class WMTOperationAttributeImage: WMTOperationAttribute {
let c = try decoder.container(keyedBy: Keys.self)

self.thumbnailUrl = try c.decode(String.self, forKey: .thumbnailUrl)
self.originalUrl = try? c.decode(String.self, forKey: .originalUrl)

do {
originalUrl = try c.decodeIfPresent(String.self, forKey: .originalUrl)
} catch {
D.error("Failed to decode \(Keys.originalUrl) - \(error), setting to null")
originalUrl = nil
}

try super.init(from: decoder)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,25 @@ public class WMTReviewPostApprovalScreenPayload: WMTPostApprovalScreenPayload {
// MARK: Internals

public required init(from decoder: Decoder) throws {

let c = try decoder.container(keyedBy: Keys.self)
attributes = (try? c.decode([WMTOperationAttributeDecodable].self, forKey: .attributes).map {
$0.attrObject }) ?? []

var operationAttributes: [WMTOperationAttribute] = []
do {
var container = try c.nestedUnkeyedContainer(forKey: .attributes)
// If decoding fails log it and continue decoding until the end of container
while container.isAtEnd == false {
do {
let attribute = try WMTOperationAttributeDecodable(from: container.superDecoder())
operationAttributes.append(attribute.attrObject)
} catch {
D.error("Error decoding WMTOperationFormData attribute: \(error)")
}
}
} catch {
D.error("No attributes in WMTOperationFormData: \(error)")
}
attributes = operationAttributes

super.init()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,20 @@ public class WMTPreApprovalScreen: Codable {
type = ScreenType(rawValue: t) ?? .unknown
heading = try c.decode(String.self, forKey: .heading)
message = try c.decode(String.self, forKey: .message)
items = try? c.decode([String].self, forKey: .items)
approvalType = try? c.decode(WMTPreApprovalScreenConfirmAction.self, forKey: .approvalType)

do {
items = try c.decodeIfPresent([String].self, forKey: .items)
} catch {
D.error("Failed to decode \(Keys.items) - \(error), setting to null")
items = nil
}

do {
approvalType = try c.decodeIfPresent(WMTPreApprovalScreenConfirmAction.self, forKey: .approvalType)
} catch {
D.error("Failed to decode \(Keys.approvalType) - \(error), setting to null")
approvalType = nil
}
}

public init(type: ScreenType, heading: String, message: String, items: [String]? = nil, approvalType: WMTPreApprovalScreenConfirmAction?) {
Expand Down
Loading
Loading