(meta map[string]any)
| 611 | var expireKeys = [...]string{"expired", "expire", "expires_at", "expiresAt", "expiry", "expires"} |
| 612 | |
| 613 | func expirationFromMap(meta map[string]any) (time.Time, bool) { |
| 614 | if meta == nil { |
| 615 | return time.Time{}, false |
| 616 | } |
| 617 | for _, key := range expireKeys { |
| 618 | if v, ok := meta[key]; ok { |
| 619 | if ts, ok1 := parseTimeValue(v); ok1 { |
| 620 | return ts, true |
| 621 | } |
| 622 | } |
| 623 | } |
| 624 | for _, nestedKey := range []string{"token", "Token"} { |
| 625 | if nested, ok := meta[nestedKey]; ok { |
| 626 | switch val := nested.(type) { |
| 627 | case map[string]any: |
| 628 | if ts, ok1 := expirationFromMap(val); ok1 { |
| 629 | return ts, true |
| 630 | } |
| 631 | case map[string]string: |
| 632 | temp := make(map[string]any, len(val)) |
| 633 | for k, v := range val { |
| 634 | temp[k] = v |
| 635 | } |
| 636 | if ts, ok1 := expirationFromMap(temp); ok1 { |
| 637 | return ts, true |
| 638 | } |
| 639 | } |
| 640 | } |
| 641 | } |
| 642 | return time.Time{}, false |
| 643 | } |
| 644 | |
| 645 | func ProviderRefreshLead(provider string, runtime any) *time.Duration { |
| 646 | provider = strings.ToLower(strings.TrimSpace(provider)) |
no test coverage detected