Skip to content

Commit 4554e17

Browse files
committed
update doc
1 parent c4bb731 commit 4554e17

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/Domains/Registrar/OpenSRS.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,24 @@ public function cancelPurchase(): bool
227227
return $successful;
228228
}
229229

230+
/**
231+
* Suggest domain names based on search query
232+
*
233+
* This method uses OpenSRS's name suggestion API with multiple services:
234+
* - 'suggestion': Returns algorithmically generated domain suggestions
235+
* - 'premium': Returns premium domain names available for purchase at higher prices
236+
* - 'lookup': Performs availability checks on exact matches and variations
237+
*
238+
* @param array|string $query Search terms to generate suggestions from
239+
* @param array $tlds Top-level domains to search within (e.g., ['com', 'net', 'org'])
240+
* @param int $minLength Minimum length for suggested domains (default: 1)
241+
* @param int $maxLength Maximum length for suggested domains (default: 100)
242+
* @return array Associative array with domain names as keys and metadata as values
243+
* Each domain entry contains:
244+
* - 'available': boolean indicating if domain is available
245+
* - 'price': float|null price for premium domains, null for regular suggestions
246+
* - 'type': string either 'suggestion' or 'premium' indicating the source service
247+
*/
230248
public function suggest(array|string $query, array $tlds = [], $minLength = 1, $maxLength = 100): array
231249
{
232250
$query = is_array($query) ? $query : [$query];
@@ -236,9 +254,9 @@ public function suggest(array|string $query, array $tlds = [], $minLength = 1, $
236254
'action' => 'name_suggest',
237255
'attributes' => [
238256
'services' => [
239-
'suggestion',
240-
'premium',
241-
'lookup'
257+
'suggestion', // Algorithmic domain suggestions
258+
'premium', // Premium domain names with pricing
259+
'lookup' // Availability lookup for exact matches
242260
],
243261
'searchstring' => implode(' ', $query),
244262
'tlds' => $tlds,
@@ -270,7 +288,7 @@ public function suggest(array|string $query, array $tlds = [], $minLength = 1, $
270288

271289
$items[$domain] = [
272290
'available' => $available,
273-
'price' => 0,
291+
'price' => null,
274292
'type' => 'suggestion'
275293
];
276294
}
@@ -309,7 +327,7 @@ public function suggest(array|string $query, array $tlds = [], $minLength = 1, $
309327
$available = $value === 'available';
310328
break;
311329
case 'price':
312-
$price = is_numeric($value) ? (float) $value : $value;
330+
$price = is_numeric($value) ? (float) $value : null;
313331
break;
314332
}
315333
}

0 commit comments

Comments
 (0)