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
Vasilis
2022-04-29 15:08:53 +0300
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
3411b7978ef2e266e4a6b180f51a7d89eb0a7712
3411b797
2 parents
44b8a96e
2a84ac1b
Merge branch 'master' of
https://git.warp.ly/open-source/warply_sdk_framework
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
9 deletions
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
View file @
3411b79
No preview for this file type
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
View file @
3411b79
...
...
@@ -140,6 +140,7 @@ public class swiftApi {
let
category
:
String
?
let
barcode
:
String
?
let
status
:
Int
?
var
couponset_data
:
CouponSetItemModel
?
init
(
dictionary
:
[
String
:
Any
])
{
self
.
couponset_uuid
=
dictionary
[
"couponset_uuid"
]
as?
String
?
??
""
...
...
@@ -151,6 +152,7 @@ public class swiftApi {
self
.
category
=
dictionary
[
"category"
]
as?
String
?
??
""
self
.
barcode
=
dictionary
[
"barcode"
]
as?
String
?
??
""
self
.
status
=
dictionary
[
"status"
]
as?
Int
?
??
nil
self
.
couponset_data
=
dictionary
[
"couponset_data"
]
as?
CouponSetItemModel
?
??
nil
let
expirationObject
=
dictionary
[
"expiration"
]
as?
[
String
:
Any
]?
??
[
""
:
""
]
let
expirationString
=
expirationObject
?[
"value"
]
as?
String
?
??
""
...
...
@@ -170,6 +172,11 @@ public class swiftApi {
}
public
func
setCouponSetData
(
_
couponSet
:
CouponSetItemModel
)
{
self
.
couponset_data
=
couponSet
}
// var asDictionary : [String:Any] {
// let mirror = Mirror(reflecting: self)
// let dict = Dictionary(uniqueKeysWithValues: mirror.children.lazy.map({ (label:String?, value:Any) -> (String, Any)? in
...
...
@@ -186,26 +193,69 @@ public class swiftApi {
init
()
{
//initializer method
let
instanceOfMyApi
=
MyApi
()
let
coupons
=
instanceOfMyApi
.
getCoupons
()
let
couponSets
=
instanceOfMyApi
.
getCouponSets
(
withActive
:
true
,
andVisible
:
true
,
andUuids
:
nil
)
var
couponsArray
:
Array
<
CouponItemModel
>
=
[]
if
let
myCouponsDictionary
=
coupons
as?
[
String
:
AnyObject
]
{
let
couponsData
=
(
myCouponsDictionary
[
"result"
]
as!
NSArray
)
for
coupon
in
couponsData
{
let
tempCoupon
=
CouponItemModel
(
dictionary
:
coupon
as!
[
String
:
Any
])
couponsArray
.
append
(
tempCoupon
)
if
let
myCouponsSetsDictionary
=
couponSets
as?
[
String
:
AnyObject
]
{
let
couponSetsData
=
(
myCouponsSetsDictionary
[
"MAPP_COUPON"
]
as!
Array
<
NSMutableDictionary
>
)
if
let
myCouponsDictionary
=
coupons
as?
[
String
:
AnyObject
]
{
let
couponsData
=
(
myCouponsDictionary
[
"result"
]
as!
Array
<
NSMutableDictionary
>
)
if
let
sets
=
couponSetsData
as?
NSArray
{
for
set
in
sets
{
let
s
=
set
as!
[
String
:
Any
]
if
let
cpns
=
couponsData
as?
NSArray
{
for
coupon
in
cpns
{
var
c
=
coupon
as!
[
String
:
Any
]
// var temp = NSMutableDictionary(dictionary: s);
if
c
[
"couponset_uuid"
]
as!
String
==
s
[
"uuid"
]
as!
String
{
let
temp
=
NSMutableDictionary
(
dictionary
:
c
);
temp
.
setValue
(
s
as
[
AnyHashable
:
Any
],
forKey
:
"couponset_data"
)
let
tempCoupon
=
CouponItemModel
(
dictionary
:
temp
as!
[
String
:
Any
])
couponsArray
.
append
(
tempCoupon
)
}
}
}
}
}
}
}
// if let myCouponsDictionary = coupons as? [String : AnyObject] {
// let couponsData = (myCouponsDictionary["result"] as! NSArray)
//
//
// for coupon in couponsData {
// let tempCoupon = CouponItemModel(dictionary: coupon as! [String : Any])
// couponsArray.append(tempCoupon)
// }
//
// }
self
.
data
=
couponsArray
}
var
getData
:
Array
<
CouponItemModel
>
{
get
{
// getter
return
data
return
data
.
filter
({
return
$0
.
status
==
1
})
}
}
var
getOldCoupons
:
Array
<
CouponItemModel
>
{
get
{
// getter
return
data
.
filter
({
return
$0
.
status
!=
1
})
}
}
}
public
func
getCoupons
()
->
Array
<
CouponItemModel
>
{
...
...
Please
register
or
login
to post a comment