Showing
1 changed file
with
117 additions
and
7 deletions
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | 7 | ||
8 | import UIKit | 8 | import UIKit |
9 | 9 | ||
10 | -@objc public class TelcoViewController: UIViewController { | 10 | +@objc public class TelcoViewController: UIViewController, UIPopoverControllerDelegate { |
11 | @IBOutlet weak var mainView: UIView! | 11 | @IBOutlet weak var mainView: UIView! |
12 | @IBOutlet weak var scrollView: UIScrollView! | 12 | @IBOutlet weak var scrollView: UIScrollView! |
13 | @IBOutlet weak var scrollContentView: UIView! | 13 | @IBOutlet weak var scrollContentView: UIView! |
... | @@ -21,14 +21,18 @@ import UIKit | ... | @@ -21,14 +21,18 @@ import UIKit |
21 | 21 | ||
22 | public var ccms: swiftApi.LoyaltyContextualOfferModel? | 22 | public var ccms: swiftApi.LoyaltyContextualOfferModel? |
23 | public var campaign: swiftApi.CampaignItemModel? | 23 | public var campaign: swiftApi.CampaignItemModel? |
24 | + var selectedNumber: String = "" | ||
25 | + public var numbersList: Array<String> = [] | ||
24 | 26 | ||
25 | public override func viewDidLoad() { | 27 | public override func viewDidLoad() { |
26 | 28 | ||
27 | super.viewDidLoad() | 29 | super.viewDidLoad() |
28 | 30 | ||
29 | self.hidesBottomBarWhenPushed = true | 31 | self.hidesBottomBarWhenPushed = true |
30 | - | 32 | + |
31 | // Do any additional setup after loading the view. | 33 | // Do any additional setup after loading the view. |
34 | + getProfileRequest() | ||
35 | + | ||
32 | setBackButton() | 36 | setBackButton() |
33 | setNavigationTitle("Ενεργοποίηση") | 37 | setNavigationTitle("Ενεργοποίηση") |
34 | 38 | ||
... | @@ -50,16 +54,122 @@ import UIKit | ... | @@ -50,16 +54,122 @@ import UIKit |
50 | } | 54 | } |
51 | 55 | ||
52 | // MARK: - Functions | 56 | // MARK: - Functions |
53 | - func activateSetRequest(uuid: String) { | 57 | + func showConfirmDialog() -> Void { |
54 | - assertionFailure("to be implemented") | 58 | + |
59 | + let alert = UIAlertController(title: "Ενεργοποίηση υπηρεσίας", message: "Θέλετε να γίνει ενεργοποίηση στο Κινητό μου;", preferredStyle: .alert) | ||
60 | + alert.addAction(UIAlertAction(title: "Ενεργοποίηση", style: .default, handler: { action in | ||
61 | + switch action.style{ | ||
62 | + case .default: | ||
63 | + self.submitOrderRequest() | ||
64 | + | ||
65 | + case .cancel: | ||
66 | + print("cancel") | ||
67 | + | ||
68 | + case .destructive: | ||
69 | + print("destructive") | ||
70 | + | ||
71 | + } | ||
72 | + })) | ||
73 | + alert.addAction(UIAlertAction(title: "Άκυρο", style: .default, handler: { action in | ||
74 | + switch action.style{ | ||
75 | + case .default: | ||
76 | + print("default") | ||
77 | + | ||
78 | + case .cancel: | ||
79 | + print("cancel") | ||
80 | + | ||
81 | + case .destructive: | ||
82 | + print("destructive") | ||
83 | + | ||
84 | + } | ||
85 | + })) | ||
86 | + self.present(alert, animated: true, completion: nil) | ||
87 | + } | ||
88 | + | ||
89 | + func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void { | ||
90 | + | ||
91 | + let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert) | ||
92 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
93 | + switch action.style{ | ||
94 | + case .default: | ||
95 | + print("default") | ||
96 | + | ||
97 | + case .cancel: | ||
98 | + print("cancel") | ||
99 | + | ||
100 | + case .destructive: | ||
101 | + print("destructive") | ||
102 | + | ||
103 | + } | ||
104 | + })) | ||
105 | + self.present(alert, animated: true, completion: nil) | ||
55 | } | 106 | } |
56 | 107 | ||
57 | - func activateSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void { | 108 | + |
58 | - assertionFailure("to be implemented") | 109 | + // MARK: - API CALLS |
110 | + func getProfileRequest() { | ||
111 | + swiftApi().getProfileAsync(getProfileCallback) | ||
59 | } | 112 | } |
113 | + | ||
114 | + func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void { | ||
115 | + if (profileData != nil) { | ||
116 | + DispatchQueue.main.async { | ||
117 | + self.numbersList = profileData?.msisdnList ?? [] | ||
118 | + } | ||
119 | + } else { | ||
120 | + } | ||
121 | + } | ||
122 | + | ||
123 | + func submitOrderRequest() { | ||
124 | + swiftApi().submitOrderAsync(campaign_session_uuid: (campaign?.session_uuid ?? ""), user_msisdn: self.selectedNumber, businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""), submitOrderCallback) | ||
125 | + } | ||
126 | + | ||
127 | + func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void { | ||
128 | + if (response != nil) { | ||
129 | + DispatchQueue.main.async { | ||
130 | + if (response?.getStatus == 1) { | ||
131 | + self.showDialog("Το αίτημά σου ολοκληρώθηκε επιτυχώς!","Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου.") | ||
132 | + | ||
133 | + } else { | ||
134 | + self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | ||
135 | + } | ||
136 | + } | ||
137 | + } else { | ||
138 | + self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
60 | // MARK: - Actions | 142 | // MARK: - Actions |
61 | @IBAction func activateButtomAction(_ sender: Any) { | 143 | @IBAction func activateButtomAction(_ sender: Any) { |
62 | -// activateSetRequest(uuid: couponset?.uuid ?? "") | 144 | + self.numbersPopupTapped(sender) |
145 | + } | ||
146 | +} | ||
147 | + | ||
148 | +// MARK: NumbersPopup | ||
149 | +extension TelcoViewController: NumbersPopupDelegate { | ||
150 | + @objc func numbersPopupTapped(_ sender: Any) { | ||
151 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
152 | + let pp = storyboard.instantiateViewController(withIdentifier: "NumberPopupViewController") as! SwiftWarplyFramework.NumberPopupViewController | ||
153 | + pp.InitWithController(controller: self, | ||
154 | + numbersList: self.numbersList, | ||
155 | + sender: sender, | ||
156 | + delegate: self) | ||
157 | + } | ||
158 | + | ||
159 | + func presentedPopup() { | ||
160 | +// Code for when popup is presented | ||
161 | + } | ||
162 | + | ||
163 | + func dismissedPopup() { | ||
164 | +// Code for when popup is dismissed | ||
165 | + } | ||
166 | + | ||
167 | + func optionSelected(_ option: String) { | ||
168 | +// Code for when option is selected | ||
169 | + self.selectedNumber = option | ||
170 | + DispatchQueue.main.async { | ||
171 | + self.showConfirmDialog() | ||
172 | + } | ||
63 | } | 173 | } |
64 | } | 174 | } |
65 | 175 | ... | ... |
-
Please register or login to post a comment