From 75de5fb79867f141cb0980456ae6a1fa3bb881cb Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Mon, 10 Jun 2024 14:40:12 -0600 Subject: [PATCH] Add utility functions for apps and orgs --- types.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/types.go b/types.go index 272aeaa..78b9d09 100644 --- a/types.go +++ b/types.go @@ -258,6 +258,21 @@ type App struct { Nodes []LimitedAccessToken } } + +func (app *App) Compact() *AppCompact { + return &AppCompact{ + ID: app.ID, + Name: app.Name, + Status: app.Status, + Deployed: app.Deployed, + Hostname: app.Hostname, + AppURL: app.AppURL, + Organization: app.Organization.Basic(), + PlatformVersion: app.PlatformVersion, + PostgresAppRole: app.PostgresAppRole, + } +} + type LimitedAccessToken struct { Id string Name string @@ -365,6 +380,20 @@ type Organization struct { } } +func (o *Organization) Basic() *OrganizationBasic { + if o == nil { + return nil + } + + return &OrganizationBasic{ + ID: o.ID, + Name: o.Name, + Slug: o.Slug, + RawSlug: o.RawSlug, + PaidPlan: o.PaidPlan, + } +} + func (o *Organization) GetID() string { return o.ID }