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-05-09 11:27:25 +0300
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
aad019362bb399b0cfe11ac2f17c864e45952ebe
aad01936
2 parents
b20ab967
736b800c
Merge branch 'master' of
https://git.warp.ly/open-source/warply_sdk_framework
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
23 deletions
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/MyApi.h
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/MyApi.m
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
View file @
aad0193
No preview for this file type
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/MyApi.h
View file @
aad0193
...
...
@@ -75,6 +75,8 @@
-
(
NSDictionary
*
)
redeemCouponWithCoupon
:(
NSString
*
)
coupon
;
-
(
NSDictionary
*
)
validateCouponWithCoupon
:(
NSString
*
)
coupon
;
-
(
NSDictionary
*
)
loginCosmoteWithGuid
:(
NSString
*
)
guid
andAppUuid
:(
NSString
*
)
appUuid
andTicket
:(
NSString
*
)
ticket
;
-
(
void
)
getCouponsWithSuccessBlock
:(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getCouponsetsAsync
:(
NSNumber
*
)
active
andVisible
:
(
NSNumber
*
)
visible
andUuids
:
(
NSArray
*
)
uuids
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:(
void
(
^
)(
NSError
*
error
))
failure
;
@end
#endif
/* MyApi_h */
...
...
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/MyApi.m
View file @
aad0193
...
...
@@ -1257,4 +1257,31 @@ CMPedometer *pedometer;
}
return
resp
;
}
-
(
void
)
getCouponsWithSuccessBlock
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
[[
Warply
sharedService
]
getCouponsWithSuccessBlock
:
^
(
NSDictionary
*
response
)
{
if
(
success
)
{
success
(
response
);
}
}
failureBlock
:
^
(
NSError
*
error
)
{
if
(
failure
)
{
failure
(
error
);
}
}];
}
-
(
void
)
getCouponsetsAsync
:
(
NSNumber
*
)
active
andVisible
:
(
NSNumber
*
)
visible
andUuids
:
(
NSArray
*
)
uuids
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
[[
Warply
sharedService
]
getCouponSetsWithSuccessBlock
:
active
andVisible
:
visible
andUuids
:
uuids
:^
(
NSDictionary
*
response
)
{
if
(
success
)
{
success
(
response
);
}
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
failure
(
error
);
}
}];
}
@end
...
...
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
View file @
aad0193
...
...
@@ -220,12 +220,62 @@ public class swiftApi {
var
data
:
Array
<
CouponItemModel
>
=
[]
init
()
{
//initializer method
}
var
getData
:
Array
<
CouponItemModel
>
{
get
{
// getter
return
data
.
filter
({
return
$0
.
status
==
1
})
}
}
var
getOldCoupons
:
Array
<
CouponItemModel
>
{
get
{
// getter
return
data
.
filter
({
return
$0
.
status
!=
1
})
}
}
func
getCouponsData
(
_
getCouponsCallback
:
@escaping
(
_
couponsData
:
Array
<
CouponItemModel
>
?)
->
Void
)
->
Void
{
var
coupons
:
[
AnyHashable
:
Any
]?
var
couponSets
:
[
AnyHashable
:
Any
]?
let
instanceOfMyApi
=
MyApi
()
let
coupons
=
instanceOfMyApi
.
getCoupons
()
let
couponSets
=
instanceOfMyApi
.
getCouponSets
(
withActive
:
true
,
andVisible
:
true
,
andUuids
:
nil
)
var
couponsArray
:
Array
<
CouponItemModel
>
=
[]
instanceOfMyApi
.
getCouponsWithSuccessBlock
(
couponsCallback
,
failureBlock
:
(
couponsFailureCallback
))
func
couponsCallback
(
_
couponsData
:
[
AnyHashable
:
Any
]?)
->
Void
{
coupons
=
couponsData
??
[
""
:
""
]
// On Coupons request success, make CouponSets request
instanceOfMyApi
.
getCouponsetsAsync
(
true
,
andVisible
:
true
,
andUuids
:
nil
,
couponSetsCallback
,
failureBlock
:
couponSetsFailureCallback
)
}
func
couponsFailureCallback
(
_
error
:
Error
?)
->
Void
{
print
(
"getCoupons error: "
)
getCouponsCallback
(
nil
)
}
func
couponSetsCallback
(
_
couponSetsData
:
[
AnyHashable
:
Any
]?)
->
Void
{
couponSets
=
couponSetsData
??
[
""
:
""
]
// On CouponSets request Success, match coupons with couponsets
let
tempCoupons
=
matchCoupons
()
getCouponsCallback
(
tempCoupons
)
}
func
couponSetsFailureCallback
(
_
error
:
Error
?)
->
Void
{
print
(
"getCouponSets error: "
)
getCouponsCallback
(
nil
)
}
func
matchCoupons
()
->
Array
<
CouponItemModel
>
{
var
couponsArray
:
Array
<
CouponItemModel
>
=
[]
if
let
myCouponsSetsDictionary
=
couponSets
as?
[
String
:
AnyObject
]
{
let
couponSetsData
=
(
myCouponsSetsDictionary
[
"MAPP_COUPON"
]
as!
Array
<
NSMutableDictionary
>
)
...
...
@@ -255,36 +305,40 @@ public class swiftApi {
}
}
// 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
// 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)
// }
//
// }
return
couponsArray
}
var
getData
:
Array
<
CouponItemModel
>
{
get
{
// getter
return
data
.
filter
({
return
$0
.
status
==
1
})
}
}
var
getOldCoupons
:
Array
<
CouponItemModel
>
{
get
{
// getter
return
data
.
filter
({
return
$0
.
status
!=
1
public
func
filterActiveCoupons
(
_
coupons
:
Array
<
CouponItemModel
>
)
->
Array
<
CouponItemModel
>
{
return
coupons
.
filter
({
return
$0
.
status
==
1
})
}
public
func
filterOldCoupons
(
_
coupons
:
Array
<
CouponItemModel
>
)
->
Array
<
CouponItemModel
>
{
return
coupons
.
filter
({
return
$0
.
status
!=
1
})
}
public
func
getCouponsAsync
(
_
getCouponsCallback
:
@escaping
(
_
couponsData
:
Array
<
CouponItemModel
>
?)
->
Void
)
->
Void
{
CouponsDataModel
()
.
getCouponsData
(
getCouponsCallback
)
}
public
func
getCoupons
()
->
Array
<
CouponItemModel
>
{
...
...
Please
register
or
login
to post a comment