Javier Cicchelli 9bcdaa697b [Setup] Basic project structure (#1)
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
2023-04-08 18:37:13 +00:00

96 lines
2.6 KiB
Swift

import Foundation
/// Represents the response structure of an article summary from the Page Content Service /page/summary endpoint
@objc(WMFArticleSummary)
public class ArticleSummary: NSObject, Codable {
@objc public class Namespace: NSObject, Codable {
let id: Int?
let text: String?
@objc public var number: NSNumber? {
guard let id = id else {
return nil
}
return NSNumber(value: id)
}
}
let id: Int64?
let wikidataID: String?
let revision: String?
let timestamp: String?
let index: Int?
@objc let namespace: Namespace?
let title: String?
let displayTitle: String?
let articleDescription: String?
let extract: String?
let extractHTML: String?
let thumbnail: ArticleSummaryImage?
let original: ArticleSummaryImage?
@objc let coordinates: ArticleSummaryCoordinates?
var languageVariantCode: String?
enum CodingKeys: String, CodingKey {
case id = "pageid"
case revision
case index
case namespace
case title
case timestamp
case displayTitle = "displaytitle"
case articleDescription = "description"
case extract
case extractHTML = "extract_html"
case thumbnail
case original = "originalimage"
case coordinates
case contentURLs = "content_urls"
case wikidataID = "wikibase_item"
}
let contentURLs: ArticleSummaryContentURLs
var articleURL: URL? {
guard let urlString = contentURLs.desktop?.page else {
return nil
}
var articleURL = URL(string: urlString)
articleURL?.wmf_languageVariantCode = languageVariantCode
return articleURL
}
var key: WMFInMemoryURLKey? {
return articleURL?.wmf_inMemoryKey // don't use contentURLs.desktop?.page directly as it needs to be standardized
}
}
@objc(WMFArticleSummaryImage)
class ArticleSummaryImage: NSObject, Codable {
let source: String
let width: Int
let height: Int
var url: URL? {
return URL(string: source)
}
}
@objc(WMFArticleSummaryURLs)
class ArticleSummaryURLs: NSObject, Codable {
let page: String?
let revisions: String?
let edit: String?
let talk: String?
}
@objc(WMFArticleSummaryContentURLs)
class ArticleSummaryContentURLs: NSObject, Codable {
let desktop: ArticleSummaryURLs?
let mobile: ArticleSummaryURLs?
}
@objc(WMFArticleSummaryCoordinates)
class ArticleSummaryCoordinates: NSObject, Codable {
@objc let lat: Double
@objc let lon: Double
}