Manos Chorianopoulos

add share coupon ui and functionality

......@@ -11,6 +11,9 @@
1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */; };
1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; };
1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */; };
1EB236AB28816B680063777A /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AA28816B680063777A /* ShareViewController.swift */; };
1EB236AD28816C560063777A /* NumberPopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AC28816C560063777A /* NumberPopupViewController.swift */; };
1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */; };
1EB5F4C828536FD60016F36E /* StepsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C728536FD60016F36E /* StepsViewController.swift */; };
1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */; };
1EBE97212865EE460080EFF7 /* MFYInboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */; };
......@@ -148,6 +151,9 @@
1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewController.swift; sourceTree = "<group>"; };
1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; };
1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxTableViewCell.swift; sourceTree = "<group>"; };
1EB236AA28816B680063777A /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
1EB236AC28816C560063777A /* NumberPopupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberPopupViewController.swift; sourceTree = "<group>"; };
1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumbersTableViewCell.swift; sourceTree = "<group>"; };
1EB5F4C728536FD60016F36E /* StepsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsViewController.swift; sourceTree = "<group>"; };
1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoyaltyAnalysisViewController.swift; sourceTree = "<group>"; };
1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFYInboxTableViewCell.swift; sourceTree = "<group>"; };
......@@ -350,6 +356,9 @@
E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */,
E6A7785A282933E40045BBA8 /* Helpers */,
E6A77861282933E50045BBA8 /* Main.storyboard */,
1EB236AA28816B680063777A /* ShareViewController.swift */,
1EB236AC28816C560063777A /* NumberPopupViewController.swift */,
1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */,
1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */,
1EB5F4C728536FD60016F36E /* StepsViewController.swift */,
E6A77860282933E40045BBA8 /* MyApi.h */,
......@@ -803,6 +812,7 @@
E6A77A36282BB4CB0045BBA8 /* MakeItAPresentViewController.swift in Sources */,
E6A77947282933E70045BBA8 /* FMDatabaseQueue.m in Sources */,
E6A77922282933E60045BBA8 /* NSData+SSToolkitAdditions.m in Sources */,
1EB236AB28816B680063777A /* ShareViewController.swift in Sources */,
E6A778E7282933E60045BBA8 /* DetailsViewController.swift in Sources */,
1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */,
E6A7794A282933E70045BBA8 /* FMDatabaseAdditions.m in Sources */,
......@@ -816,7 +826,9 @@
E6A77924282933E70045BBA8 /* NSString+SSToolkitAdditions.m in Sources */,
E6A7792A282933E70045BBA8 /* AFNetworkActivityIndicatorManager.m in Sources */,
E6A77914282933E60045BBA8 /* WLUserManager.m in Sources */,
1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */,
E6A7794F282933E70045BBA8 /* FMDatabasePool.m in Sources */,
1EB236AD28816C560063777A /* NumberPopupViewController.swift in Sources */,
E6A778E3282933E60045BBA8 /* WalletViewController.swift in Sources */,
E6A7790C282933E60045BBA8 /* WLBeaconManager.m in Sources */,
E6A77940282933E70045BBA8 /* AFURLSessionManager.m in Sources */,
......
......@@ -164,25 +164,10 @@ import AVFoundation
// MARK: - Actions
@IBAction func redeemButtomAction(_ sender: Any) {
// TODO: Add redeem action
// SwiftEventBus.post("couponBarcodeRedeem", sender: coupon)
let alert = UIAlertController(title: "Το κουπόνι σου ενεργοποιήθηκε", message: "Μπορείς να το βρεις στην αρχική οθόνη της εφαρμογής και στην ενότητα ενεργά δώρα!", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "ShareViewController") as! SwiftWarplyFramework.ShareViewController
vc.coupon = self.coupon
self.navigationController?.pushViewController(vc, animated: true)
}
@IBAction func termsButtonAction(_ sender: Any) {
......
{
"images" : [
{
"filename" : "ic_close.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_close-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_close-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -87,6 +87,7 @@
- (void)cosmoteSharingAsync:(NSString*)sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)cosmoteRetrieveSharingAsync:(NSString*)sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCosmoteUserAsync:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)cosmoteCouponSharingAsync:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
@end
#endif /* MyApi_h */
......
......@@ -1431,4 +1431,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)cosmoteCouponSharingAsync:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] cosmoteCouponSharingWithSuccessBlock:coupon :sender :receiver :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
@end
......
//
// NumberPopupViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 15/7/22.
//
import UIKit
protocol NumbersPopupDelegate {
func numbersPopupTapped(_ sender: Any)
func presentedPopup()
func dismissedPopup()
func optionSelected(_ option: String)
}
@objc public class NumberPopupViewController: UIViewController, UIPopoverPresentationControllerDelegate {
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var headerLabel: UILabel!
@IBOutlet weak var closeButton: UIButton!
@IBOutlet weak var tableView: UITableView!
let uiscreen: CGRect = UIScreen.main.bounds
var delegateBallon: NumbersPopupDelegate?
var numbersList: Array<String> = []
var widthPopup: Int = 0
var heightPopup: Int = 0
func InitWithController(controller: UIViewController, numbersList: Array<String>, sender: Any, delegate: NumbersPopupDelegate){
//print("Ok InitWithController sender ")
delegateBallon = delegate
// set the presentation style
self.modalPresentationStyle = UIModalPresentationStyle.popover
// set up the popover presentation controller
// self.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up
self.popoverPresentationController?.delegate = self
self.popoverPresentationController?.sourceView = (sender as! UIView ) // button
//--- Better center of the arrow
// let rect: CGRect = (sender as AnyObject).bounds
// let rectFixed: CGRect = CGRect(x: rect.origin.x, y: rect.origin.y, width: rect.size.width-10, height: rect.size.height)
// self.popoverPresentationController?.sourceRect = rectFixed
self.popoverPresentationController?.backgroundColor = UIColor.clear
// self.popoverPresentationController?.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 0.58)
DispatchQueue.main.async {
// present the popover
controller.present(self, animated: true, completion: nil)
}
self.numbersList = numbersList
}
public override func viewWillAppear(_ animated: Bool) {
// self.SetInfoText(t: infoText ?? "")
}
public override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// setupScreens()
tableView.delegate = self
tableView.dataSource = self
popupView.clipsToBounds = true
popupView.layer.cornerRadius = 12
popupView.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, right corner radius
self.preferredContentSize = CGSize(width: widthPopup, height: heightPopup)
closeButton.setImage(UIImage(named: "ic_close.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
closeButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
// self.tableView.reloadData()
self.tableView.invalidateIntrinsicContentSize()
}
func setupScreens() {
// if UIDevice.current.userInterfaceIdiom == .pad {
// // Do what you want
// widthPopup = 450
// heightPopup = 550
// textView.font = UIFont(name: Fonts.ProximaNova.semibold, size: 20)
// } else if UIDevice.current.userInterfaceIdiom == .phone {
// // Do what you want
// widthPopup = 250
// heightPopup = 360
// textView.font = UIFont(name: Fonts.ProximaNova.semibold, size: 14)
// }
}
public override func viewDidAppear(_ animated: Bool) {
delegateBallon?.presentedPopup()
}
public override func viewDidDisappear(_ animated: Bool) {
delegateBallon?.dismissedPopup()
}
// func SetInfoText(t: String){
// infoTextView.text = t
// infoTextView.scrollRangeToVisible(NSRange(location:0, length:0))
// }
public override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
public override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
//print("In prepare")
}
public func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.fullScreen
}
public func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return UIModalPresentationStyle.fullScreen
// return UIModalPresentationStyle.none
}
// MARK: - UIButton Action
@IBAction func closeButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {
})
}
}
// MARK: - TableView
extension NumberPopupViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.numbersList.count
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 50 //+ 30.0
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "NumbersTableViewCellId", for: indexPath) as! NumbersTableViewCell
let isLast = indexPath.row == (self.numbersList.count - 1)
cell.configureCell(number: numbersList[indexPath.row], isLast: isLast)
return cell
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
delegateBallon?.optionSelected(self.numbersList[indexPath.row])
self.dismiss(animated: true, completion: {})
// Logs
// let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
// print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? ""))
// print("Coupon Name clicked: " + (couponSetData?.name ?? ""))
// print("Coupon Description clicked: " + (couponSetData?.short_description ?? ""))
// print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? ""))
//
// let storyboard = UIStoryboard(name: "Main", bundle: nil)
// let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! CouponBarcodeViewController
// vc.coupon = coupons[indexPath.row]
// self.navigationController?.pushViewController(vc, animated: true)
}
}
// Class for dynamic height table view
@objc public class DynamicSizeTableView: UITableView
{
override public func layoutSubviews() {
super.layoutSubviews()
if bounds.size != intrinsicContentSize {
invalidateIntrinsicContentSize()
}
}
override public var intrinsicContentSize: CGSize {
return contentSize
}
}
//
// NumbersTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 15/7/22.
//
import UIKit
@objc public class NumbersTableViewCell: UITableViewCell {
@IBOutlet weak var numberLabel: UILabel!
@IBOutlet weak var borderView: UIView!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
// override func layoutSubviews() {
// super.layoutSubviews()
//
// //set the values for top,left,bottom,right margins
// let margins = UIEdgeInsets(top: 0, left: 0, bottom: 30, right: 0)
// contentView.frame = contentView.frame.inset(by: margins)
// }
func configureCell(number: String, isLast: Bool) {
numberLabel.text = number
if (isLast) {
borderView.isHidden = true
} else {
borderView.isHidden = false
}
}
}
//
// ShareViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 15/7/22.
//
import UIKit
@objc public class ShareViewController: UIViewController, UITextFieldDelegate, UIPopoverControllerDelegate {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var mainViewBottom: NSLayoutConstraint!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var scrollContentView: UIView!
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var couponImageHeight: NSLayoutConstraint!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
@IBOutlet weak var senderLabel: UILabel!
@IBOutlet weak var senderArrowImage: UIImageView!
@IBOutlet weak var senderButton: UIButton!
@IBOutlet weak var numberTextField: UITextField!
@IBOutlet weak var redeemButton: UIButton!
let uiscreen: CGRect = UIScreen.main.bounds
public var coupon: swiftApi.CouponItemModel?
var selectedNumber: String = ""
var numbersList: Array<String> = []
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
NotificationCenter.default.addObserver(self,
selector: #selector(self.keyboardNotification(notification:)),
name: UIResponder.keyboardWillChangeFrameNotification,
object: nil)
self.setupToHideKeyboardOnTapOnView()
numberTextField.delegate = self
getProfileRequest()
// Do any additional setup after loading the view.
setBackButton()
setNavigationTitle("Κάντο δώρο!")
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
scrollView.clipsToBounds = true
scrollView.layer.cornerRadius = 30
scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
// COUPONSET: desc, img_preview, name, terms
// COUPON: coupon, expiration, discount, status
let couponSetData: swiftApi.CouponSetItemModel? = coupon?.couponset_data
couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
couponImage.contentMode = .scaleAspectFill
couponImageHeight.constant = self.uiscreen.height * 0.25
nameLabel.text = couponSetData?.name ?? ""
descriptionLabel.text = couponSetData?.short_description ?? ""
senderLabel.text = "Αποστολέας"
senderArrowImage.image = UIImage(named: "ic_down_dark", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
senderButton.addTarget(self, action: #selector(self.numbersPopupTapped(_:)), for: .touchUpInside)
numberTextField.font = UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.medium)
numberTextField.textColor = UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00)
numberTextField.attributedPlaceholder = NSAttributedString(string: "Καταχώρηση τηλεφώνου", attributes: [NSAttributedString.Key.foregroundColor: UIColor(red: 0.68, green: 0.68, blue: 0.68, alpha: 1.00)])
numberTextField.keyboardType = .asciiCapableNumberPad
redeemButton.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .semibold)
redeemButton.setTitle("Αποστολή με SMS", for: .normal)
redeemButton.setTitleColor(.white, for: .normal)
redeemButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00)
redeemButton.layer.cornerRadius = 12.0
}
deinit {
NotificationCenter.default.removeObserver(self)
}
@objc func keyboardNotification(notification: NSNotification) {
guard let userInfo = notification.userInfo else { return }
let endFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue
let endFrameY = endFrame?.origin.y ?? 0
let duration:TimeInterval = (userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0
let animationCurveRawNSN = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber
let animationCurveRaw = animationCurveRawNSN?.uintValue ?? UIView.AnimationOptions.curveEaseInOut.rawValue
let animationCurve:UIView.AnimationOptions = UIView.AnimationOptions(rawValue: animationCurveRaw)
if endFrameY >= UIScreen.main.bounds.size.height {
self.mainViewBottom?.constant = 0.0
} else {
self.mainViewBottom?.constant = endFrame?.size.height ?? 0.0
}
UIView.animate(
withDuration: duration,
delay: TimeInterval(0),
options: animationCurve,
animations: { self.view.layoutIfNeeded() },
completion: nil)
}
// MARK: - Functions
func showSendDialog() -> Void {
let alert = UIAlertController(title: "Στείλε δώρο", message: "Είσαι σίγουρος ότι θέλεις να κάνεις δώρο το κουπόνι σου;", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Αποστολή", style: .default, handler: { action in
switch action.style{
case .default:
self.cosmoteCouponSharingRequest()
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
alert.addAction(UIAlertAction(title: "Άκυρο", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
// MARK: - API Calls
func getProfileRequest() {
swiftApi().getProfileAsync(getProfileCallback)
}
func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
if (profileData != nil) {
DispatchQueue.main.async {
self.numbersList = profileData?.msisdnList ?? []
print("========= getProfileRequest SUCCESSSS =========")
}
} else {
print("========= getProfileRequest ERROR =========")
}
}
func cosmoteCouponSharingRequest() {
swiftApi().cosmoteCouponSharingAsync(coupon: coupon?.coupon ?? "", sender: selectedNumber, receiver: numberTextField.text ?? "", couponSharingCallback)
}
func couponSharingCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
self.showDialog("Συγχαρητήρια!","Μόλις έκανες δώρο ένα κουπόνι!")
// swiftApi().getCouponsAsync(getCouponsCallback)
//
// func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
// if (couponsData != nil) {
//
// DispatchQueue.main.async {
// print("========= getCouponsRequest SUCCESSSS CouponViewController =========")
// }
// } else {
// print("========= getCouponsRequest ERROR CouponViewController =========")
// }
// }
} else {
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
} else {
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
// MARK: - Actions
@IBAction func redeemButtomAction(_ sender: Any) {
if (selectedNumber == "" || numberTextField.text == "") {
self.showDialog("Αποτυχία","Τα πεδία δεν είναι σωστά")
} else {
self.showSendDialog()
}
}
}
// MARK: NumbersPopup
extension ShareViewController: NumbersPopupDelegate {
@objc func numbersPopupTapped(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// self.storyboard?
let pp = storyboard.instantiateViewController(withIdentifier: "NumberPopupViewController") as! SwiftWarplyFramework.NumberPopupViewController
pp.InitWithController(controller: self,
numbersList: self.numbersList,
sender: sender,
delegate: self)
}
func presentedPopup() {
// Code for when popup is presented
}
func dismissedPopup() {
// Code for when popup is dismissed
}
func optionSelected(_ option: String) {
// Code for when option is selected
selectedNumber = option
senderLabel.text = option
}
}
......@@ -378,6 +378,8 @@ WL_VERSION_INTERFACE()
- (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) cosmoteCouponSharingWithSuccessBlock:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) cosmoteSharingWithSuccessBlock:(NSString*) sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) cosmoteRetrieveSharingWithSuccessBlock:(NSString*) sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
......@@ -1949,7 +1949,48 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
NSLog(@"Error at token %@", error );
}];
}
NSLog(@"Error at get coupon sets %@", error );
NSLog(@"Error at redeem coupon sets %@", error );
}
}];
}
- (void) cosmoteCouponSharingWithSuccessBlock:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
NSDictionary *postDictionary = @{@"coupon": @{@"action": @"share", @"coupon": coupon, @"sender_msisdn": sender, @"receiver_msisdn": receiver}};
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 cosmote Coupon Sharing %@", error );
}
}];
}
......
......@@ -1215,6 +1215,9 @@ public class swiftApi {
let profileDataResult = (profileDataDictionary["result"] as? [String: Any] ?? ["":""])
let tempProfile = ProfileModel(dictionary: profileDataResult)
swiftApi().setConsumer(tempProfile ?? swiftApi.ProfileModel())
swiftApi().setUserTag(tempProfile.badge ?? "")
getProfileCallback(tempProfile);
......@@ -3034,4 +3037,32 @@ public class swiftApi {
}
}
public func cosmoteCouponSharingAsync(coupon: String, sender: String, receiver: String, _ couponSharingCallback: @escaping (_ responseData: GenericResponseModel?) -> Void) -> Void {
let instanceOfMyApi = MyApi()
instanceOfMyApi.cosmoteCouponSharingAsync(coupon, sender, receiver, requestCallback, failureBlock: requestFailureCallback)
func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void {
if let responseDataDictionary = responseData as? [String: Any] {
let tempResponse = GenericResponseModel(dictionary: responseDataDictionary)
couponSharingCallback(tempResponse);
} else {
couponSharingCallback(nil)
}
}
func requestFailureCallback(_ error: Error?) -> Void {
print("cosmoteCouponSharing error: ")
print(error)
print("====================")
couponSharingCallback(nil)
}
}
}
......