Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOB-1842 - Updated search domains to buy API #446

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ private extension BaseFirebaseInteractionService.URLSList {
static var USER_PROFILE_URL: String { USER_URL.appendingURLPathComponent("profile") }

static var DOMAIN_URL: String { baseAPIURL.appendingURLPathComponent("domain") }
static var DOMAIN_SEARCH_URL: String { DOMAIN_URL.appendingURLPathComponent("search") }
static var DOMAIN_AI_SUGGESTIONS_URL: String { DOMAIN_SEARCH_URL.appendingURLPathComponent("ai-suggestions") }
static var DOMAIN_SEARCH_URL: String { DOMAIN_URL.appendingURLPathComponents("search", "internal") }
static var DOMAIN_AI_SUGGESTIONS_URL: String { DOMAIN_URL.appendingURLPathComponents("search", "ai-suggestions") }
static func DOMAIN_ENS_STATUS_URL(domain: String) -> String {
DOMAIN_URL.appendingURLPathComponents(domain, "ens-status")
}
Expand Down Expand Up @@ -187,8 +187,8 @@ private extension FirebasePurchaseDomainsService {
}

func aiSearchForFBDomains(hint: String) async throws -> [DomainProductItem] {
let queryComponents = ["phrase" : hint,
"extension" : "All"]
let queryComponents = ["extension" : "All",
"phrase" : hint]
let urlString = URLSList.DOMAIN_AI_SUGGESTIONS_URL.appendingURLQueryComponents(queryComponents)
let request = try APIRequest(urlString: urlString,
method: .get)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,25 @@ extension FirebasePurchaseDomainsService {
@DecodeHashableIgnoringFailed
var hiddenProducts: [UDProduct]


init(from decoder: any Decoder) throws {
let container: KeyedDecodingContainer<FirebasePurchaseDomainsService.DomainProductItem.CodingKeys> = try decoder.container(keyedBy: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.self)
self.reservedForUserId = try container.decodeIfPresent(String.self, forKey: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.reservedForUserId)
self.availability = try container.decode(Bool.self, forKey: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.availability)
self.domain = try container.decode(FirebasePurchaseDomainsService.DomainProductDetails.self, forKey: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.domain)
self.price = try container.decode(Int.self, forKey: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.price)
self.productId = try container.decodeIfPresent(Int.self, forKey: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.productId)
self.productType = try container.decode(String.self, forKey: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.productType)
self.productCode = try container.decode(String.self, forKey: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.productCode)
self.status = try container.decode(String.self, forKey: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.status)
self.tags = try container.decode([String].self, forKey: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.tags)
if let hiddenProducts = try? container.decode(DecodeHashableIgnoringFailed<FirebasePurchaseDomainsService.UDProduct>.self, forKey: FirebasePurchaseDomainsService.DomainProductItem.CodingKeys.hiddenProducts) {
self._hiddenProducts = hiddenProducts
} else {
self._hiddenProducts = .init(value: [])
}
}

// Custom field
var availableProducts: [UDProduct]?
var ensStatus: ENSDomainProductStatusResponse?
Expand Down