This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended. To summarise this work: - [x] created a new **Xcode** project; - [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project; - [x] created the `Locations` app and also, its `Libraries` package; - [x] created the `Shared` package to share dependencies between the apps; - [x] added a `Makefile` file and implemented some **environment** and **help** commands. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: rock-n-code/deep-linking-assignment#1
23 lines
1.0 KiB
Swift
23 lines
1.0 KiB
Swift
public class WMFCaptcha: NSObject {
|
|
@objc public let captchaID: String
|
|
@objc public let captchaURL: URL
|
|
@objc public init(captchaID:String, captchaURL:URL) {
|
|
self.captchaID = captchaID
|
|
self.captchaURL = captchaURL
|
|
}
|
|
static public func captcha(from requests: [[String : AnyObject]]) -> WMFCaptcha? {
|
|
guard
|
|
let captchaAuthenticationRequest = requests.first(where: {$0["id"]! as! String == "CaptchaAuthenticationRequest"}),
|
|
let fields = captchaAuthenticationRequest["fields"] as? [String : AnyObject],
|
|
let captchaId = fields["captchaId"] as? [String : AnyObject],
|
|
let captchaInfo = fields["captchaInfo"] as? [String : AnyObject],
|
|
let captchaIdValue = captchaId["value"] as? String,
|
|
let captchaInfoValue = captchaInfo["value"] as? String,
|
|
let captchaURL = URL(string: captchaInfoValue)
|
|
else {
|
|
return nil
|
|
}
|
|
return WMFCaptcha(captchaID: captchaIdValue, captchaURL: captchaURL)
|
|
}
|
|
}
|