Skip to content

Commit

Permalink
MOB-1842 - Updated search domains to buy API (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg-Pecheneg authored Mar 18, 2024
1 parent 42cc262 commit 3e3163c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
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

0 comments on commit 3e3163c

Please sign in to comment.