Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2022-07-06 18:55:32 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4b2b4cb67f828abefbec4ac549dfe14e2f9b6c43
4b2b4cb6
1 parent
26382266
refactor setCCMSLoyaltyCampaigns, add mergeGFYCCMSLoyaltyCampaigns, mergeMFYCCMSLoyaltyCampaigns
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
4 deletions
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
4b2b4cb
...
...
@@ -73,11 +73,15 @@ public class swiftApi {
let
ccmsCampaign
:
Array
<
LoyaltyContextualOfferModel
>
=
campaigns
GlobalVariables
.
ccmsCampaigns
=
campaigns
}
public
func
mergeGFYCCMSLoyaltyCampaigns
(
campaigns
:
Array
<
LoyaltyContextualOfferModel
>
)
->
Array
<
CampaignItemModel
>
{
let
ccmsCampaign
:
Array
<
LoyaltyContextualOfferModel
>
=
campaigns
let
mergedGFYCampaigns
=
GlobalVariables
.
campaigns
.
filter
{
let
tempCampaign
=
$0
let
isGFY
=
tempCampaign
.
offer_category
==
"gifts_for_you"
let
hasExtraFields
=
(
tempCampaign
.
hasExtraFields
!=
nil
)
&&
(
tempCampaign
.
hasExtraFields
==
true
)
//
let hasExtraFields = (tempCampaign.hasExtraFields != nil) && (tempCampaign.hasExtraFields == true)
let
isCcmsOffer
=
(
tempCampaign
.
ccms_offer
!=
nil
)
&&
(
tempCampaign
.
ccms_offer
!=
""
)
&&
(
tempCampaign
.
ccms_offer
==
"true"
)
let
loyaltyCampaignIdExists
=
ccmsCampaign
.
contains
{
$0
.
_loyaltyCampaignId
==
tempCampaign
.
session_uuid
}
return
isGFY
&&
(
!
isCcmsOffer
||
(
isCcmsOffer
&&
loyaltyCampaignIdExists
))
...
...
@@ -86,7 +90,7 @@ public class swiftApi {
let
matchedCampaigns
=
GlobalVariables
.
campaigns
.
filter
{
let
tempCampaign
=
$0
let
isGFY
=
tempCampaign
.
offer_category
==
"gifts_for_you"
let
hasExtraFields
=
(
tempCampaign
.
hasExtraFields
!=
nil
)
&&
(
tempCampaign
.
hasExtraFields
==
true
)
//
let hasExtraFields = (tempCampaign.hasExtraFields != nil) && (tempCampaign.hasExtraFields == true)
let
isCcmsOffer
=
(
tempCampaign
.
ccms_offer
!=
nil
)
&&
(
tempCampaign
.
ccms_offer
!=
""
)
&&
(
tempCampaign
.
ccms_offer
==
"true"
)
let
loyaltyCampaignIdExists
=
ccmsCampaign
.
contains
{
$0
.
_loyaltyCampaignId
==
tempCampaign
.
session_uuid
}
return
isGFY
&&
isCcmsOffer
&&
loyaltyCampaignIdExists
...
...
@@ -98,9 +102,45 @@ public class swiftApi {
print
(
"====================================="
)
GlobalVariables
.
campaigns
=
GlobalVariables
.
campaigns
.
filter
{
$0
.
offer_category
!=
"gifts_for_you"
}
+
mergedGFYCampaigns
let
totalCampaigns
=
GlobalVariables
.
campaigns
.
filter
{
$0
.
offer_category
!=
"gifts_for_you"
}
+
mergedGFYCampaigns
print
(
"TOTAL: Campaigns Sum="
+
String
(
totalCampaigns
.
count
)
+
" campaigns to display"
)
return
mergedGFYCampaigns
}
public
func
mergeMFYCCMSLoyaltyCampaigns
(
campaigns
:
Array
<
LoyaltyContextualOfferModel
>
)
->
Array
<
CampaignItemModel
>
{
let
ccmsCampaign
:
Array
<
LoyaltyContextualOfferModel
>
=
campaigns
let
mergedMFYCampaigns
=
GlobalVariables
.
campaigns
.
filter
{
let
tempCampaign
=
$0
let
isMFY
=
tempCampaign
.
offer_category
==
"more_for_you"
// let hasExtraFields = (tempCampaign.hasExtraFields != nil) && (tempCampaign.hasExtraFields == true)
let
isCcmsOffer
=
(
tempCampaign
.
ccms_offer
!=
nil
)
&&
(
tempCampaign
.
ccms_offer
!=
""
)
&&
(
tempCampaign
.
ccms_offer
==
"true"
)
let
loyaltyCampaignIdExists
=
ccmsCampaign
.
contains
{
$0
.
_loyaltyCampaignId
==
tempCampaign
.
session_uuid
}
return
isMFY
&&
(
!
isCcmsOffer
||
(
isCcmsOffer
&&
loyaltyCampaignIdExists
))
}
let
matchedCampaigns
=
GlobalVariables
.
campaigns
.
filter
{
let
tempCampaign
=
$0
let
isMFY
=
tempCampaign
.
offer_category
==
"more_for_you"
// let hasExtraFields = (tempCampaign.hasExtraFields != nil) && (tempCampaign.hasExtraFields == true)
let
isCcmsOffer
=
(
tempCampaign
.
ccms_offer
!=
nil
)
&&
(
tempCampaign
.
ccms_offer
!=
""
)
&&
(
tempCampaign
.
ccms_offer
==
"true"
)
let
loyaltyCampaignIdExists
=
ccmsCampaign
.
contains
{
$0
.
_loyaltyCampaignId
==
tempCampaign
.
session_uuid
}
return
isMFY
&&
isCcmsOffer
&&
loyaltyCampaignIdExists
}
print
(
"Got L:{"
+
String
(
GlobalVariables
.
campaigns
.
count
)
+
"} LOYALTY campaigns"
)
print
(
"Got C:{"
+
String
(
campaigns
.
count
)
+
"} CCMS campaigns"
)
print
(
"Matched M:{"
+
String
(
matchedCampaigns
.
count
)
+
"} CCMS campaigns"
)
print
(
"====================================="
)
let
totalCampaigns
=
GlobalVariables
.
campaigns
.
filter
{
$0
.
offer_category
!=
"more_for_you"
}
+
mergedMFYCampaigns
print
(
"TOTAL: Campaigns Sum="
+
String
(
totalCampaigns
.
count
)
+
" campaigns to display"
)
print
(
"TOTAL: Campaigns Sum="
+
String
(
GlobalVariables
.
campaigns
.
count
)
+
" campaigns to display"
)
return
mergedMFYCampaigns
}
public
func
getCCMSLoyaltyCampaigns
()
->
Array
<
LoyaltyContextualOfferModel
>
{
...
...
Please
register
or
login
to post a comment