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
2023-07-26 11:59:34 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a480768c5919c7fde8f6ae537247847feaf33c15
a480768c
1 parent
67bc7ebd
fix WalletVC SM discount banner
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
4 deletions
SwiftWarplyFramework/SwiftWarplyFramework/WalletViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/WalletViewController.swift
View file @
a480768
...
...
@@ -117,7 +117,8 @@ import SwiftEventBus
// TODO: DELETE <===
// TODO: Uncomment when UnifiedCoupons will be shown again
getUnifiedCouponsRequest
()
// getUnifiedCouponsRequest()
getCouponsSetsDealsRequest
()
setBackButton
()
setNavigationTitle
(
"My Rewards"
)
...
...
@@ -590,12 +591,26 @@ import SwiftEventBus
func
updateMarketBadge
()
{
unifiedCouponsDiscount
=
0.0
for
coupon
in
swiftApi
()
.
getOldUnifiedCouponList
()
{
if
let
discountFloat
=
Float
(
coupon
.
discount
??
"0.0"
)
{
unifiedCouponsDiscount
+=
discountFloat
for
smCouponSet
in
swiftApi
()
.
getCouponSetsDealsList
()
{
for
oldCoupon
in
swiftApi
()
.
getAllOldCouponList
()
{
if
(
smCouponSet
.
uuid
!=
""
&&
oldCoupon
.
couponset_uuid
!=
""
&&
smCouponSet
.
uuid
==
oldCoupon
.
couponset_uuid
)
{
oldCoupon
.
setCouponSetData
(
smCouponSet
);
if
let
discountFloat
=
Float
(
oldCoupon
.
discount
??
"0.0"
)
{
unifiedCouponsDiscount
+=
discountFloat
}
break
;
}
}
}
// for coupon in swiftApi().getOldUnifiedCouponList() {
// if let discountFloat = Float(coupon.discount ?? "0.0") {
// unifiedCouponsDiscount += discountFloat
// }
// }
// TODO: UNCOMMENT if emptyView is needed again
// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0 && unifiedCouponsDiscount == 0.0) {
// emptyView.isHidden = false
...
...
@@ -607,6 +622,21 @@ import SwiftEventBus
}
// MARK: - API Functions
func
getCouponsSetsDealsRequest
()
{
swiftApi
()
.
getCouponSetsDealsAsync
(
getCouponsSetsDealsCallback
,
failureCallback
:
{
errorCode
in
})
}
func
getCouponsSetsDealsCallback
(
_
couponsData
:
Array
<
swiftApi
.
CouponSetItemModel
>
?)
->
Void
{
if
(
couponsData
!=
nil
)
{
DispatchQueue
.
main
.
async
{
self
.
getUnifiedCouponsRequest
()
}
}
else
{
}
}
func
getUnifiedCouponsRequest
()
{
swiftApi
()
.
getUnifiedCouponsAsync
(
getUnifiedCouponsCallback
,
failureCallback
:
{
errorCode
in
self
.
unifiedCoupons
=
[]
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
a480768
...
...
@@ -16,6 +16,7 @@ public struct GlobalVariables {
static
var
dfyCoupons
:
Array
<
swiftApi
.
ActiveDFYCouponModel
>
=
[]
static
var
couponList
:
Array
<
swiftApi
.
CouponItemModel
>
=
[]
static
var
oldCouponList
:
Array
<
swiftApi
.
CouponItemModel
>
=
[]
static
var
allOldCouponList
:
Array
<
swiftApi
.
CouponItemModel
>
=
[]
static
var
couponSetList
:
Array
<
swiftApi
.
CouponSetItemModel
>
=
[]
static
var
couponsetsDealsList
:
Array
<
swiftApi
.
CouponSetItemModel
>
=
[]
// Supermarket couponsets
static
var
unifiedCouponList
:
Array
<
swiftApi
.
UnifiedCouponModel
>
=
[]
...
...
@@ -839,6 +840,24 @@ public class swiftApi {
dynatraceEvent
.
_eventName
=
"custom_success_user_coupons_loyalty"
dynatraceEvent
.
_parameters
=
nil
SwiftEventBus
.
post
(
"dynatrace"
,
sender
:
dynatraceEvent
)
// setAllOldCouponList uncluding Supermarkets ==>
var
allOldCouponsArray
:
Array
<
CouponItemModel
>
=
[]
if
let
myCouponsDictionary
=
coupons
as?
[
String
:
AnyObject
]
{
let
couponsData
=
(
myCouponsDictionary
[
"result"
]
as!
Array
<
NSMutableDictionary
>
)
if
let
cpns
=
couponsData
as?
NSArray
{
for
coupon
in
cpns
{
var
c
=
coupon
as!
NSDictionary
let
temp
=
NSMutableDictionary
(
dictionary
:
c
);
let
tempCoupon
=
CouponItemModel
(
dictionary
:
temp
as!
[
String
:
Any
])
allOldCouponsArray
.
append
(
tempCoupon
)
}
}
}
swiftApi
()
.
setAllOldCouponList
(
allOldCouponsArray
)
// <==
// On Coupons request success, make CouponSets request
instanceOfMyApi
.
getCouponsetsAsync
(
true
,
andVisible
:
true
,
andUuids
:
nil
,
couponSetsCallback
,
failureBlock
:
couponSetsFailureCallback
)
...
...
@@ -4525,6 +4544,37 @@ public class swiftApi {
return
GlobalVariables
.
oldCouponList
}
public
func
setAllOldCouponList
(
_
coupons
:
Array
<
CouponItemModel
>
)
{
// let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) }
var
oldCoupons
=
coupons
.
filter
({
return
$0
.
status
==
0
})
// sort oldCoupons by redeemed date
// let dateFormatter = DateFormatter()
// dateFormatter.dateFormat = "dd/MM/yyyy"
oldCoupons
.
sort
(
by
:
{
// let date1 = dateFormatter.date(from: $0.redeemed ?? "")
// let date2 = dateFormatter.date(from: $1.redeemed ?? "")
let
date1
=
$0
.
redeemed_date
let
date2
=
$1
.
redeemed_date
if
((
date1
!=
nil
)
&&
(
date2
!=
nil
))
{
return
date1
!.
compare
(
date2
!
)
==
.
orderedDescending
}
else
{
return
false
}
})
GlobalVariables
.
allOldCouponList
=
oldCoupons
}
public
func
getAllOldCouponList
()
->
Array
<
CouponItemModel
>
{
return
GlobalVariables
.
allOldCouponList
}
public
func
setCouponSetList
(
_
couponSets
:
Array
<
CouponSetItemModel
>
)
{
GlobalVariables
.
couponSetList
=
couponSets
...
...
Please
register
or
login
to post a comment