-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #726 from matrix-org/riot_2718
[WIP] MX3PidAddManager: New class to handle add 3pids to HS and to bind to IS
- Loading branch information
Showing
14 changed files
with
1,431 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
MatrixSDK/Contrib/Swift/ThreePidAdd/MX3PidAddManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
Copyright 2019 The Matrix.org Foundation C.I.C | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
public extension MX3PidAddManager { | ||
|
||
// MARK: - Setup | ||
@nonobjc convenience init(session: MXSession) { | ||
self.init(__matrixSession: session) | ||
} | ||
|
||
@nonobjc func cancel(session: MX3PidAddSession) { | ||
__cancel3PidAddSession(session) | ||
} | ||
|
||
// MARK: - Email | ||
@nonobjc @discardableResult func startAddEmailSession(_ email: String, nextLink: String?, completion: @escaping (_ response: MXResponse<Void>) -> Void) -> MX3PidAddSession { | ||
return __startAddEmailSession(withEmail: email, nextLink: nextLink, success: currySuccess(completion), failure: curryFailure(completion)) | ||
} | ||
|
||
@nonobjc func tryFinaliseAddEmailSession(_ session: MX3PidAddSession, completion: @escaping (_ response: MXResponse<Void>) -> Void) -> Void { | ||
return __tryFinaliseAddEmailSession(session, success: currySuccess(completion), failure: curryFailure(completion)) | ||
} | ||
|
||
|
||
// MARK: - Add MSISDN | ||
@nonobjc @discardableResult func startAddPhoneNumberSession(_ phoneNumber: String, countryCode: String?, completion: @escaping (_ response: MXResponse<Void>) -> Void) -> MX3PidAddSession { | ||
return __startAddPhoneNumberSession(withPhoneNumber: phoneNumber, countryCode: countryCode, success: currySuccess(completion), failure: curryFailure(completion)) | ||
} | ||
|
||
@nonobjc func finaliseAddPhoneNumberSession(_ session: MX3PidAddSession, token: String, completion: @escaping (_ response: MXResponse<Void>) -> Void) -> Void { | ||
return __finaliseAddPhoneNumber(session, withToken: token, success: currySuccess(completion), failure: curryFailure(completion)) | ||
} | ||
|
||
|
||
// MARK: - Bind Email | ||
@nonobjc @discardableResult func startIdentityServerSession(withEmail email: String, bind: Bool, completion: @escaping (_ response: MXResponse<Bool>) -> Void) -> MX3PidAddSession { | ||
return __startIdentityServerEmailSession(withEmail: email, bind: bind, success: currySuccess(completion), failure: curryFailure(completion)) | ||
} | ||
|
||
@nonobjc func tryFinaliseIdentityServerEmailSession(_ session: MX3PidAddSession, completion: @escaping (_ response: MXResponse<Void>) -> Void) -> Void { | ||
return __tryFinaliseIdentityServerEmailSession(session, success: currySuccess(completion), failure: curryFailure(completion)) | ||
} | ||
|
||
// MARK: - Bind phone number | ||
@nonobjc @discardableResult func startIdentityServerSession(withPhoneNumber phoneNumber: String, countryCode: String?, bind: Bool, completion: @escaping (_ response: MXResponse<Bool>) -> Void) -> MX3PidAddSession { | ||
return __startIdentityServerPhoneNumberSession(withPhoneNumber: phoneNumber, countryCode: countryCode, bind: bind, success: currySuccess(completion), failure: curryFailure(completion)) | ||
} | ||
|
||
@nonobjc func finaliseIdentityServerPhoneNumberSession(_ session: MX3PidAddSession, token: String, completion: @escaping (_ response: MXResponse<Void>) -> Void) -> Void { | ||
return __finaliseIdentityServerPhoneNumber(session, withToken: token, success: currySuccess(completion), failure: curryFailure(completion)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.