Skip to content

Commit

Permalink
Add WHOIS XML API Website Contacts API endpoint #74 #112 - Fork's cod…
Browse files Browse the repository at this point in the history
…e review feedback
  • Loading branch information
techwinlabs committed Oct 20, 2022
1 parent 34d7072 commit a61ffe8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 38 deletions.
7 changes: 1 addition & 6 deletions ec3730/Data Feeds/WhoisXML/WhoisXMLService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,7 @@ class WhoisXMLService: Service {
guard let endpoint = endpoint(userData), let endpointURL = endpoint.url else {
throw DataFeedError.invalidUrl
}
print("endpoint-----------")
print(endpoint.url!)
print(endpoint.host)
print(endpoint.path)
print(endpoint.queryItems)
print(endpoint.schema)

let minimumBalance = userData?["minimumBalance"] as? Int ?? 100

if let cached: T = cache.value(for: endpointURL.absoluteString) {
Expand Down
2 changes: 0 additions & 2 deletions ec3730/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,5 @@
<dict/>
</dict>
</array>
<key>aps-connection-initiate</key>
<true/>
</dict>
</plist>
28 changes: 14 additions & 14 deletions ec3730/Models/Sections/WhoIsXmlContactsSectionModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ class WhoIsXmlContactsSectionModel: HostSectionModel {
latestData = copyData
dataToCopy = String(data: copyData, encoding: .utf8)
var rows = [CopyCellRow]()

if let names = records.companyNames {
let row = CopyCellRow(title: "Company Names", content: names.joined(separator: "\n"))
rows.append(row)
}

rows.append(CopyCellRow(title: "Title", content: records.meta?.title))

rows.append(CopyCellRow(title: "Description", content: records.meta?.metaDescription))

if let postal = records.postalAddresses {
let row = CopyCellRow(title: "Postal Addresses", content: postal.joined(separator: "\n"))
rows.append(row)
}

rows.append(CopyCellRow(title: "Country code", content: records.countryCode))

if let emails = records.emails {
var emailsArr = [String]()
for email in emails {
Expand All @@ -51,7 +51,7 @@ class WhoIsXmlContactsSectionModel: HostSectionModel {
let row = CopyCellRow(title: "Emails", content: emailsArr.joined(separator: "\n"))
rows.append(row)
}

if let phones = records.phones {
var phoneArr = [String]()
for phone in phones {
Expand All @@ -62,7 +62,7 @@ class WhoIsXmlContactsSectionModel: HostSectionModel {
let row = CopyCellRow(title: "Phone", content: phoneArr.joined(separator: "\n"))
rows.append(row)
}

rows.append(CopyCellRow(title: "Domain name", content: records.domainName))

rows.append(CopyCellRow(title: "Website responed", content: "\(records.websiteResponded ?? false)"))
Expand All @@ -72,23 +72,23 @@ class WhoIsXmlContactsSectionModel: HostSectionModel {
if let facebook = records.socialLinks?.facebook {
socialRows.append(CopyCellRow(title: "Facebook", content: facebook))
}

if let twitter = records.socialLinks?.twitter {
socialRows.append(CopyCellRow(title: "Twitter", content: twitter))
}

if let instagram = records.socialLinks?.instagram {
socialRows.append(CopyCellRow(title: "Instagram", content: instagram))
}

if let linkedIn = records.socialLinks?.linkedIn {
socialRows.append(CopyCellRow(title: "LinkedIn", content: linkedIn))
}

content.append(CopyCellView(title: "Contacts", rows: rows))

content.append(CopyCellView(title: "Social Links", rows: socialRows))

return copyData
}

Expand All @@ -113,7 +113,7 @@ class WhoIsXmlContactsSectionModel: HostSectionModel {
}

let response: WhoIsXmlContactsResult = try await WhoisXml.contactsService.query(["domain": host])

// guard let record = response.dnsData.dnsRecords else {
// throw URLError(URLError.badServerResponse)
// }
Expand Down
32 changes: 16 additions & 16 deletions ec3730/Persistence/Persistence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ struct PersistenceController {
if inMemory {
container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
}
// container.loadPersistentStores(completionHandler: { _, error in
// if let error = error as NSError? {
// // Replace this implementation with code to handle the error appropriately.
// // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
//
// /*
// Typical reasons for an error here include:
// * The parent directory does not exist, cannot be created, or disallows writing.
// * The persistent store is not accessible, due to permissions or data protection when the device is locked.
// * The device is out of space.
// * The store could not be migrated to the current model version.
// Check the error message to determine what the actual problem was.
// */
// fatalError("Unresolved error \(error), \(error.userInfo)")
// }
// })
container.loadPersistentStores(completionHandler: { _, error in
if let error = error as NSError? {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.

/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
}
}

0 comments on commit a61ffe8

Please sign in to comment.