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 12:07:04 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
499f15b1e538fcdfccebfe5035b226ae75baf673
499f15b1
1 parent
85c91f81
swift api added coupons and couponsets
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
178 additions
and
2 deletions
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/billskouras.xcuserdatad/UserInterfaceState.xcuserstate
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/billskouras.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/billskouras.xcuserdatad/UserInterfaceState.xcuserstate
View file @
499f15b
No preview for this file type
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/billskouras.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
View file @
499f15b
...
...
@@ -32,8 +32,8 @@
endingColumnNumber =
"9223372036854775807"
startingLineNumber =
"212"
endingLineNumber =
"212"
landmarkName =
"
goBack()
"
landmarkType =
"
7
"
>
landmarkName =
"
body
"
landmarkType =
"
24
"
>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
...
...
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
View file @
499f15b
...
...
@@ -9,6 +9,10 @@ import Foundation
public
class
swiftApi
{
public
init
()
{
}
public
func
getUserTag
()
->
String
{
return
"1"
}
...
...
@@ -24,4 +28,176 @@ public class swiftApi {
public
func
setCCMSLoyaltyCampaigns
(
campaigns
:
Array
<
Dictionary
<
String
,
String
>>
)
{
}
public
class
CouponSetItemModel
{
let
uuid
:
String
?
let
admin_name
:
String
?
let
name
:
String
?
let
img_preview
:
String
?
let
expiration
:
String
?
let
description
:
String
?
let
short_description
:
String
?
let
discount
:
String
?
let
sorting
:
Int
?
let
inner_text
:
String
?
let
buyable
:
Bool
?
let
visible
:
Bool
?
init
(
dictionary
:
[
String
:
Any
])
{
self
.
uuid
=
dictionary
[
"uuid"
]
as?
String
?
??
""
self
.
admin_name
=
dictionary
[
"admin_name"
]
as?
String
?
??
""
self
.
name
=
dictionary
[
"name"
]
as?
String
?
??
""
self
.
img_preview
=
dictionary
[
"img_preview"
]
as?
String
?
??
""
self
.
description
=
dictionary
[
"description"
]
as?
String
?
??
""
self
.
short_description
=
dictionary
[
"short_description"
]
as?
String
?
??
""
self
.
discount
=
dictionary
[
"discount"
]
as?
String
?
??
""
self
.
sorting
=
dictionary
[
"sorting"
]
as?
Int
?
??
nil
self
.
inner_text
=
dictionary
[
"inner_text"
]
as?
String
?
??
""
self
.
buyable
=
dictionary
[
"buyable"
]
as?
Bool
?
??
false
self
.
visible
=
dictionary
[
"visible"
]
as?
Bool
?
??
false
let
expirationObject
=
dictionary
[
"expiration"
]
as?
[
String
:
Any
]?
??
[
""
:
""
]
let
expirationString
=
expirationObject
?[
"value"
]
as?
String
?
??
""
// Example expirationString: Optional(2022-12-05 01:55)
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"yyyy-MM-dd hh:mm"
if
let
date
=
dateFormatter
.
date
(
from
:
expirationString
??
""
)
{
dateFormatter
.
dateFormat
=
"dd/MM/yyyy"
let
resultString
=
dateFormatter
.
string
(
from
:
date
)
self
.
expiration
=
resultString
}
else
{
self
.
expiration
=
""
}
}
// var asDictionary : [String:Any] {
// let mirror = Mirror(reflecting: self)
// let dict = Dictionary(uniqueKeysWithValues: mirror.children.lazy.map({ (label:String?, value:Any) -> (String, Any)? in
// guard let label = label else { return nil }
// return (label, value)
// }).compactMap { $0 })
// return dict
// }
}
public
class
CouponSetsDataModel
{
var
data
:
Array
<
CouponSetItemModel
>
=
[]
init
()
{
//initializer method
let
instanceOfMyApi
=
MyApi
()
let
couponSets
=
instanceOfMyApi
.
getCouponSets
(
withActive
:
true
,
andVisible
:
true
,
andUuids
:
nil
)
var
couponSetsArray
:
Array
<
CouponSetItemModel
>
=
[]
if
let
myCouponsSetsDictionary
=
couponSets
as?
[
String
:
AnyObject
]
{
let
couponSetsData
=
(
myCouponsSetsDictionary
[
"MAPP_COUPON"
]
as!
NSArray
)
for
couponset
in
couponSetsData
{
let
tempCouponset
=
CouponSetItemModel
(
dictionary
:
couponset
as!
[
String
:
Any
])
couponSetsArray
.
append
(
tempCouponset
)
}
}
self
.
data
=
couponSetsArray
}
var
getData
:
Array
<
CouponSetItemModel
>
{
get
{
// getter
return
data
}
}
}
public
func
getCouponSets
()
->
Array
<
CouponSetItemModel
>
{
return
CouponSetsDataModel
()
.
getData
}
public
class
CouponItemModel
{
let
couponset_uuid
:
String
?
let
name
:
String
?
let
image
:
String
?
let
expiration
:
String
?
let
description
:
String
?
let
discount
:
String
?
let
coupon
:
String
?
let
category
:
String
?
let
barcode
:
String
?
let
status
:
Int
?
init
(
dictionary
:
[
String
:
Any
])
{
self
.
couponset_uuid
=
dictionary
[
"couponset_uuid"
]
as?
String
?
??
""
self
.
name
=
dictionary
[
"name"
]
as?
String
?
??
""
self
.
image
=
dictionary
[
"image"
]
as?
String
?
??
""
self
.
description
=
dictionary
[
"description"
]
as?
String
?
??
""
self
.
discount
=
dictionary
[
"discount"
]
as?
String
?
??
""
self
.
coupon
=
dictionary
[
"coupon"
]
as?
String
?
??
""
self
.
category
=
dictionary
[
"category"
]
as?
String
?
??
""
self
.
barcode
=
dictionary
[
"barcode"
]
as?
String
?
??
""
self
.
status
=
dictionary
[
"status"
]
as?
Int
?
??
nil
let
expirationObject
=
dictionary
[
"expiration"
]
as?
[
String
:
Any
]?
??
[
""
:
""
]
let
expirationString
=
expirationObject
?[
"value"
]
as?
String
?
??
""
// Example expirationString: Optional(2022-12-05 01:55)
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"yyyy-MM-dd hh:mm"
if
let
date
=
dateFormatter
.
date
(
from
:
expirationString
??
""
)
{
dateFormatter
.
dateFormat
=
"dd/MM/yyyy"
let
resultString
=
dateFormatter
.
string
(
from
:
date
)
self
.
expiration
=
resultString
}
else
{
self
.
expiration
=
""
}
}
// var asDictionary : [String:Any] {
// let mirror = Mirror(reflecting: self)
// let dict = Dictionary(uniqueKeysWithValues: mirror.children.lazy.map({ (label:String?, value:Any) -> (String, Any)? in
// guard let label = label else { return nil }
// return (label, value)
// }).compactMap { $0 })
// return dict
// }
}
public
class
CouponsDataModel
{
var
data
:
Array
<
CouponItemModel
>
=
[]
init
()
{
//initializer method
let
instanceOfMyApi
=
MyApi
()
let
coupons
=
instanceOfMyApi
.
getCoupons
()
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
)
}
}
self
.
data
=
couponsArray
}
var
getData
:
Array
<
CouponItemModel
>
{
get
{
// getter
return
data
}
}
}
public
func
getCoupons
()
->
Array
<
CouponItemModel
>
{
return
CouponsDataModel
()
.
getData
}
}
...
...
Please
register
or
login
to post a comment