Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for business units. #498

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions examples/resources/commercetools_business_unit/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
resource "commercetools_business_unit_company" "acme_company" {
key = "acme-company"
name = "The ACME Company"
status = "Active"
contact_email = "acme@example.com"

store {
key = "acme-usa"
type_id = "store"
}

store {
key = "acme-germany"
type_id = "store"
}

address {
key = "acme-business-unit-address"
title = "Acme Business Unit Address"
salutation = "Mr."
first_name = "John"
last_name = "Doe"
street_name = "Main Street"
street_number = "1"
additional_street_info = "Additional Street Info"
postal_code = "12345"
city = "Berlin"
region = "Berlin"
country = "DE"
company = "Acme"
department = "IT"
building = "Building"
apartment = "Apartment"
po_box = "P.O. Box"
phone = "123456789"
mobile = "987654321"
}

default_shipping_address_id = "acme-business-unit-address"
default_billing_address_id = "acme-business-unit-address"
}

resource "commercetools_business_unit_division" "acme-willie-coyote" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The address are also required, might be nice to add it to the example

key = "acme-willie-coyote"
name = "Willie Coyote - Traps for Roadrunners"
status = "Active"
contact_email = "acme-traps@example.com"
store_mode = "FromParent"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is not actually part of the definition?

associate_mode = "ExplicitAndFromParent"

// Only available for division business units as the Company
// business unit has no parent unit and must always be the Top Level Unit.
parent_unit {
key = commercetools_business_unit_company.acme-company.key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
key = commercetools_business_unit_company.acme-company.key
key = commercetools_business_unit_company.acme_company.key

type_id = "company"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type_id = "company"
type_id = "Company"

}
}
3 changes: 3 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
datasourcetype "github.com/labd/terraform-provider-commercetools/internal/datasource/type"
"github.com/labd/terraform-provider-commercetools/internal/resources/associate_role"
"github.com/labd/terraform-provider-commercetools/internal/resources/attribute_group"
"github.com/labd/terraform-provider-commercetools/internal/resources/business_unit"
"github.com/labd/terraform-provider-commercetools/internal/resources/product_selection"
"github.com/labd/terraform-provider-commercetools/internal/resources/project"
"github.com/labd/terraform-provider-commercetools/internal/resources/state"
Expand Down Expand Up @@ -196,5 +197,7 @@ func (p *ctProvider) Resources(_ context.Context) []func() resource.Resource {
attribute_group.NewResource,
associate_role.NewResource,
product_selection.NewResource,
business_unit.NewCompanyResource,
business_unit.NewDivisionResource,
}
}
Loading
Loading