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

Commit

Permalink
Merge pull request #333 from packethost/create_organization_request_r…
Browse files Browse the repository at this point in the history
…equired_field_address

Create organization request required field address
  • Loading branch information
displague authored May 9, 2022
2 parents c1c08c7 + 384f67c commit c64c7f8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
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"`
}

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

0 comments on commit c64c7f8

Please sign in to comment.