-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="15400" systemVersion="19A602" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> | ||
<entity name="ServiceUsage" representedClassName="ServiceUsage" syncable="YES" codeGenerationType="class"> | ||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21279" systemVersion="21G115" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> | ||
<entity name="ServiceUsage" representedClassName="ServiceUsage" isAbstract="YES" syncable="YES" codeGenerationType="class"> | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
<attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO"/> | ||
<attribute name="serviceName" optional="YES" attributeType="String"/> | ||
</entity> | ||
<elements> | ||
<element name="ServiceUsage" positionX="-63" positionY="-18" width="128" height="73"/> | ||
</elements> | ||
</model> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,5 @@ struct GoogleWebRiskRecordWrapper: Codable { | |
|
||
struct GoogleWebRiskRecord: Codable { | ||
var threatTypes: [GoogleWebRisk.ThreatTypes] | ||
var expireTime: Date | ||
var expireTime: Date? | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
iphone201988
Contributor
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
import Foundation | ||
|
||
struct DnsCoordinate: Codable { | ||
let dnsData: DNSResults | ||
let dnsData: DNSResults? | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
iphone201988
Contributor
|
||
let error: String? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
|
@@ -50,10 +50,10 @@ extension DnsCoordinate { | |
} | ||
|
||
struct DNSResults: Codable { | ||
let domainName: String | ||
let types: [Int] | ||
let dnsTypes: String | ||
let audit: WhoisRecordAudit | ||
let domainName: String? | ||
let types: [Int]? | ||
let dnsTypes: String? | ||
let audit: WhoisRecordAudit? | ||
let dnsRecords: [DNSRecords]? | ||
} | ||
|
||
|
@@ -91,12 +91,12 @@ extension DNSResults { | |
} | ||
|
||
struct DNSRecords: Codable { | ||
let type: Int | ||
let dnsType: String | ||
let name: String | ||
let ttl: Int | ||
let rRsetType: Int | ||
let rawText: String | ||
let type: Int? | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
iphone201988
Contributor
|
||
let dnsType: String? | ||
let name: String? | ||
let ttl: Int? | ||
let rRsetType: Int? | ||
let rawText: String? | ||
|
||
// optionals | ||
let address: String? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,7 @@ class WhoisXMLService: Service { | |
block?(error, nil) | ||
return | ||
} | ||
|
||
guard let data = data else { | ||
block?(DataFeedError.empty, nil) | ||
return | ||
|
@@ -200,22 +201,28 @@ class WhoisXMLService: Service { | |
throw DataFeedError.invalidUrl | ||
} | ||
|
||
let minimumBalance = userData?["minimumBalance"] as? Int ?? 100 | ||
// TODO: Response | ||
// below #208, #215, #216, due to balance validation some services haven't any data, | ||
// if you want to check please uncomment above mentioned line number (#) | ||
|
||
// let minimumBalance = userData?["minimumBalance"] as? Int ?? 100 | ||
This comment has been minimized.
Sorry, something went wrong.
twodayslate
Owner
|
||
|
||
if let cached: T = cache.value(for: endpointURL.absoluteString) { | ||
usage += 1 | ||
return cached | ||
} | ||
|
||
let balance = try await balance(for: WhoisXml.current.userKey) | ||
|
||
guard balance > minimumBalance else { | ||
throw DataFeedError.lowBalance(balance: balance) | ||
} | ||
// let balance = try await balance(for: WhoisXml.current.userKey) | ||
// guard balance > minimumBalance else { throw DataFeedError.lowBalance(balance: balance) } | ||
|
||
usage += 1 | ||
|
||
let (data, _) = try await WhoisXml.session.data(from: endpointURL) | ||
|
||
// TODO: Response | ||
// uncomment below #223, #224 line for validate response | ||
// if let dataIntoStr = String(data: data, encoding: .utf8) { debugPrint("services response: ", dataIntoStr) } | ||
// else { debugPrint("services haven't any data due to balance or parse error") } | ||
|
||
let decoder = JSONDecoder() | ||
decoder.dateDecodingStrategy = .custom { | ||
decoder in | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,27 +6,18 @@ | |
// Copyright © 2022 Zachary Gorak. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import UIKit | ||
|
||
class WhoisXmlContactsService: WhoisXMLService { | ||
fileprivate var contactServiceAPIKey = "at_l54dNyKOiaxH5KV9BWZbNPiOkksmK" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
override func endpoint(_ userData: [String: Any?]?) -> DataFeedEndpoint? { | ||
guard let userData = userData, let userInput = userData["domain"] as? String, let domain = userInput.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) else { | ||
return nil | ||
} | ||
|
||
var params = [URLQueryItem(name: "domainName", value: domain), | ||
URLQueryItem(name: "outputFormat", value: "JSON"), | ||
URLQueryItem(name: "type", value: "_all"), | ||
URLQueryItem(name: "api", value: "whoisXml"), | ||
URLQueryItem(name: "identifierForVendor", value: UIDevice.current.identifierForVendor?.uuidString), | ||
URLQueryItem(name: "bundleIdentifier", value: Bundle.main.bundleIdentifier)] | ||
This comment has been minimized.
Sorry, something went wrong.
twodayslate
Owner
|
||
|
||
if let key = WhoisXml.current.userKey { | ||
params.append(URLQueryItem(name: "apiKey", value: key)) | ||
} | ||
|
||
return WhoisXml.Endpoint(host: "api.netutils.workers.dev", path: "/whoisserver/DNSService", queryItems: params) | ||
let params = [URLQueryItem(name: "domainName", value: domain), | ||
URLQueryItem(name: "apiKey", value: contactServiceAPIKey)] | ||
return WhoisXml.Endpoint(host: "website-contacts.whoisxmlapi.com", path: "/api/v1", queryItems: params) | ||
} | ||
} |
3 comments
on commit 83297a5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of this should be reverted. Unless you actually found a response where it should be optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have created #113 based on your feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's break this pull request into smaller parts. So please just have the Contacts API changes.
If you have found an actual parsing bug please document/create a ticket.
I assume this was auto put there?