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-04-29 12:15:17 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a2cc38b57a7099a44a76641ba68990b3e5c439bf
a2cc38b5
1 parent
f27ae22b
addition of campaigns at swiftApi
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/billskouras.xcuserdatad/UserInterfaceState.xcuserstate
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS.xcworkspace/xcuserdata/billskouras.xcuserdatad/UserInterfaceState.xcuserstate
View file @
a2cc38b
No preview for this file type
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
View file @
a2cc38b
...
...
@@ -200,4 +200,72 @@ public class swiftApi {
return
CouponsDataModel
()
.
getData
}
public
class
CampaignItemModel
{
let
index_url
:
String
?
let
logo_url
:
String
?
let
offer_category
:
String
?
let
title
:
String
?
let
subtitle
:
String
?
let
session_uuid
:
String
?
let
subcategory
:
String
?
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
.
title
=
dictionary
[
"title"
]
as?
String
?
??
""
self
.
subtitle
=
dictionary
[
"subtitle"
]
as?
String
?
??
""
self
.
session_uuid
=
dictionary
[
"session_uuid"
]
as?
String
?
??
""
// 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
?
??
""
}
else
{
self
.
subcategory
=
""
print
(
"bad json"
)
}
}
catch
let
error
as
NSError
{
self
.
subcategory
=
""
print
(
error
)
}
}
}
public
class
CampaignDataModel
{
var
data
:
Array
<
CampaignItemModel
>
=
[]
init
()
{
//initializer method
let
instanceOfMyApi
=
MyApi
()
let
products
=
instanceOfMyApi
.
getInbox
()
as
NSMutableArray
?
var
giftsArray
:
Array
<
CampaignItemModel
>
=
[]
for
gift
in
products
??
[]
{
let
tempGift
=
CampaignItemModel
(
dictionary
:
gift
as!
[
String
:
Any
])
giftsArray
.
append
(
tempGift
)
}
self
.
data
=
giftsArray
;
}
var
getData
:
Array
<
CampaignItemModel
>
{
get
{
// getter
return
data
}
}
}
public
func
getCampaigns
()
->
Array
<
CampaignItemModel
>
{
return
CampaignDataModel
()
.
getData
}
}
...
...
Please
register
or
login
to post a comment