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-04-29 12:26:27 +0300
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
04d9cdfea49af652e333c7cea7bb0d540549a0ea
04d9cdfe
2 parents
80c3a6f1
a2cc38b5
Merge branch 'master' of
https://git.warp.ly/open-source/warply_sdk_framework
Show 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 @
04d9cdf
No preview for this file type
WarplySDKFrameworkIOS/WarplySDKFrameworkIOS/swiftApi.swift
View file @
04d9cdf
...
...
@@ -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