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-04-29 15:08:08 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8afc50e5f7d01e17c7f7ea2a2e488184aebae35a
8afc50e5
1 parent
9a72486e
swiftApi model changes
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
6 deletions
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
View file @
8afc50e
No preview for this file type
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
View file @
8afc50e
...
...
@@ -128,6 +128,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
?
??
""
...
...
@@ -139,6 +140,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
?
??
""
...
...
@@ -158,6 +160,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
...
...
@@ -174,26 +181,69 @@ public class swiftApi {
init
()
{
//initializer method
let
instanceOfMyApi
=
MyApi
()
let
coupons
=
instanceOfMyApi
.
getCoupons
()
var
couponsArray
:
Array
<
CouponItemModel
>
=
[]
let
couponSets
=
instanceOfMyApi
.
getCouponSets
(
withActive
:
true
,
andVisible
:
true
,
andUuids
:
nil
)
if
let
myCouponsDictionary
=
coupons
as?
[
String
:
AnyObject
]
{
let
couponsData
=
(
myCouponsDictionary
[
"result"
]
as!
NSArray
)
var
couponsArray
:
Array
<
CouponItemModel
>
=
[]
for
coupon
in
couponsData
{
let
tempCoupon
=
CouponItemModel
(
dictionary
:
coupon
as!
[
String
:
Any
])
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