diff --git a/internal/organizations/create.go b/internal/organizations/create.go index 69c56363..30f2845f 100644 --- a/internal/organizations/create.go +++ b/internal/organizations/create.go @@ -51,6 +51,13 @@ func (c *Client) Create() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true + // API spec says organization address.address is required, + // but the address is not included by default + defaultIncludes := []string{"address", "billing_address"} + + include := c.Servicer.Includes(defaultIncludes) + exclude := c.Servicer.Excludes(nil) + req := metal.NewOrganizationInput() req.Name = &name @@ -70,7 +77,7 @@ func (c *Client) Create() *cobra.Command { req.Logo = &logo } - org, _, err := c.Service.CreateOrganization(context.Background()).OrganizationInput(*req).Include(c.Servicer.Includes(nil)).Exclude(c.Servicer.Excludes(nil)).Execute() + org, _, err := c.Service.CreateOrganization(context.Background()).OrganizationInput(*req).Include(include).Exclude(exclude).Execute() if err != nil { return fmt.Errorf("Could not create Organization: %w", err) } diff --git a/internal/organizations/retrieve.go b/internal/organizations/retrieve.go index b7a357f0..9a32c77e 100644 --- a/internal/organizations/retrieve.go +++ b/internal/organizations/retrieve.go @@ -44,7 +44,12 @@ func (c *Client) Retrieve() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true - include := c.Servicer.Includes(nil) + + // API spec says organization address.address is required, + // but the address is not included by default + defaultIncludes := []string{"address", "billing_address"} + + include := c.Servicer.Includes(defaultIncludes) exclude := c.Servicer.Excludes(nil) if organizationID == "" { diff --git a/internal/organizations/update.go b/internal/organizations/update.go index 22817669..0632d743 100644 --- a/internal/organizations/update.go +++ b/internal/organizations/update.go @@ -42,6 +42,13 @@ func (c *Client) Update() *cobra.Command { cmd.SilenceUsage = true req := metal.NewOrganizationInput() + // API spec says organization address.address is required, + // but the address is not included by default + defaultIncludes := []string{"address", "billing_address"} + + include := c.Servicer.Includes(defaultIncludes) + exclude := c.Servicer.Excludes(nil) + if name != "" { req.Name = &name } @@ -62,7 +69,7 @@ func (c *Client) Update() *cobra.Command { req.Website = &website } - org, _, err := c.Service.UpdateOrganization(context.Background(), organizationID).OrganizationInput(*req).Execute() + org, _, err := c.Service.UpdateOrganization(context.Background(), organizationID).OrganizationInput(*req).Include(include).Exclude(exclude).Execute() if err != nil { return fmt.Errorf("Could not update Organization: %w", err) } diff --git a/test/helper/helper.go b/test/helper/helper.go index 0e2088e3..50c943d3 100644 --- a/test/helper/helper.go +++ b/test/helper/helper.go @@ -377,7 +377,11 @@ func CreateTestOrganization(name string) (string, error) { addr.SetZipCode("02108") organizationInput.Address = addr - resp, _, err := TestApiClient.OrganizationsApi.CreateOrganization(context.Background()).OrganizationInput(*organizationInput).Execute() + // API spec says organization address.address is required, + // but the address is not included by default + defaultIncludes := []string{"address", "billing_address"} + + resp, _, err := TestApiClient.OrganizationsApi.CreateOrganization(context.Background()).OrganizationInput(*organizationInput).Include(defaultIncludes).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `OrganizationsApi.CreateOrganization``: %v\n", err) return "", err