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
2023-11-28 12:22:09 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d2cbaa5552bc75fb49123486795b720c4e31932f
d2cbaa55
1 parent
a497557a
Added handleSMDealsCampaign
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
d2cbaa5
...
...
@@ -3410,6 +3410,44 @@ public class swiftApi {
}
public
func
constructSMCampaignParams
(
_
campaign
:
CampaignItemModel
,
_
from_widget
:
Bool
,
_
dlParam
:
String
)
->
String
{
let
instanceOfMyApi
=
MyApi
()
let
campaignInfo
=
instanceOfMyApi
.
provideInfoForCampaign
()
let
jsonObject
:
[
String
:
String
]
=
[
"web_id"
:
(
campaignInfo
?[
"web_id"
]
as!
String
),
"app_uuid"
:
(
campaignInfo
?[
"app_uuid"
]
as!
String
),
"api_key"
:
(
campaignInfo
?[
"api_key"
]
as!
String
),
"session_uuid"
:
(
campaign
.
session_uuid
??
""
),
"access_token"
:
(
campaignInfo
?[
"access_token"
]
as!
String
),
"refresh_token"
:
(
campaignInfo
?[
"refresh_token"
]
as!
String
),
"client_id"
:
(
campaignInfo
?[
"client_id"
]
as!
String
),
"client_secret"
:
(
campaignInfo
?[
"client_secret"
]
as!
String
),
"from_widget"
:
(
from_widget
?
"true"
:
"false"
),
"dl_param"
:
dlParam
]
let
encoder
=
JSONEncoder
()
encoder
.
outputFormatting
=
.
prettyPrinted
let
data
=
try!
encoder
.
encode
(
jsonObject
)
let
stringData
=
String
(
data
:
data
,
encoding
:
.
utf8
)
??
""
print
(
"constructSMCampaignParams: "
+
stringData
)
return
stringData
// do {
// let data = try JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted)
// let stringData = String(data: data, encoding: String.Encoding.utf8) ?? ""
// print("constructCampaignParams: " + stringData)
// return stringData
// } catch {
// print("constructCampaignParams: ")
// return ""
// }
}
public
func
constructCcmsParams
(
_
campaign
:
LoyaltyContextualOfferModel
)
->
String
{
for
item
in
GlobalVariables
.
campaigns
{
...
...
@@ -4112,6 +4150,30 @@ public class swiftApi {
}
public
func
handleSMDealsCampaign
(
_
controller
:
UIViewController
,
_
dlParam
:
String
)
->
Void
{
let
status
=
swiftApi
()
.
getNetworkStatus
()
if
(
status
==
-
1
||
status
==
0
)
{
swiftApi
()
.
showDialog
(
controller
,
"Δεν υπάρχει σύνδεση"
,
"Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά."
)
}
else
{
for
item
in
GlobalVariables
.
campaigns
{
if
(
item
.
session_uuid
==
"39e70f0548884020809dda5f78d06c85"
||
item
.
session_uuid
==
"8314046c83a44576a03ccc3cd9e825db"
)
{
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
Bundle
(
for
:
MyEmptyClass
.
self
))
let
vc
=
storyboard
.
instantiateViewController
(
withIdentifier
:
"CampaignViewController"
)
as!
SwiftWarplyFramework
.
CampaignViewController
let
url
=
swiftApi
()
.
constructCampaignUrl
(
item
)
let
params
=
swiftApi
()
.
constructSMCampaignParams
(
item
,
true
,
dlParam
)
print
(
"handleSMDealsCampaign url: "
+
url
)
vc
.
campaignUrl
=
url
vc
.
params
=
params
vc
.
showHeader
=
false
controller
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
break
;
}
}
}
}
public
func
openPacing
(
_
controller
:
UIViewController
)
->
Void
{
let
status
=
swiftApi
()
.
getNetworkStatus
()
if
(
status
==
-
1
||
status
==
0
)
{
...
...
Please
register
or
login
to post a comment