@@ -23,6 +23,7 @@ func NewDomainAPI(m interface{}) *domain.API {
2323 return domain .NewAPI (meta .ExtractScwClient (m ))
2424}
2525
26+ // NewRegistrarDomainAPI returns a new registrar API.
2627func NewRegistrarDomainAPI (m interface {}) * domain.RegistrarAPI {
2728 return domain .NewRegistrarAPI (meta .ExtractScwClient (m ))
2829}
@@ -116,6 +117,7 @@ func ExpandContact(contactMap map[string]interface{}) *domain.Contact {
116117 contact .ExtensionFr = extension .(* domain.ContactExtensionFR )
117118 }
118119 }
120+
119121 if extEu , ok := contactMap ["extension_eu" ].(map [string ]interface {}); ok && len (extEu ) > 0 {
120122 extension := expandContactExtension (extEu , "eu" )
121123 if extension != nil {
@@ -148,6 +150,7 @@ func expandContactExtension(extensionMap map[string]interface{}, extensionType s
148150 TrademarkInfo : parseStruct [domain.ContactExtensionFRTrademarkInfo ](extensionMap , "trademark_info" ),
149151 CodeAuthAfnicInfo : parseStruct [domain.ContactExtensionFRCodeAuthAfnicInfo ](extensionMap , "code_auth_afnic_info" ),
150152 }
153+
151154 case "nl" :
152155 legalFormRegistrationNumber := ""
153156 if value , ok := extensionMap ["legal_form_registration_number" ]; ok {
@@ -160,6 +163,7 @@ func expandContactExtension(extensionMap map[string]interface{}, extensionType s
160163 LegalForm : domain .ContactExtensionNLLegalForm (parseEnum (extensionMap , "legal_form" , domain .ContactExtensionNLLegalFormLegalFormUnknown .String ())),
161164 LegalFormRegistrationNumber : legalFormRegistrationNumber ,
162165 }
166+
163167 case "eu" :
164168 europeanCitizenship := ""
165169 if value , ok := extensionMap ["european_citizenship" ]; ok {
@@ -171,6 +175,7 @@ func expandContactExtension(extensionMap map[string]interface{}, extensionType s
171175 return & domain.ContactExtensionEU {
172176 EuropeanCitizenship : europeanCitizenship ,
173177 }
178+
174179 default :
175180 return nil
176181 }
@@ -233,6 +238,7 @@ func ExpandNewContact(contactMap map[string]interface{}) *domain.NewContact {
233238 contact .ExtensionFr = extension .(* domain.ContactExtensionFR )
234239 }
235240 }
241+
236242 if extEu , ok := contactMap ["extension_eu" ].(map [string ]interface {}); ok && len (extEu ) > 0 {
237243 extension := expandContactExtension (extEu , "eu" )
238244 if extension != nil {
@@ -265,6 +271,7 @@ func parseStruct[T any](data map[string]interface{}, key string) *T {
265271
266272 return & result
267273 }
274+
268275 return nil
269276}
270277
@@ -274,13 +281,15 @@ func mapToStruct(data map[string]interface{}, target interface{}) {
274281 if v , ok := data ["whois_opt_in" ].(bool ); ok {
275282 t .WhoisOptIn = v
276283 }
284+
277285 case * domain.ContactExtensionFRDunsInfo :
278286 if v , ok := data ["duns_id" ].(string ); ok {
279287 t .DunsID = v
280288 }
281289 if v , ok := data ["local_id" ].(string ); ok {
282290 t .LocalID = v
283291 }
292+
284293 case * domain.ContactExtensionFRAssociationInfo :
285294 if v , ok := data ["publication_jo" ].(string ); ok {
286295 if parsedTime , err := time .Parse (time .RFC3339 , v ); err == nil {
@@ -290,10 +299,12 @@ func mapToStruct(data map[string]interface{}, target interface{}) {
290299 if v , ok := data ["publication_jo_page" ].(float64 ); ok {
291300 t .PublicationJoPage = uint32 (v )
292301 }
302+
293303 case * domain.ContactExtensionFRTrademarkInfo :
294304 if v , ok := data ["trademark_inpi" ].(string ); ok {
295305 t .TrademarkInpi = v
296306 }
307+
297308 case * domain.ContactExtensionFRCodeAuthAfnicInfo :
298309 if v , ok := data ["code_auth_afnic" ].(string ); ok {
299310 t .CodeAuthAfnic = v
@@ -304,6 +315,7 @@ func mapToStruct(data map[string]interface{}, target interface{}) {
304315func getStatusTasks (ctx context.Context , api * domain.RegistrarAPI , taskID string ) (domain.TaskStatus , error ) {
305316 var page int32 = 1
306317 var pageSize uint32 = 1000
318+
307319 for {
308320 listTasksResponse , err := api .ListTasks (& domain.RegistrarAPIListTasksRequest {
309321 Page : & page ,
@@ -356,6 +368,7 @@ func ExtractDomainsFromTaskID(ctx context.Context, id string, registrarAPI *doma
356368 if len (parts ) != 2 {
357369 return nil , fmt .Errorf ("invalid ID format, expected 'projectID/domainName', got: %s" , id )
358370 }
371+
359372 taskID := parts [1 ]
360373
361374 listTasksResponse , err := registrarAPI .ListTasks (& domain.RegistrarAPIListTasksRequest {}, scw .WithContext (ctx ), scw .WithAllPages ())
@@ -402,9 +415,11 @@ func flattenContact(contact *domain.Contact) []map[string]interface{} {
402415 if contact .ExtensionFr != nil {
403416 flattened ["extension_fr" ] = flattenContactExtensionFR (contact .ExtensionFr )
404417 }
418+
405419 if contact .ExtensionEu != nil {
406420 flattened ["extension_eu" ] = flattenContactExtensionEU (contact .ExtensionEu )
407421 }
422+
408423 if contact .ExtensionNl != nil {
409424 flattened ["extension_nl" ] = flattenContactExtensionNL (contact .ExtensionNl )
410425 }
@@ -516,52 +531,9 @@ func flattenContactExtensionNL(ext *domain.ContactExtensionNL) []map[string]inte
516531 }
517532}
518533
519- // func flattenTLD(tld *domain.Tld) []map[string]interface{} {
520- // if tld == nil {
521- // return []map[string]interface{}{}
522- // }
523- // tldMap := map[string]interface{}{
524- // "name": tld.Name,
525- // "dnssec_support": tld.DnssecSupport,
526- // "duration_in_years_min": tld.DurationInYearsMin,
527- // "duration_in_years_max": tld.DurationInYearsMax,
528- // "idn_support": tld.IDnSupport,
529- // }
530- //
531- // tldMap["offers"] = flattenTldOffers(tld.Offers)
532- //
533- // if tld.Specifications != nil {
534- // tldMap["specifications"] = tld.Specifications
535- // } else {
536- // tldMap["specifications"] = map[string]interface{}{}
537- // }
538- //
539- // return []map[string]interface{}{tldMap}
540- // }
541-
542- // func flattenTldOffers(offers map[string]*domain.TldOffer) []map[string]interface{} {
543- // if offers == nil {
544- // return nil
545- // }
546- //
547- // flattenedOffers := []map[string]interface{}{}
548- // for _, offer := range offers {
549- // flattenedOffers = append(flattenedOffers, map[string]interface{}{
550- // "action": offer.Action,
551- // "operation_path": offer.OperationPath,
552- // "price": map[string]interface{}{
553- // "currency_code": offer.Price.CurrencyCode,
554- // "units": strconv.Itoa(int(offer.Price.Units)),
555- // "nanos": strconv.Itoa(int(offer.Price.Nanos)),
556- // },
557- // })
558- // }
559- //
560- // return flattenedOffers
561- // }
562-
563534func waitForTaskCompletion (ctx context.Context , registrarAPI * domain.RegistrarAPI , taskID string , duration int ) error {
564535 timeout := time .Duration (duration ) * time .Second
536+
565537 return retry .RetryContext (ctx , timeout , func () * retry.RetryError {
566538 status , err := getStatusTasks (ctx , registrarAPI , taskID )
567539 if err != nil {
@@ -577,7 +549,7 @@ func waitForTaskCompletion(ctx context.Context, registrarAPI *domain.RegistrarAP
577549 }
578550
579551 if status == domain .TaskStatusError {
580- return retry .NonRetryableError (fmt .Errorf ("task failed for domain: %s" , taskID )) // Échec
552+ return retry .NonRetryableError (fmt .Errorf ("task failed for domain: %s" , taskID ))
581553 }
582554
583555 return retry .NonRetryableError (fmt .Errorf ("unexpected task status: %v" , status ))
@@ -661,6 +633,50 @@ func FlattenDSRecord(dsRecords []*domain.DSRecord) []interface{} {
661633 return results
662634}
663635
636+ // func flattenTLD(tld *domain.Tld) []map[string]interface{} {
637+ // if tld == nil {
638+ // return []map[string]interface{}{}
639+ // }
640+ // tldMap := map[string]interface{}{
641+ // "name": tld.Name,
642+ // "dnssec_support": tld.DnssecSupport,
643+ // "duration_in_years_min": tld.DurationInYearsMin,
644+ // "duration_in_years_max": tld.DurationInYearsMax,
645+ // "idn_support": tld.IDnSupport,
646+ // }
647+ //
648+ // tldMap["offers"] = flattenTldOffers(tld.Offers)
649+ //
650+ // if tld.Specifications != nil {
651+ // tldMap["specifications"] = tld.Specifications
652+ // } else {
653+ // tldMap["specifications"] = map[string]interface{}{}
654+ // }
655+ //
656+ // return []map[string]interface{}{tldMap}
657+ // }
658+
659+ // func flattenTldOffers(offers map[string]*domain.TldOffer) []map[string]interface{} {
660+ // if offers == nil {
661+ // return nil
662+ // }
663+ //
664+ // flattenedOffers := []map[string]interface{}{}
665+ // for _, offer := range offers {
666+ // flattenedOffers = append(flattenedOffers, map[string]interface{}{
667+ // "action": offer.Action,
668+ // "operation_path": offer.OperationPath,
669+ // "price": map[string]interface{}{
670+ // "currency_code": offer.Price.CurrencyCode,
671+ // "units": strconv.Itoa(int(offer.Price.Units)),
672+ // "nanos": strconv.Itoa(int(offer.Price.Nanos)),
673+ // },
674+ // })
675+ // }
676+ //
677+ // return flattenedOffers
678+ // }
679+
664680// func flattenDNSZones(dnsZones []*domain.DNSZone) []map[string]interface{} {
665681// if dnsZones == nil {
666682// return nil
0 commit comments