-
Notifications
You must be signed in to change notification settings - Fork 3
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 #40 from Cidaas/development
Development
- Loading branch information
Showing
14 changed files
with
547 additions
and
25 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
61 changes: 61 additions & 0 deletions
61
Cidaas/Classes/Core/Controllers/Repository/Settings/SettingsController.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,61 @@ | ||
// | ||
// SettingsController.swift | ||
// Cidaas | ||
// | ||
// Created by ganesh on 27/11/18. | ||
// | ||
|
||
import Foundation | ||
|
||
public class SettingsController { | ||
|
||
// shared instance | ||
public static var shared : SettingsController = SettingsController() | ||
|
||
// constructor | ||
public init() { | ||
|
||
} | ||
|
||
// get end points | ||
public func getEndpoints(properties: Dictionary<String, String>, callback: @escaping (Result<EndpointsResponseEntity>) -> Void) { | ||
|
||
// null check | ||
if properties["DomainURL"] == "" || properties["DomainURL"] == nil { | ||
let error = WebAuthError.shared.propertyMissingException() | ||
// log error | ||
let loggerMessage = "Read properties failure : " + "Error Code - " + String(describing: error.errorCode) + ", Error Message - " + error.errorMessage + ", Status Code - " + String(describing: error.statusCode) | ||
logw(loggerMessage, cname: "cidaas-sdk-error-log") | ||
|
||
DispatchQueue.main.async { | ||
callback(Result.failure(error: error)) | ||
} | ||
return | ||
} | ||
|
||
// call getEndpoints service | ||
SettingsService.shared.getEndpoints(properties: properties) { | ||
switch $0 { | ||
case .failure(let error): | ||
// log error | ||
let loggerMessage = "Get endpoints service failure : " + "Error Code - " + String(describing: error.errorCode) + ", Error Message - " + error.errorMessage + ", Status Code - " + String(describing: error.statusCode) | ||
logw(loggerMessage, cname: "cidaas-sdk-error-log") | ||
|
||
// return failure callback | ||
DispatchQueue.main.async { | ||
callback(Result.failure(error: error)) | ||
} | ||
return | ||
case .success(let serviceResponse): | ||
// log success | ||
let loggerMessage = "Get endpoints service success : " + "Authz URL - " + serviceResponse.authorization_endpoint | ||
logw(loggerMessage, cname: "cidaas-sdk-success-log") | ||
|
||
// return callback | ||
DispatchQueue.main.async { | ||
callback(Result.success(result: serviceResponse)) | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.