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 11:36:55 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a1aa27b2122ae947824042646e0a2809d5eb7be6
a1aa27b2
1 parent
da0cd054
update CampaignItemModel
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
51 deletions
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
a1aa27b
...
...
@@ -501,6 +501,7 @@ public class swiftApi {
// public var campaign_type_settings: [String: Any]?
public
var
couponset
:
String
?
public
var
type
:
String
?
public
var
sorting
:
Int
?
public
init
()
{
self
.
index_url
=
""
...
...
@@ -521,35 +522,30 @@ public class swiftApi {
// self.campaign_type_settings = [String: Any]()
self
.
couponset
=
""
self
.
type
=
""
self
.
sorting
=
nil
}
public
init
(
dictionary
:
[
String
:
Any
])
{
self
.
index_url
=
dictionary
[
"index_url"
]
as?
String
?
??
""
self
.
logo_url
=
dictionary
[
"logo_url"
]
as?
String
?
??
""
self
.
offer_category
=
dictionary
[
"
offer
_category"
]
as?
String
?
??
""
self
.
offer_category
=
dictionary
[
"
communication
_category"
]
as?
String
?
??
""
self
.
title
=
dictionary
[
"title"
]
as?
String
?
??
""
self
.
subtitle
=
dictionary
[
"subtitle"
]
as?
String
?
??
""
self
.
session_uuid
=
dictionary
[
"
sess
ion_uuid"
]
as?
String
?
??
""
self
.
session_uuid
=
dictionary
[
"
communicat
ion_uuid"
]
as?
String
?
??
""
self
.
is_new
=
dictionary
[
"is_new"
]
as?
Bool
?
??
false
self
.
message
=
dictionary
[
"message"
]
as?
String
?
??
""
self
.
loyaltyPackageId
=
""
self
.
campaign_type
=
dictionary
[
"campaign_type"
]
as?
String
?
??
""
self
.
sorting
=
dictionary
[
"sorting"
]
as?
Int
?
??
nil
// let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""]
let
extra_fields
=
dictionary
[
"extra_fields"
]
as
AnyObject
var
extra_fields_parsed
:[
String
:
Any
]
let
json
=
extra_fields
.
data
(
using
:
String
.
Encoding
.
utf8
.
rawValue
)
do
{
if
let
jsonArray
=
try
JSONSerialization
.
jsonObject
(
with
:
json
!
,
options
:
.
allowFragments
)
as?
[
String
:
AnyObject
]
{
extra_fields_parsed
=
jsonArray
;
self
.
subcategory
=
extra_fields_parsed
[
"subcategory"
]
as?
String
?
??
""
self
.
loyaltyCampaignId
=
extra_fields_parsed
[
"loyaltyCampaignId"
]
as?
String
?
??
""
// let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""]
if
let
extra_fields
=
dictionary
[
"extra_fields"
]
as?
[
String
:
Any
]
{
self
.
subcategory
=
extra_fields
[
"subcategory"
]
as?
String
?
??
""
self
.
loyaltyCampaignId
=
extra_fields
[
"loyaltyCampaignId"
]
as?
String
?
??
""
self
.
hasExtraFields
=
true
self
.
ccms_offer
=
extra_fields_parsed
[
"ccms_offer"
]
as?
String
?
??
"false"
self
.
badge
=
extra_fields_parsed
[
"badge"
]
as?
String
?
??
""
self
.
type
=
extra_fields_parsed
[
"type"
]
as?
String
?
??
""
self
.
ccms_offer
=
extra_fields
[
"ccms_offer"
]
as?
String
?
??
"false"
self
.
badge
=
extra_fields
[
"badge"
]
as?
String
?
??
""
self
.
type
=
extra_fields
[
"type"
]
as?
String
?
??
""
}
else
{
self
.
subcategory
=
""
self
.
loyaltyCampaignId
=
""
...
...
@@ -557,48 +553,78 @@ public class swiftApi {
self
.
ccms_offer
=
"false"
self
.
badge
=
""
self
.
type
=
""
print
(
"bad json"
)
}
}
catch
let
error
as
NSError
{
self
.
subcategory
=
""
self
.
loyaltyCampaignId
=
""
self
.
hasExtraFields
=
false
self
.
ccms_offer
=
"false"
self
.
badge
=
""
self
.
type
=
""
print
(
error
)
}
// campaign_type_settings
if
let
campaign_type_settings_obj
=
dictionary
[
"campaign_type_settings"
]
as?
AnyObject
{
if
((
!
(
campaign_type_settings_obj
is
NSNull
))
&&
(
campaign_type_settings_obj
!=
nil
))
{
var
campaign_type_settings_parsed
:[
String
:
Any
]
// let extra_fields = dictionary["extra_fields"] as AnyObject
// var extra_fields_parsed:[String: Any]
// let json = extra_fields.data(using: String.Encoding.utf8.rawValue)
// do {
// if let jsonArray = try JSONSerialization.jsonObject(with: json!, options: .allowFragments) as? [String:AnyObject]
// {
// extra_fields_parsed = jsonArray;
// self.subcategory = extra_fields_parsed["subcategory"] as? String? ?? ""
// self.loyaltyCampaignId = extra_fields_parsed["loyaltyCampaignId"] as? String? ?? ""
// self.hasExtraFields = true
// self.ccms_offer = extra_fields_parsed["ccms_offer"] as? String? ?? "false"
// self.badge = extra_fields_parsed["badge"] as? String? ?? ""
// self.type = extra_fields_parsed["type"] as? String? ?? ""
// } else {
// self.subcategory = ""
// self.loyaltyCampaignId = ""
// self.hasExtraFields = false
// self.ccms_offer = "false"
// self.badge = ""
// self.type = ""
// print("bad json")
// }
// } catch let error as NSError {
// self.subcategory = ""
// self.loyaltyCampaignId = ""
// self.hasExtraFields = false
// self.ccms_offer = "false"
// self.badge = ""
// self.type = ""
// print(error)
// }
let
campaign_type_settings_json
=
campaign_type_settings_obj
.
data
(
using
:
String
.
Encoding
.
utf8
.
rawValue
)
do
{
if
let
jsonArray
=
try
JSONSerialization
.
jsonObject
(
with
:
campaign_type_settings_json
!
,
options
:
.
allowFragments
)
as?
[
String
:
AnyObject
]
{
campaign_type_settings_parsed
=
jsonArray
;
// self.campaign_type_settings = campaign_type_settings_parsed as? [String: Any]? ?? [String: Any]()
self
.
couponset
=
campaign_type_settings_parsed
[
"couponset"
]
as?
String
?
??
""
}
else
{
// self.campaign_type_settings = [String: Any]()
self
.
couponset
=
""
print
(
"bad json"
)
}
}
catch
let
error
as
NSError
{
// self.campaign_type_settings = [String: Any]()
self
.
couponset
=
""
print
(
error
)
}
// campaign_type_settings
if
let
campaign_type_settings
=
dictionary
[
"settings"
]
as?
[
String
:
Any
]
{
self
.
couponset
=
campaign_type_settings
[
"couponset"
]
as?
String
?
??
""
}
else
{
self
.
couponset
=
""
}
}
else
{
self
.
couponset
=
""
}
// if let campaign_type_settings_obj = dictionary["campaign_type_settings"] as? AnyObject {
//
// if ((!(campaign_type_settings_obj is NSNull)) && (campaign_type_settings_obj != nil)) {
// var campaign_type_settings_parsed:[String: Any]
//
// let campaign_type_settings_json = campaign_type_settings_obj.data(using: String.Encoding.utf8.rawValue)
// do {
// if let jsonArray = try JSONSerialization.jsonObject(with: campaign_type_settings_json!, options: .allowFragments) as? [String:AnyObject]
// {
// campaign_type_settings_parsed = jsonArray;
// // self.campaign_type_settings = campaign_type_settings_parsed as? [String: Any]? ?? [String: Any]()
// self.couponset = campaign_type_settings_parsed["couponset"] as? String? ?? ""
// } else {
// // self.campaign_type_settings = [String: Any]()
// self.couponset = ""
// print("bad json")
// }
// } catch let error as NSError {
// // self.campaign_type_settings = [String: Any]()
// self.couponset = ""
// print(error)
// }
// } else {
// self.couponset = ""
// }
//
// } else {
// self.couponset = ""
// }
}
...
...
@@ -673,6 +699,15 @@ public class swiftApi {
self
.
type
=
newValue
}
}
public
var
_sorting
:
Int
?
{
get
{
// getter
return
self
.
sorting
}
set
(
newValue
)
{
//setter
self
.
sorting
=
newValue
}
}
}
public
class
CampaignDataModel
{
...
...
Please
register
or
login
to post a comment