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
2024-10-22 12:23:24 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
909d88fdb602f13a811a05cd9a548f4f38d1d69b
909d88fd
1 parent
faadac58
add shop_availability key to CouponSetItemModel
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
2 deletions
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
909d88f
...
...
@@ -498,7 +498,42 @@ public class swiftApi {
public
func
getActiveDFYCoupons
()
->
Array
<
ActiveDFYCouponModel
>
{
return
GlobalVariables
.
dfyCoupons
}
public
class
ShopAvailabilityItemModel
:
Codable
{
private
var
merchant_uuid
:
String
?
private
var
product_url
:
String
?
init
()
{
self
.
merchant_uuid
=
""
self
.
product_url
=
""
}
public
init
(
dictionary
:
[
String
:
Any
])
{
self
.
merchant_uuid
=
dictionary
[
"merchant_uuid"
]
as?
String
?
??
""
self
.
product_url
=
dictionary
[
"product_url"
]
as?
String
?
??
""
}
public
var
_merchant_uuid
:
String
{
get
{
// getter
return
self
.
merchant_uuid
??
""
}
set
(
newValue
)
{
//setter
self
.
merchant_uuid
=
newValue
}
}
public
var
_product_url
:
String
{
get
{
// getter
return
self
.
product_url
??
""
}
set
(
newValue
)
{
//setter
self
.
product_url
=
newValue
}
}
}
public
class
CouponSetItemModel
:
Codable
{
public
let
uuid
:
String
?
public
let
admin_name
:
String
?
...
...
@@ -519,6 +554,9 @@ public class swiftApi {
// Universal Coupons
public
let
couponset_type
:
String
?
// PopupMerchantsViewController List
public
let
shop_availability
:
Array
<
ShopAvailabilityItemModel
>
?
public
init
(
dictionary
:
[
String
:
Any
])
{
self
.
uuid
=
dictionary
[
"uuid"
]
as?
String
?
??
""
...
...
@@ -540,7 +578,7 @@ public class swiftApi {
// Universal Coupons
self
.
couponset_type
=
dictionary
[
"couponset_type"
]
as?
String
?
??
""
if
let
double_final_price
=
dictionary
[
"final_price"
]
as?
Double
{
self
.
final_price
=
Float
(
double_final_price
)
}
...
...
@@ -570,6 +608,41 @@ public class swiftApi {
self
.
expiration
=
""
}
// shop_availability Example
// {"shop_availability":"[{\"merchant_uuid\": \"9742752bcf904a269707c40b286e66de\", \"product_url\": \"https://www.ab.gr/el/eshop/Galaktokomika-Fytika-Rofimata-and-Eidi-Psygeioy/Gala-and-Fytika-Rofimata/Fytika-Rofimata/Fytiko-Rofima-Amygdalo-Choris-Prosthiki-Zacharis-1lt/p/7438640\"}]"}
if
let
extra_fields
=
dictionary
[
"extra_fields"
]
as?
[
String
:
Any
]
{
if
let
shopAvailabilityString
=
extra_fields
[
"shop_availability"
]
as?
String
{
// Convert the cleaned string to JSON data
if
let
shopData
=
shopAvailabilityString
.
data
(
using
:
.
utf8
)
{
do
{
// Parse JSON data as an array of dictionaries
if
let
shopArray
=
try
JSONSerialization
.
jsonObject
(
with
:
shopData
,
options
:
[])
as?
[[
String
:
Any
]]
{
var
shopItems
:
Array
<
ShopAvailabilityItemModel
>
=
[]
// Iterate through the shopArray and populate ShopAvailabilityItemModel objects
for
shopDict
in
shopArray
{
let
tempShop
=
ShopAvailabilityItemModel
(
dictionary
:
shopDict
)
shopItems
.
append
(
tempShop
)
}
self
.
shop_availability
=
shopItems
}
else
{
self
.
shop_availability
=
[]
}
}
catch
{
self
.
shop_availability
=
[]
print
(
"Error parsing shop availability:
\(
error
)
"
)
}
}
else
{
self
.
shop_availability
=
[]
}
}
else
{
self
.
shop_availability
=
[]
}
}
else
{
self
.
shop_availability
=
[]
}
}
...
...
Please
register
or
login
to post a comment