-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
grpc service method to get all webhook endpoints (#790)
* grpc service method to get all webhook endpoints * make api vesion a constant * fix lint * fix lint issue
- Loading branch information
1 parent
1d93952
commit f60b7d0
Showing
8 changed files
with
572 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package rpcservice | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/stripe/stripe-cli/pkg/requests" | ||
"github.com/stripe/stripe-cli/pkg/stripe" | ||
"github.com/stripe/stripe-cli/rpc" | ||
) | ||
|
||
// WebhookEndpointsList returns a list of webhook endpoints. | ||
func (srv *RPCService) WebhookEndpointsList(ctx context.Context, req *rpc.WebhookEndpointsListRequest) (*rpc.WebhookEndpointsListResponse, error) { | ||
userConfig := srv.cfg.UserCfg | ||
livemode := false | ||
|
||
key, err := userConfig.Profile.GetAPIKey(livemode) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
endpoints := requests.WebhookEndpointsList(ctx, stripe.DefaultAPIBaseURL, stripe.APIVersion, key, &userConfig.Profile) | ||
|
||
formattedEndpoints := make([]*rpc.WebhookEndpointsListResponse_WebhookEndpointData, 0, len(endpoints.Data)) | ||
for _, v := range endpoints.Data { | ||
formattedEndpoints = append(formattedEndpoints, &rpc.WebhookEndpointsListResponse_WebhookEndpointData{ | ||
Application: v.Application, | ||
EnabledEvents: v.EnabledEvents, | ||
Url: v.URL, | ||
Status: v.Status, | ||
}) | ||
} | ||
|
||
return &rpc.WebhookEndpointsListResponse{Endpoints: formattedEndpoints}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.