
Go function to fetch Subscriptions:
func FetchSubscriptions() ([]entities.Subscription, error) {
var result []entities.Subscription
ctx := context.TODO()
subscriptions, err := goCardLessClient.Subscriptions.List(ctx, gocardless.SubscriptionListParams{Limit: 100})
if err != nil {
log.Println("Error in api.FetchSubscriptions 1:", err)
return result, appjoy.ErrSomethingWentWrong
}
for _, subscription := range subscriptions.Subscriptions {
var eSubscription entities.Subscription
eSubscription.ID = subscription.Id
switch subscription.IntervalUnit {
case "weekly":
eSubscription.Pricing = fmt.Sprintf("%d€ / w", subscription.Amount/1000)
case "monthly":
eSubscription.Pricing = fmt.Sprintf("%d€ / m", subscription.Amount/1000)
}
result = append(result, eSubscription)
}
return result, nil
}
Desired result: getting the subscriptions
Actual result: no error is returned, but the slice of Subscriptions is empty.
Go function to fetch Subscriptions:
Desired result: getting the subscriptions
Actual result: no error is returned, but the slice of Subscriptions is empty.