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-29 15:01:47 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f32dec5a5aa2b5df378162b8b0e345392a66b1cc
f32dec5a
1 parent
3800120d
Add handleSMDealsCampaign
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
f32dec5
...
...
@@ -3382,6 +3382,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
{
...
...
@@ -4084,6 +4122,29 @@ 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