Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Create organization request required field address #333

Merged
Merged
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
22 changes: 12 additions & 10 deletions organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ func (o Organization) String() string {

// OrganizationCreateRequest type used to create an Equinix Metal organization
type OrganizationCreateRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Website string `json:"website,omitempty"`
Twitter string `json:"twitter,omitempty"`
Logo string `json:"logo,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Website string `json:"website,omitempty"`
Twitter string `json:"twitter,omitempty"`
Logo string `json:"logo,omitempty"`
Address Address `json:"address,omitempty"`
}

func (o OrganizationCreateRequest) String() string {
Expand All @@ -64,11 +65,12 @@ func (o OrganizationCreateRequest) String() string {

// OrganizationUpdateRequest type used to update an Equinix Metal organization
type OrganizationUpdateRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Website *string `json:"website,omitempty"`
Twitter *string `json:"twitter,omitempty"`
Logo *string `json:"logo,omitempty"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Website *string `json:"website,omitempty"`
Twitter *string `json:"twitter,omitempty"`
Logo *string `json:"logo,omitempty"`
Address *Address `json:"address,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

We could potentially send an AddressUpdateRequest object if the API supports updates to individual fields.

https://github.com/packethost/packngo/blob/38eb9a9d3ae9c27ee1bbd7bb720d3fa362873eca/facilities.go#L35-L45

I think it's ok to treat the whole address object as a single entity in this, as is done here.

}

func (o OrganizationUpdateRequest) String() string {
Expand Down
36 changes: 34 additions & 2 deletions organizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ func TestAccOrgList(t *testing.T) {
defer organizationTeardown(c)

rs := testProjectPrefix + randString8()
city := "foo"
addr := Address {
Address: "test",
ZipCode: "12345",
Country: "GB",
City: &city,
}
ocr := OrganizationCreateRequest{
Name: rs,
Description: "Managed by Packngo.",
Website: "http://example.com",
Twitter: "foo",
Address: addr,
}
org, _, err := c.Organizations.Create(&ocr)
if err != nil {
Expand Down Expand Up @@ -55,11 +63,19 @@ func TestAccOrgBasic(t *testing.T) {
defer organizationTeardown(c)

rs := testProjectPrefix + randString8()
city := "foo"
addr := Address{
Address: "test",
ZipCode: "12345",
Country: "GB",
City: &city,
}
ocr := OrganizationCreateRequest{
Name: rs,
Description: "Managed by Packngo.",
Website: "http://example.com",
Twitter: "foo",
Address: addr,
}
p, _, err := c.Organizations.Create(&ocr)
if err != nil {
Expand All @@ -71,13 +87,21 @@ func TestAccOrgBasic(t *testing.T) {

rs = testProjectPrefix + randString8()
oDesc := "Managed by Packngo."
oWeb := "http://quux.example.com"
oTwi := "bar"
oWeb := "http://quux.example.com"
oTwi := "bar"
oCity := "bar"
oAddr := Address{
Address: "test 2",
ZipCode: "54321",
Country: "ES",
City: &oCity,
}
pur := OrganizationUpdateRequest{
Name: &rs,
Description: &oDesc,
Website: &oWeb,
Twitter: &oTwi,
Address: &oAddr,
}
org, _, err := c.Organizations.Update(p.ID, &pur)
if err != nil {
Expand Down Expand Up @@ -114,11 +138,19 @@ func TestAccOrgListPaymentMethods(t *testing.T) {
defer organizationTeardown(c)

rs := testProjectPrefix + randString8()
city := "foo"
addr := Address{
Address: "test",
ZipCode: "12345",
Country: "GB",
City: &city,
}
ocr := OrganizationCreateRequest{
Name: rs,
Description: "Managed by Packngo.",
Website: "http://example.com",
Twitter: "foo",
Address: addr,
}
org, _, err := c.Organizations.Create(&ocr)
if err != nil {
Expand Down