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-25 13:16:46 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d87ed8c4ad762da2a0a17c594054287ebd955113
d87ed8c4
1 parent
851ebe00
add getSharingHistoryAsync request
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
254 additions
and
0 deletions
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.h
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.m
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.h
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.m
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.h
View file @
d87ed8c
...
...
@@ -92,6 +92,7 @@
-
(
void
)
postEventAsync
:(
NSString
*
)
Session_ID
:
(
NSString
*
)
OfferAudienceLevel
:
(
NSString
*
)
msisdn
:
(
NSString
*
)
UACIOfferTrackingCode
:
(
NSString
*
)
OFFERCODE1
:
(
NSString
*
)
SCORE
:
(
NSString
*
)
ZONE
:
(
NSString
*
)
WAVE
:
(
NSString
*
)
VALIDITY
:
(
NSString
*
)
TREATMENT_CODE
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getCampaignsAsyncNew
:(
NSString
*
)
language
:
(
NSDictionary
*
)
filters
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getCampaignsPersonalizedAsync
:(
NSString
*
)
language
:
(
NSDictionary
*
)
filters
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
;
-
(
void
)
getSharingHistoryAsync
:(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:(
void
(
^
)(
NSError
*
error
))
failure
;
@end
#endif
/* MyApi_h */
...
...
SwiftWarplyFramework/SwiftWarplyFramework/MyApi.m
View file @
d87ed8c
...
...
@@ -1494,4 +1494,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
-
(
void
)
getSharingHistoryAsync
:
(
void
(
^
)(
NSDictionary
*
response
))
success
failureBlock
:
(
void
(
^
)(
NSError
*
error
))
failure
{
[[
Warply
sharedService
]
getSharingHistoryWithSuccessBlock
:
^
(
NSDictionary
*
response
)
{
if
(
success
)
{
success
(
response
);
}
}
failureBlock
:
^
(
NSError
*
error
)
{
if
(
failure
)
{
failure
(
error
);
}
}];
}
@end
...
...
SwiftWarplyFramework/SwiftWarplyFramework/Warply/Warply.h
View file @
d87ed8c
...
...
@@ -359,6 +359,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 @
d87ed8c
...
...
@@ -1646,6 +1646,47 @@ 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
);
}
NSLog
(
@"**************** WARPLY Response *****************"
);
NSLog
(
@"%@"
,
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
);
}
NSLog
(
@"**************** WARPLY Response *****************"
);
NSLog
(
@"%@"
,
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 Sharing 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 @
d87ed8c
...
...
@@ -3460,4 +3460,201 @@ public class swiftApi {
}
}
public
class
SharingCouponModel
:
Codable
{
// public let transactionMetadata: String?
// public let sharingType: String?
// public let discount: Float
// public let date: Date?
// public let couponsetUuid: String?
// public let name: String?
private
var
couponset_uuid
:
String
?
private
var
date
:
String
?
private
var
discount
:
String
?
private
var
sharing_type
:
String
?
// private var transaction_metadata: String?
private
var
name
:
String
?
private
var
receiver_msisdn
:
String
?
private
var
sender_msisdn
:
String
?
public
init
()
{
self
.
couponset_uuid
=
""
self
.
date
=
""
self
.
discount
=
""
self
.
sharing_type
=
""
// self.transaction_metadata = ""
self
.
name
=
""
self
.
receiver_msisdn
=
""
self
.
sender_msisdn
=
""
}
public
init
(
dictionary
:
[
String
:
Any
])
{
// self.transactionMetadata = dictionary["transaction_metadata"] as? String? ?? ""
// self.sharingType = dictionary["sharing_type"] as? String? ?? ""
// self.discount = dictionary["discount"] as? Float ?? 0.0
// self.couponsetUuid = dictionary["couponsetUuid"] as? String? ?? ""
// self.name = dictionary["name"] as? String? ?? ""
// let dateString = dictionary["date"] as? String? ?? ""
// let dateFormatter = DateFormatter()
// dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
// if let date = dateFormatter.date(from: dateString ?? "") {
// self.date = date
// } else {
// self.date = nil
// }
self
.
couponset_uuid
=
dictionary
[
"couponset_uuid"
]
as?
String
?
??
""
self
.
discount
=
dictionary
[
"discount"
]
as?
String
?
??
""
self
.
sharing_type
=
dictionary
[
"sharing_type"
]
as?
String
?
??
""
// self.transaction_metadata = dictionary["transaction_metadata"] as? String? ?? ""
self
.
name
=
dictionary
[
"name"
]
as?
String
?
??
""
// Example "date": "Thu, Jun 23 2022 16:24:44",
let
dateString
=
dictionary
[
"date"
]
as?
String
?
??
""
let
dateFormatter
=
DateFormatter
()
// dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
dateFormatter
.
dateFormat
=
"E, MMM dd yyyy HH:mm:ss"
if
let
date
=
dateFormatter
.
date
(
from
:
dateString
??
""
)
{
dateFormatter
.
dateFormat
=
"dd/MM/yyyy"
let
resultString
=
dateFormatter
.
string
(
from
:
date
)
self
.
date
=
resultString
}
else
{
self
.
date
=
""
}
let
transaction_metadata_json
=
dictionary
[
"transaction_metadata"
]
as
AnyObject
var
transaction_metadata_parsed
:[
String
:
Any
]
let
json
=
transaction_metadata_json
.
data
(
using
:
String
.
Encoding
.
utf8
.
rawValue
)
do
{
if
let
jsonArray
=
try
JSONSerialization
.
jsonObject
(
with
:
json
!
,
options
:
.
allowFragments
)
as?
[
String
:
AnyObject
]
{
transaction_metadata_parsed
=
jsonArray
;
self
.
receiver_msisdn
=
transaction_metadata_parsed
[
"receiver_msisdn"
]
as?
String
?
??
""
self
.
sender_msisdn
=
transaction_metadata_parsed
[
"sender_msisdn"
]
as?
String
?
??
""
}
else
{
self
.
receiver_msisdn
=
""
self
.
sender_msisdn
=
""
print
(
"bad json"
)
}
}
catch
let
error
as
NSError
{
self
.
receiver_msisdn
=
""
self
.
sender_msisdn
=
""
print
(
error
)
}
}
public
var
_couponset_uuid
:
String
{
get
{
// getter
return
self
.
couponset_uuid
??
""
}
set
(
newValue
)
{
//setter
self
.
couponset_uuid
=
newValue
}
}
public
var
_date
:
String
{
get
{
// getter
return
self
.
date
??
""
}
set
(
newValue
)
{
//setter
self
.
date
=
newValue
}
}
public
var
_discount
:
String
{
get
{
// getter
return
self
.
discount
??
""
}
set
(
newValue
)
{
//setter
self
.
discount
=
newValue
}
}
public
var
_sharing_type
:
String
{
get
{
// getter
return
self
.
sharing_type
??
""
}
set
(
newValue
)
{
//setter
self
.
sharing_type
=
newValue
}
}
public
var
_name
:
String
{
get
{
// getter
return
self
.
name
??
""
}
set
(
newValue
)
{
//setter
self
.
name
=
newValue
}
}
public
var
_receiver_msisdn
:
String
{
get
{
// getter
return
self
.
receiver_msisdn
??
""
}
set
(
newValue
)
{
//setter
self
.
receiver_msisdn
=
newValue
}
}
public
var
_sender_msisdn
:
String
{
get
{
// getter
return
self
.
sender_msisdn
??
""
}
set
(
newValue
)
{
//setter
self
.
sender_msisdn
=
newValue
}
}
}
public
func
getSharingHistoryAsync
(
_
getSharingHistoryCallback
:
@escaping
(
_
sharingHistoryData
:
Array
<
SharingCouponModel
>
?)
->
Void
)
->
Void
{
let
instanceOfMyApi
=
MyApi
()
instanceOfMyApi
.
getSharingHistoryAsync
(
requestCallback
,
failureBlock
:
requestFailureCallback
)
func
requestCallback
(
_
sharingHistoryData
:
[
AnyHashable
:
Any
]?)
->
Void
{
var
historyArray
:
Array
<
SharingCouponModel
>
=
[]
if
let
responseDataDictionary
=
sharingHistoryData
as?
[
String
:
AnyObject
]
{
if
(
responseDataDictionary
[
"status"
]
as?
Int
==
1
)
{
if
let
responseDataResult
=
responseDataDictionary
[
"result"
]
as?
[[
String
:
Any
]?]
{
for
item
in
responseDataResult
{
if
let
itemDictionary
=
item
{
let
tempHistoyItem
=
SharingCouponModel
(
dictionary
:
itemDictionary
)
historyArray
.
append
(
tempHistoyItem
)
}
}
getSharingHistoryCallback
(
historyArray
);
}
else
{
getSharingHistoryCallback
(
nil
)
}
}
else
{
getSharingHistoryCallback
(
nil
)
}
}
else
{
getSharingHistoryCallback
(
nil
)
}
}
func
requestFailureCallback
(
_
error
:
Error
?)
->
Void
{
print
(
"getSharingHistory error: "
)
print
(
error
)
print
(
"===================="
)
getSharingHistoryCallback
(
nil
)
}
}
}
...
...
Please
register
or
login
to post a comment