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-07-21 14:25:57 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5a456b27756581d2c2722199ea91d639ee7dfca4
5a456b27
1 parent
a1aa27b2
add getCampaignsAsyncNew request
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
204 additions
and
0 deletions
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.h
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.m
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.h
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.m
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.h
View file @
5a456b2
...
...
@@ -90,6 +90,8 @@
-
(
void
)
cosmoteCouponSharingAsync
:(
NSString
*
)
coupon
:
(
NSString
*
)
sender
:
(
NSString
*
)
receiver
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
submitOrderAsync
:(
NSString
*
)
campaign_session_uuid
:
(
NSString
*
)
user_msisdn
:
(
NSString
*
)
businessService
:
(
NSString
*
)
offerName
:
(
NSString
*
)
productType
:
(
NSString
*
)
provDuration
:
(
NSString
*
)
noOfRecurrance
:
(
NSString
*
)
price
:
(
NSString
*
)
discount
:
(
NSString
*
)
voiceCategory
:
(
NSString
*
)
dataCategory
:
(
NSString
*
)
minsValue
:
(
NSString
*
)
dataValue
:
(
NSString
*
)
provStepValueMins
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
postEventAsync
:(
NSString
*
)
Session_ID
:
(
NSString
*
)
OfferAudienceLevel
:
(
NSString
*
)
msisdn
:
(
NSString
*
)
UACIOfferTrackingCode
:
(
NSString
*
)
OFFERCODE1
:
(
NSString
*
)
SCORE
:
(
NSString
*
)
ZONE
:
(
NSString
*
)
WAVE
:
(
NSString
*
)
VALIDITY
:
(
NSString
*
)
TREATMENT_CODE
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getCampaignsAsyncNew
:(
NSString
*
)
language
:
(
NSDictionary
*
)
filters
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getCampaignsPersonalizedAsync
:(
NSString
*
)
language
:
(
NSDictionary
*
)
filters
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
@end
#endif
/* MyApi_h */
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.m
View file @
5a456b2
...
...
@@ -1468,4 +1468,30 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
-
(
void
)
getCampaignsAsyncNew
:
(
NSString
*
)
language
:
(
NSDictionary
*
)
filters
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
[[
Warply
sharedService
]
getCampaignsWithSuccessBlock
:
language
:
filters
:^
(
NSDictionary
*
response
)
{
if
(
success
)
{
success
(
response
);
}
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
failure
(
error
);
}
}];
}
-
(
void
)
getCampaignsPersonalizedAsync
:
(
NSString
*
)
language
:
(
NSDictionary
*
)
filters
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
[[
Warply
sharedService
]
getCampaignsPersonalizedWithSuccessBlock
:
language
:
filters
:^
(
NSDictionary
*
response
)
{
if
(
success
)
{
success
(
response
);
}
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
failure
(
error
);
}
}];
}
@end
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.h
View file @
5a456b2
...
...
@@ -299,6 +299,10 @@ WL_VERSION_INTERFACE()
-
(
BOOL
)
getInbox2WithSuccessBlock
:(
void
(
^
)(
NSArray
*
list
))
success
failureBlock
:(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
BOOL
)
getCampaignsWithSuccessBlock
:(
NSString
*
)
language
:
(
NSDictionary
*
)
filters
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getCampaignsPersonalizedWithSuccessBlock
:(
NSString
*
)
language
:
(
NSDictionary
*
)
filters
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getProductsWithSuccessBlock
:(
NSString
*
)
filter
:
(
void
(
^
)(
NSMutableArray
*
params
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
sendContactWithSuccessBlock
:(
NSString
*
)
name
andEmail
:(
NSString
*
)
email
andMsisdn
:
msisdn
andMessage
:
message
:
(
void
(
^
)(
NSMutableArray
*
params
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.m
View file @
5a456b2
...
...
@@ -517,6 +517,73 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
return
[
self
isRegistrationValid
];
}
-
(
BOOL
)
getCampaignsWithSuccessBlock
:
(
NSString
*
)
language
:
(
NSDictionary
*
)
filters
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
// if (self.allOffers.count > 0) {
// success(self.allOffers);
// } else {
NSDictionary
*
postDictionary
=
@{
@"campaigns"
:
@{
@"action"
:
@"retrieve"
,
@"language"
:
language
,
@"filters"
:
filters
}};
NSData
*
jsonData
=
[
NSJSONSerialization
dataWithJSONObject
:
postDictionary
options
:
0
error
:
NULL
];
[
self
sendContext
:
jsonData
successBlock
:
^
(
NSDictionary
*
contextResponse
)
{
if
(
success
)
{
success
(
contextResponse
);
}
NSLog
(
@"**************** WARPLY Response *****************"
);
NSLog
(
@"%@"
,
contextResponse
);
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
failure
(
error
);
}
NSLog
(
@"Error at get Campaigns %@"
,
error
);
}];
// }
return
[
self
isRegistrationValid
];
}
-
(
void
)
getCampaignsPersonalizedWithSuccessBlock
:
(
NSString
*
)
language
:
(
NSDictionary
*
)
filters
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
NSDictionary
*
postDictionary
=
@{
@"campaigns"
:
@{
@"action"
:
@"retrieve"
,
@"language"
:
language
,
@"filters"
:
filters
}};
NSData
*
jsonData
=
[
NSJSONSerialization
dataWithJSONObject
:
postDictionary
options
:
0
error
:
NULL
];
[
self
sendContext8
:
jsonData
successBlock
:
^
(
NSDictionary
*
contextResponse
)
{
if
(
success
)
{
success
(
contextResponse
);
}
NSLog
(
@"**************** WARPLY Response *****************"
);
NSLog
(
@"%@"
,
contextResponse
);
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
NSDictionary
*
dict
=
[
NSDictionary
alloc
];
dict
=
[
error
userInfo
];
NSString
*
errorCode
=
[
dict
objectForKey
:
@"NSLocalizedDescription"
];
if
([
errorCode
isEqual
:
@"Request failed: unauthorized (401)"
])
{
[
self
refreshToken
:
^
(
NSDictionary
*
response
)
{
[
self
sendContext8
:
jsonData
successBlock
:
^
(
NSDictionary
*
contextResponse
)
{
if
(
success
)
{
success
(
contextResponse
);
}
NSLog
(
@"**************** WARPLY Response *****************"
);
NSLog
(
@"%@"
,
contextResponse
);
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
failure
(
error
);
}
}];
}
failureBlock
:
^
(
NSError
*
error
)
{
if
(
failure
)
{
[
_db
executeUpdate
:
@"DROP TABLE requestVariables"
];
failure
(
error
);
}
NSLog
(
@"Error at token %@"
,
error
);
}];
}
NSLog
(
@"Error at get Campaigns Personalized %@"
,
error
);
}
}];
}
-
(
NSString
*
)
getAccessToken
{
[
self
createDBIfNeeded
];
[
self
initDBIfNeeded
];
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
5a456b2
...
...
@@ -764,6 +764,111 @@ public class swiftApi {
}
public
func
getCampaignsAsyncNew
(
language
:
String
,
filters
:
[
String
:
Any
],
_
getCampaignsCallback
:
@escaping
(
_
campaignsData
:
Array
<
CampaignItemModel
>
?)
->
Void
)
->
Void
{
let
instanceOfMyApi
=
MyApi
()
instanceOfMyApi
.
getCampaignsAsyncNew
(
language
,
filters
,
campaignsCallback
,
failureBlock
:
campaignsFailureCallback
)
func
campaignsCallback
(
_
campaignsData
:
[
AnyHashable
:
Any
]?)
->
Void
{
var
campaignsArray
:
Array
<
CampaignItemModel
>
=
[]
if
let
responseDataDictionary
=
campaignsData
as?
[
String
:
AnyObject
]
{
if
(
responseDataDictionary
[
"MAPP_CAMPAIGNING-status"
]
as?
Int
==
1
)
{
if
let
responseDataMapp
=
responseDataDictionary
[
"MAPP_CAMPAIGNING"
]
as?
[
String
:
Any
]
{
if
let
responseDataCampaigns
=
responseDataMapp
[
"campaigns"
]
as?
[[
String
:
Any
]?]
{
for
item
in
responseDataCampaigns
{
if
let
itemDictionary
=
item
{
let
tempCampaign
=
CampaignItemModel
(
dictionary
:
itemDictionary
)
campaignsArray
.
append
(
tempCampaign
)
}
}
}
}
else
{
getCampaignsCallback
(
nil
)
}
swiftApi
()
.
getCampaignsPersonalizedAsync
(
language
:
language
,
filters
:
filters
,
{
campaignsPersonalizedData
in
campaignsArray
=
campaignsArray
+
(
campaignsPersonalizedData
??
[])
swiftApi
()
.
setUniqueCampaignList
(
campaignsArray
)
let
filteredCampaigns
=
campaignsArray
.
filter
{
let
tempCampaign
=
$0
let
isCcmsOffer
=
(
tempCampaign
.
ccms_offer
!=
nil
)
&&
(
tempCampaign
.
ccms_offer
!=
""
)
&&
(
tempCampaign
.
ccms_offer
==
"true"
)
let
isTelco
=
(
tempCampaign
.
_type
!=
nil
&&
tempCampaign
.
_type
==
"telco"
)
return
(
!
(
isCcmsOffer
||
isTelco
))
}
getCampaignsCallback
(
filteredCampaigns
);
})
}
else
{
getCampaignsCallback
(
nil
)
}
}
else
{
getCampaignsCallback
(
nil
)
}
}
func
campaignsFailureCallback
(
_
error
:
Error
?)
->
Void
{
print
(
"getCampaigns error: "
)
print
(
error
)
print
(
"===================="
)
getCampaignsCallback
(
nil
)
}
}
public
func
getCampaignsPersonalizedAsync
(
language
:
String
,
filters
:
[
String
:
Any
],
_
getCampaignsCallback
:
@escaping
(
_
campaignsData
:
Array
<
CampaignItemModel
>
?)
->
Void
)
->
Void
{
let
instanceOfMyApi
=
MyApi
()
instanceOfMyApi
.
getCampaignsPersonalizedAsync
(
language
,
filters
,
campaignsCallback
,
failureBlock
:
campaignsFailureCallback
)
func
campaignsCallback
(
_
campaignsData
:
[
AnyHashable
:
Any
]?)
->
Void
{
var
campaignsArray
:
Array
<
CampaignItemModel
>
=
[]
if
let
responseDataDictionary
=
campaignsData
as?
[
String
:
AnyObject
]
{
if
(
responseDataDictionary
[
"MAPP_CAMPAIGNING-status"
]
as?
Int
==
1
)
{
if
let
responseDataMapp
=
responseDataDictionary
[
"MAPP_CAMPAIGNING"
]
as?
[
String
:
Any
]
{
if
let
responseDataCampaigns
=
responseDataMapp
[
"campaigns"
]
as?
[[
String
:
Any
]?]
{
for
item
in
responseDataCampaigns
{
if
let
itemDictionary
=
item
{
let
tempCampaign
=
CampaignItemModel
(
dictionary
:
itemDictionary
)
campaignsArray
.
append
(
tempCampaign
)
}
}
getCampaignsCallback
(
campaignsArray
);
}
}
else
{
getCampaignsCallback
(
nil
)
}
}
else
{
getCampaignsCallback
(
nil
)
}
}
else
{
getCampaignsCallback
(
nil
)
}
}
func
campaignsFailureCallback
(
_
error
:
Error
?)
->
Void
{
print
(
"getCampaignsPersonalized error: "
)
print
(
error
)
print
(
"===================="
)
getCampaignsCallback
(
nil
)
}
}
public
class
LoyaltyContextualOfferModel
:
Codable
{
private
var
sessionId
:
String
private
var
eligibleAssets
:
Array
<
String
>
...
...
Please
register
or
login
to post a comment