From fd93b99e1aaefe8edf1a7c289169fd811d00c581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Semp=C3=A9?= Date: Thu, 5 Oct 2023 10:12:55 +0200 Subject: [PATCH] feat(override-plan): Ability to fetch a single subscription (#128) --- subscription.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/subscription.go b/subscription.go index 8dab8f3..c257a73 100644 --- a/subscription.go +++ b/subscription.go @@ -149,6 +149,27 @@ func (sr *SubscriptionRequest) Terminate(ctx context.Context, subscriptionTermin return subscriptionResult.Subscription, nil } +func (sr *SubscriptionRequest) Get(ctx context.Context, subscriptionExternalId string) (*Subscription, *Error) { + subPath := fmt.Sprintf("%s/%s", "subscriptions", subscriptionExternalId) + + clientRequest := &ClientRequest{ + Path: subPath, + Result: &SubscriptionResult{}, + } + + result, err := sr.client.Get(ctx, clientRequest) + if err != nil { + return nil, err + } + + subscriptionResult, ok := result.(*SubscriptionResult) + if !ok { + return nil, &ErrorTypeAssert + } + + return subscriptionResult.Subscription, nil +} + func (sr *SubscriptionRequest) GetList(ctx context.Context, subscriptionListInput SubscriptionListInput) (*SubscriptionResult, *Error) { jsonQueryParams, err := json.Marshal(subscriptionListInput) if err != nil {