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
Dimitris Togias
2022-07-21 02:06:44 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
32be2af1fcb8b13de021a839c6cd1db963de2550
32be2af1
1 parent
4c10621c
add sharig history api call and view controller
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
215 additions
and
81 deletions
SwiftWarplyFramework/SwiftWarplyFramework.xcodeproj/project.pbxproj
SwiftWarplyFramework/SwiftWarplyFramework/AnalysisChildViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/AnalysisItemViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/LoyaltyAnalysisViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.h
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.m
SwiftWarplyFramework/SwiftWarplyFramework/SharingHistoryViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.h
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.m
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework.xcodeproj/project.pbxproj
View file @
32be2af
...
...
@@ -26,6 +26,7 @@
A07936792885EF9400064122 /* RESegmentedControl in Frameworks */ = {isa = PBXBuildFile; productRef = A07936782885EF9400064122 /* RESegmentedControl */; };
A079367C2885F2F500064122 /* AnalysisHeaderViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */; };
A079367E2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */; };
A09DBCAE2888BA8100DD50B0 /* SharingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */; };
E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; };
E6A77854282933340045BBA8 /* SwiftWarplyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; };
E6A778DF282933E60045BBA8 /* WarplyReactMethods.m in Sources */ = {isa = PBXBuildFile; fileRef = E6A7785B282933E40045BBA8 /* WarplyReactMethods.m */; };
...
...
@@ -170,6 +171,7 @@
A07936752885E9CC00064122 /* UIColorExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColorExtensions.swift; sourceTree = "<group>"; };
A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderViewCell.swift; sourceTree = "<group>"; };
A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderMessageViewCell.swift; sourceTree = "<group>"; };
A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharingHistoryViewController.swift; sourceTree = "<group>"; };
A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; };
B9EB8A451EF0C5AD75094EEE /* Pods-SwiftWarplyFramework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.release.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.release.xcconfig"; sourceTree = "<group>"; };
C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftWarplyFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; };
...
...
@@ -331,6 +333,7 @@
A079367A2885F2D100064122 /* cells */,
1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */,
A079366D2885D07700064122 /* AnalysisChildViewController.swift */,
A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */,
);
name = analysis;
sourceTree = "<group>";
...
...
@@ -837,6 +840,7 @@
E6A7794B282933E70045BBA8 /* FMDatabase.m in Sources */,
E6A778EC282933E60045BBA8 /* WLNativeVideoTableViewCell.m in Sources */,
E6A77954282933E70045BBA8 /* MyApi.m in Sources */,
A09DBCAE2888BA8100DD50B0 /* SharingHistoryViewController.swift in Sources */,
E6A778F2282933E60045BBA8 /* WLNativeAdCollectionViewCell.m in Sources */,
E6A77904282933E60045BBA8 /* WLEvent.m in Sources */,
E6A77927282933E70045BBA8 /* UIRefreshControl+AFNetworking.m in Sources */,
...
...
SwiftWarplyFramework/SwiftWarplyFramework/AnalysisChildViewController.swift
View file @
32be2af
...
...
@@ -10,78 +10,4 @@ import UIKit
class
AnalysisChildViewController
:
UITableViewController
{
public
var
index
:
Int
=
-
1
var
items
:
Array
<
AnalysisItem
>
=
Array
()
// TODO: remove this when configuring model
let
hasMessage
=
true
// lifecycle
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
self
.
refreshControl
=
UIRefreshControl
()
self
.
refreshControl
?
.
addTarget
(
self
,
action
:
#selector(
handleRefresh(_:)
)
,
for
:
.
valueChanged
)
loadData
()
}
// mvp
private
func
loadData
()
{
self
.
items
=
Array
()
}
private
func
showLoading
()
{
}
private
func
showError
()
{
}
private
func
showContent
()
{
}
// private
@objc
func
handleRefresh
(
_
refreshControl
:
UIRefreshControl
)
{
loadData
()
}
// MARK: - Table view data source
override
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
return
2
}
override
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
if
(
section
==
0
)
{
return
1
;
}
return
items
.
count
}
override
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
if
(
indexPath
.
section
==
0
)
{
return
hasMessage
?
380.0
:
280
}
return
160.0
}
override
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
// header
if
(
indexPath
.
section
==
0
)
{
if
(
hasMessage
)
{
return
tableView
.
dequeueReusableCell
(
withIdentifier
:
"AnalysisHeaderMessageViewCell"
,
for
:
indexPath
)
as!
AnalysisHeaderMessageViewCell
}
return
tableView
.
dequeueReusableCell
(
withIdentifier
:
"AnalysisHeaderViewCell"
,
for
:
indexPath
)
as!
AnalysisHeaderViewCell
}
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"AnalysisItemViewCell"
,
for
:
indexPath
)
as!
AnalysisItemViewCell
cell
.
configureCell
(
item
:
items
[
indexPath
.
row
])
return
cell
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/AnalysisItemViewCell.swift
View file @
32be2af
...
...
@@ -34,17 +34,17 @@ class AnalysisItemViewCell: UITableViewCell {
}
extension
AnalysisItemViewCell
{
func
configureCell
(
item
:
AnalysisItem
)
{
func
configureCell
(
item
:
swiftApi
.
SharingCouponModel
)
{
// TODO: this is not optimal. we need a static date formatter. we cannot instantiate a new object each time we render a new item.
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"dd-MM-yyyy"
dateLabel
.
text
=
dateFormatter
.
string
(
from
:
item
.
date
)
//
dateLabel.text = dateFormatter.string(from: item.date)
//itemImage.image =
titleLabel
.
text
=
item
.
titl
e
priceLabel
.
text
=
String
(
format
:
"%.2f€"
,
item
.
price
)
subtitleLabel
.
text
=
item
.
subtitle
// titleLabel.text = item.nam
e
// priceLabel.text = String(format: "%.2f€", item.discount
)
//
subtitleLabel.text = item.subtitle
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/LoyaltyAnalysisViewController.swift
View file @
32be2af
...
...
@@ -29,7 +29,7 @@ import RESegmentedControl
return
titles
.
map
({
SegmentModel
(
title
:
$0
)
})
}
let
preset
=
BootstapPreset
(
backgroundColor
:
.
white
,
selectedBackgroundColor
:
.
white
,
border
)
let
preset
=
BootstapPreset
(
backgroundColor
:
.
white
,
selectedBackgroundColor
:
.
white
)
tabView
.
configure
(
segmentItems
:
segmentItems
,
preset
:
preset
)
// pages
...
...
@@ -46,6 +46,13 @@ import RESegmentedControl
////////////////////////////////////////////////////////////////////////////////
private
func
viewControllerAt
(
_
index
:
Int
)
->
AnalysisChildViewController
?
{
if
(
index
==
1
)
{
let
analysisVC
=
SharingHistoryViewController
()
analysisVC
.
index
=
index
;
return
analysisVC
;
}
let
analysisVC
=
AnalysisChildViewController
()
analysisVC
.
index
=
index
;
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.h
View file @
32be2af
...
...
@@ -63,6 +63,7 @@
-
(
NSDictionary
*
)
getCoupons
;
-
(
NSDictionary
*
)
getTransactionHistory
;
-
(
NSDictionary
*
)
getPointsHistory
;
-
(
NSDictionary
*
)
getSharingHistory
;
-
(
NSDictionary
*
)
addAddress
:(
NSString
*
)
friendlyName
andAddressName
:(
NSString
*
)
addressName
andAddressNumber
:(
NSString
*
)
addressNumber
andPostalCode
:(
NSString
*
)
postalCode
andFloorNumber
:(
NSNumber
*
)
floorNumber
andDoorbell
:(
NSString
*
)
doorbel
andRegion
:(
NSString
*
)
region
andLatitude
:(
NSString
*
)
latitude
andLongitude
:(
NSString
*
)
longitude
andNotes
:(
NSString
*
)
notes
;
-
(
NSDictionary
*
)
getAddress
;
-
(
NSDictionary
*
)
editAddress
:(
NSString
*
)
friendlyName
andAddressName
:(
NSString
*
)
addressName
andAddressNumber
:(
NSString
*
)
addressNumber
andPostalCode
:(
NSString
*
)
postalCode
andFloorNumber
:(
NSNumber
*
)
floorNumber
andDoorbell
:(
NSString
*
)
doorbel
andRegion
:(
NSString
*
)
region
andLatitude
:(
NSString
*
)
latitude
andLongitude
:(
NSString
*
)
longitude
andNotes
:(
NSString
*
)
notes
andUuid
:(
NSString
*
)
uuid
;
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.m
View file @
32be2af
...
...
@@ -940,6 +940,35 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
return
resp
;
}
-
(
NSDictionary
*
)
getSharingHistory
{
__block
NSDictionary
*
resp
=
[
NSDictionary
alloc
];
__block
BOOL
isRunLoopNested
=
NO
;
__block
BOOL
isOperationCompleted
=
NO
;
[[
Warply
sharedService
]
getSharingHistoryWithSuccessBlock
:
^
(
NSDictionary
*
response
)
{
resp
=
response
;
isOperationCompleted
=
YES
;
if
(
isRunLoopNested
)
{
CFRunLoopStop
(
CFRunLoopGetCurrent
());
// CFRunLoopRun() returns
}
}
failureBlock
:
^
(
NSError
*
error
)
{
NSLog
(
@"%@"
,
error
);
resp
=
nil
;
isOperationCompleted
=
YES
;
if
(
isRunLoopNested
)
{
CFRunLoopStop
(
CFRunLoopGetCurrent
());
// CFRunLoopRun() returns
}
}];
if
(
!
isOperationCompleted
)
{
isRunLoopNested
=
YES
;
NSLog
(
@"Waiting..."
);
CFRunLoopRun
();
// Magic!
isRunLoopNested
=
NO
;
}
return
resp
;
}
-
(
NSDictionary
*
)
addAddress
:
(
NSString
*
)
friendlyName
andAddressName
:
(
NSString
*
)
addressName
andAddressNumber
:
(
NSString
*
)
addressNumber
andPostalCode
:
(
NSString
*
)
postalCode
andFloorNumber
:
(
NSNumber
*
)
floorNumber
andDoorbell
:
(
NSString
*
)
doorbel
andRegion
:
(
NSString
*
)
region
andLatitude
:
(
NSString
*
)
latitude
andLongitude
:
(
NSString
*
)
longitude
andNotes
:
(
NSString
*
)
notes
{
__block
NSDictionary
*
resp
=
[
NSDictionary
alloc
];
__block
BOOL
isRunLoopNested
=
NO
;
...
...
SwiftWarplyFramework/SwiftWarplyFramework/SharingHistoryViewController.swift
0 → 100644
View file @
32be2af
//
// SharingHistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import
UIKit
class
SharingHistoryViewController
:
AnalysisChildViewController
{
var
loading
:
Bool
=
false
var
items
:
Array
<
swiftApi
.
SharingCouponModel
>
=
Array
()
// TODO: remove this when configuring model
let
hasMessage
=
true
// lifecycle
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
self
.
refreshControl
=
UIRefreshControl
()
self
.
refreshControl
?
.
addTarget
(
self
,
action
:
#selector(
handleRefresh(_:)
)
,
for
:
.
valueChanged
)
handleRefresh
(
self
.
refreshControl
!
)
}
// mvp
@objc
func
load
()
{
if
(
loading
)
{
return
;
}
showLoading
()
// TODO: Implement API call
}
private
func
showLoading
()
{
loading
=
true
if
(
self
.
refreshControl
!.
isRefreshing
)
{
return
;
}
self
.
refreshControl
!.
beginRefreshing
()
}
private
func
showError
()
{
}
private
func
showContent
()
{
loading
=
true
self
.
refreshControl
!.
endRefreshing
()
}
// private
func
responseCallback
(
_
data
:
Array
<
swiftApi
.
SharingCouponModel
>
?)
->
Void
{
self
.
items
=
data
!
showContent
()
DispatchQueue
.
main
.
async
{
self
.
tableView
.
reloadData
()
}
}
@objc
func
handleRefresh
(
_
refreshControl
:
UIRefreshControl
)
{
self
.
perform
(
_
:
#selector(
load
)
,
with
:
nil
,
afterDelay
:
0.5
)
}
// MARK: - Table view data source
override
func
numberOfSections
(
in
tableView
:
UITableView
)
->
Int
{
return
2
}
override
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
if
(
section
==
0
)
{
return
1
;
}
return
items
.
count
}
override
func
tableView
(
_
tableView
:
UITableView
,
heightForRowAt
indexPath
:
IndexPath
)
->
CGFloat
{
if
(
indexPath
.
section
==
0
)
{
return
hasMessage
?
380.0
:
280
}
return
160.0
}
override
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
// header
if
(
indexPath
.
section
==
0
)
{
if
(
hasMessage
)
{
return
tableView
.
dequeueReusableCell
(
withIdentifier
:
"AnalysisHeaderMessageViewCell"
,
for
:
indexPath
)
as!
AnalysisHeaderMessageViewCell
}
return
tableView
.
dequeueReusableCell
(
withIdentifier
:
"AnalysisHeaderViewCell"
,
for
:
indexPath
)
as!
AnalysisHeaderViewCell
}
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"AnalysisItemViewCell"
,
for
:
indexPath
)
as!
AnalysisItemViewCell
cell
.
configureCell
(
item
:
items
[
indexPath
.
row
])
return
cell
}
}
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.h
View file @
32be2af
...
...
@@ -352,6 +352,8 @@ WL_VERSION_INTERFACE()
-
(
void
)
getPointsHistoryWithSuccessBlock
:(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getSharingHistoryWithSuccessBlock
:(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
verifyTicketWithSuccessBlock
:(
NSString
*
)
guid
:
(
NSString
*
)
ticket
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getCosmoteUserWithSuccessBlock
:(
NSString
*
)
guid
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.m
View file @
32be2af
...
...
@@ -1518,6 +1518,43 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
}];
}
-
(
void
)
getSharingHistoryWithSuccessBlock
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
NSDictionary
*
postDictionary
=
@{
@"coupon"
:
@{
@"action"
:
@"sharing_history"
}};
NSData
*
jsonData
=
[
NSJSONSerialization
dataWithJSONObject
:
postDictionary
options
:
0
error
:
NULL
];
[
self
sendContext8
:
jsonData
successBlock
:
^
(
NSDictionary
*
contextResponse
)
{
if
(
success
)
{
success
(
contextResponse
);
}
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
NSDictionary
*
dict
=
[
NSDictionary
alloc
];
dict
=
[
error
userInfo
];
NSString
*
errorCode
=
[
dict
objectForKey
:
@"NSLocalizedDescription"
];
if
([
errorCode
isEqual
:
@"Request failed: unauthorized (401)"
])
{
[
self
refreshToken
:
^
(
NSDictionary
*
response
)
{
[
self
sendContext8
:
jsonData
successBlock
:
^
(
NSDictionary
*
contextResponse
)
{
if
(
success
)
{
success
(
contextResponse
);
}
}
failureBlock
:^
(
NSError
*
error
)
{
if
(
failure
)
{
failure
(
error
);
}
}];
}
failureBlock
:
^
(
NSError
*
error
)
{
if
(
failure
)
{
[
_db
executeUpdate
:
@"DROP TABLE requestVariables"
];
failure
(
error
);
}
NSLog
(
@"Error at token %@"
,
error
);
}];
}
NSLog
(
@"Error at get points history %@"
,
error
);
}
}];
}
-
(
void
)
addAddressWithSuccessBlock
:
(
NSString
*
)
friendlyName
:
(
NSString
*
)
addressName
:
(
NSString
*
)
addressNumber
:
(
NSString
*
)
postalCode
:
(
NSNumber
*
)
floorNumber
:
(
NSString
*
)
doorbel
:
(
NSString
*
)
region
:
(
NSString
*
)
latitude
:
(
NSString
*
)
longitude
:
(
NSString
*
)
notes
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
NSDictionary
*
postDictionary
=
@{
@"consumer_data"
:
@{
@"action"
:
@"handle_addresses_new"
,
@"process"
:
@"add"
,
@"data"
:
@{
@"friendly_name"
:
friendlyName
,
@"address_name"
:
addressName
,
@"address_number"
:
addressNumber
,
@"postal_code"
:
postalCode
,
@"floor_number"
:
floorNumber
,
@"doorbel"
:
doorbel
,
@"region"
:
region
,
@"latitude"
:
latitude
,
@"longitude"
:
longitude
,
@"notes"
:
notes
}}};
...
...
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
32be2af
...
...
@@ -154,7 +154,6 @@ public class swiftApi {
public
func
getActiveDFYCoupons
()
->
Array
<
ActiveDFYCouponModel
>
{
return
GlobalVariables
.
dfyCoupons
}
public
class
CouponSetItemModel
:
Codable
{
public
let
uuid
:
String
?
...
...
@@ -455,6 +454,24 @@ public class swiftApi {
}
public
class
SharingCouponModel
:
Codable
{
public
let
transactionMetadata
:
String
?
public
let
sharingType
:
String
?
public
let
discount
:
String
?
public
let
date
:
String
?
public
let
couponsetUuid
:
String
?
public
let
name
:
String
?
public
init
(
dictionary
:
[
String
:
Any
])
{
self
.
transactionMetadata
=
dictionary
[
"transaction_metadata"
]
as?
String
?
??
""
self
.
sharingType
=
dictionary
[
"sharing_type"
]
as?
String
?
??
""
self
.
discount
=
dictionary
[
"discount"
]
as?
String
?
??
""
self
.
date
=
dictionary
[
"date"
]
as?
String
?
??
""
self
.
couponsetUuid
=
dictionary
[
"couponsetUuid"
]
as?
String
?
??
""
self
.
name
=
dictionary
[
"name"
]
as?
String
?
??
""
}
}
public
func
filterActiveCoupons
(
_
coupons
:
Array
<
CouponItemModel
>
)
->
Array
<
CouponItemModel
>
{
return
coupons
.
filter
({
...
...
Please
register
or
login
to post a comment