Skip to content

Commit 57de92e

Browse files
committed
refactor(api): rename type convert functions
1 parent a3de993 commit 57de92e

46 files changed

Lines changed: 384 additions & 383 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/v3/handlers/apps/convert.gen.go

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v3/handlers/apps/convert.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ import (
2323
// goverter:useUnderlyingTypeMethods
2424
// goverter:matchIgnoreCase
2525
// goverter:extend IntToFloat32
26-
// goverter:extend MapAppToAPI
26+
// goverter:extend ToAPIBillingApp
2727
// goverter:enum:unknown @error
2828
var (
29-
ConvertToListAppResponse func(source response.PagePaginationResponse[api.BillingApp]) api.AppPagePaginatedResponse
29+
ToAPIAppPagePaginatedResponse func(source response.PagePaginationResponse[api.BillingApp]) api.AppPagePaginatedResponse
3030

31-
ConvertMarketplaceListingToV3Api func(source app.MarketplaceListing) (api.BillingAppCatalogItem, error)
31+
ToAPIBillingAppCatalogItem func(source app.MarketplaceListing) (api.BillingAppCatalogItem, error)
3232

3333
// goverter:enum:map AppTypeStripe BillingAppTypeStripe
3434
// goverter:enum:map AppTypeSandbox BillingAppTypeSandbox
3535
// goverter:enum:map AppTypeCustomInvoicing BillingAppTypeExternalInvoicing
36-
ConvertAppTypeToV3Api func(source app.AppType) (api.BillingAppType, error)
36+
ToAPIBillingAppTypeFromDomain func(source app.AppType) (api.BillingAppType, error)
3737

38-
ConvertAppsToBillingApps func(source []app.App) ([]api.BillingApp, error)
38+
ToAPIBillingApps func(source []app.App) ([]api.BillingApp, error)
3939
)
4040

4141
func IntToFloat32(i int) float32 {
4242
return float32(i)
4343
}
4444

45-
// MapAppToAPI maps an app to an v3 API app
46-
func MapAppToAPI(item app.App) (api.BillingApp, error) {
45+
// ToAPIBillingApp maps an app to a v3 API app
46+
func ToAPIBillingApp(item app.App) (api.BillingApp, error) {
4747
if item == nil {
4848
return api.BillingApp{}, errors.New("invalid app: nil")
4949
}
@@ -55,7 +55,7 @@ func MapAppToAPI(item app.App) (api.BillingApp, error) {
5555
return api.BillingApp{}, fmt.Errorf("expected stripe app, got %T", item)
5656
}
5757

58-
billingAppStripe, err := mapStripeAppToAPI(stripeApp.Meta)
58+
billingAppStripe, err := toAPIBillingAppStripe(stripeApp.Meta)
5959
if err != nil {
6060
return api.BillingApp{}, fmt.Errorf("failed to map stripe app to API: %w", err)
6161
}
@@ -72,7 +72,7 @@ func MapAppToAPI(item app.App) (api.BillingApp, error) {
7272
return api.BillingApp{}, fmt.Errorf("expected sandbox app, got %T", item)
7373
}
7474

75-
billingAppSandbox, err := mapSandboxAppToAPI(sandboxApp.Meta)
75+
billingAppSandbox, err := toAPIBillingAppSandbox(sandboxApp.Meta)
7676
if err != nil {
7777
return api.BillingApp{}, fmt.Errorf("failed to map sandbox app to API: %w", err)
7878
}
@@ -89,7 +89,7 @@ func MapAppToAPI(item app.App) (api.BillingApp, error) {
8989
return api.BillingApp{}, fmt.Errorf("expected custom invoicing app, got %T", item)
9090
}
9191

92-
billingAppExternalInvoicing, err := mapCustomInvoicingAppToAPI(customInvoicingApp.Meta)
92+
billingAppExternalInvoicing, err := toAPIBillingAppExternalInvoicing(customInvoicingApp.Meta)
9393
if err != nil {
9494
return api.BillingApp{}, fmt.Errorf("failed to map custom invoicing app to API: %w", err)
9595
}
@@ -105,8 +105,8 @@ func MapAppToAPI(item app.App) (api.BillingApp, error) {
105105
}
106106
}
107107

108-
func mapSandboxAppToAPI(sandboxApp appsandbox.Meta) (api.BillingAppSandbox, error) {
109-
definition, err := ConvertMarketplaceListingToV3Api(sandboxApp.GetListing())
108+
func toAPIBillingAppSandbox(sandboxApp appsandbox.Meta) (api.BillingAppSandbox, error) {
109+
definition, err := ToAPIBillingAppCatalogItem(sandboxApp.GetListing())
110110
if err != nil {
111111
return api.BillingAppSandbox{}, err
112112
}
@@ -125,10 +125,10 @@ func mapSandboxAppToAPI(sandboxApp appsandbox.Meta) (api.BillingAppSandbox, erro
125125
}, nil
126126
}
127127

128-
func mapStripeAppToAPI(
128+
func toAPIBillingAppStripe(
129129
stripeApp appstripeentityapp.Meta,
130130
) (api.BillingAppStripe, error) {
131-
definition, err := ConvertMarketplaceListingToV3Api(stripeApp.GetListing())
131+
definition, err := ToAPIBillingAppCatalogItem(stripeApp.GetListing())
132132
if err != nil {
133133
return api.BillingAppStripe{}, err
134134
}
@@ -153,8 +153,8 @@ func mapStripeAppToAPI(
153153
return apiStripeApp, nil
154154
}
155155

156-
func mapCustomInvoicingAppToAPI(customInvoicingApp appcustominvoicing.Meta) (api.BillingAppExternalInvoicing, error) {
157-
definition, err := ConvertMarketplaceListingToV3Api(customInvoicingApp.GetListing())
156+
func toAPIBillingAppExternalInvoicing(customInvoicingApp appcustominvoicing.Meta) (api.BillingAppExternalInvoicing, error) {
157+
definition, err := ToAPIBillingAppCatalogItem(customInvoicingApp.GetListing())
158158
if err != nil {
159159
return api.BillingAppExternalInvoicing{}, err
160160
}

api/v3/handlers/apps/get_app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (h *handler) GetApp() GetAppHandler {
4040
return GetAppResponse{}, fmt.Errorf("failed to get app: %w", err)
4141
}
4242

43-
return MapAppToAPI(app)
43+
return ToAPIBillingApp(app)
4444
},
4545
commonhttp.JSONResponseEncoder[GetAppResponse],
4646
httptransport.AppendOptions(

api/v3/handlers/apps/list_app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (h *handler) ListApps() ListAppsHandler {
6363
return ListAppsResponse{}, fmt.Errorf("failed to list apps: %w", err)
6464
}
6565

66-
items, err := ConvertAppsToBillingApps(result.Items)
66+
items, err := ToAPIBillingApps(result.Items)
6767
if err != nil {
6868
return ListAppsResponse{}, fmt.Errorf("failed to convert Apps to BillingApps: %w", err)
6969
}
@@ -74,7 +74,7 @@ func (h *handler) ListApps() ListAppsHandler {
7474
Total: lo.ToPtr(result.TotalCount),
7575
})
7676

77-
response := ConvertToListAppResponse(r)
77+
response := ToAPIAppPagePaginatedResponse(r)
7878

7979
return response, nil
8080
},

0 commit comments

Comments
 (0)