Skip to content

Commit 38faf7b

Browse files
kitallisclaude
andcommitted
Fix quotes API: correct response format and parameters
- Response is nested in _embedded.quotes, not quotes directly - API doesn't support begin/end date params - Filter by statuses=OPEN and statuses=AWAITING_PAYMENT instead Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 14244ac commit 38faf7b

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

main.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,9 @@ func fetchAllSubscriptions() ([]SubscriptionDetail, error) {
668668
}
669669

670670
type QuoteListResponse struct {
671-
Action string `json:"action"`
672-
Result string `json:"result"`
673-
Quotes []QuoteAPIData `json:"quotes"`
671+
Embedded struct {
672+
Quotes []QuoteAPIData `json:"quotes"`
673+
} `json:"_embedded"`
674674
}
675675

676676
type QuoteAPIData struct {
@@ -688,11 +688,8 @@ type QuoteAPIData struct {
688688
}
689689

690690
func fetchRecentQuotes() ([]QuoteAPIData, error) {
691-
// Fetch quotes from the last 30 days
692-
now := time.Now()
693-
begin := now.AddDate(0, -1, 0).Format("2006-01-02")
694-
695-
path := fmt.Sprintf("/quotes?begin=%s&scope=live&limit=50", begin)
691+
// Fetch open and awaiting payment quotes
692+
path := "/quotes?statuses=OPEN&statuses=AWAITING_PAYMENT"
696693
resp, err := fastspringAPIRequest("GET", path, nil)
697694
if err != nil {
698695
return nil, fmt.Errorf("failed to fetch quotes: %w", err)
@@ -711,8 +708,8 @@ func fetchRecentQuotes() ([]QuoteAPIData, error) {
711708
return nil, fmt.Errorf("failed to decode quotes list: %w", err)
712709
}
713710

714-
log.Printf("Fetched %d quotes", len(result.Quotes))
715-
return result.Quotes, nil
711+
log.Printf("Fetched %d quotes", len(result.Embedded.Quotes))
712+
return result.Embedded.Quotes, nil
716713
}
717714

718715
func fetchSubscriptionEntries(subscriptionID string) ([]SubscriptionEntry, error) {

0 commit comments

Comments
 (0)