Skip to content

Commit

Permalink
Use ObjectType instead of string
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Degn committed Jan 18, 2024
1 parent 2c7677c commit b66728d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions company.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (
// Reference: https://developers.hubspot.com/docs/api/crm/companies
type CompanyService interface {
Get(companyID string, company interface{}, option *RequestQueryOption) (*ResponseResource, error)
GetAssociations(companyID, toObjectType string) (*AssociationsResponse, error)
GetAssociations(companyID string, toObjectType ObjectType) (*AssociationsResponse, error)
Create(company interface{}) (*ResponseResource, error)
Update(companyID string, company interface{}) (*ResponseResource, error)
Delete(companyID string) error
Expand Down Expand Up @@ -39,9 +39,9 @@ func (s *CompanyServiceOp) Get(companyID string, company interface{}, option *Re
}

// GetAssociations gets company associations
func (s *CompanyServiceOp) GetAssociations(companyID, toObjectType string) (*AssociationsResponse, error) {
func (s *CompanyServiceOp) GetAssociations(companyID string, toObjectType ObjectType) (*AssociationsResponse, error) {
result := &AssociationsResponse{}
if err := s.client.Get(s.companyPath+"/"+companyID+"/associations/"+toObjectType, result, nil); err != nil {
if err := s.client.Get(s.companyPath+"/"+companyID+"/associations/"+string(toObjectType), result, nil); err != nil {
return nil, err
}
return result, nil
Expand Down
4 changes: 2 additions & 2 deletions company_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func TestCompanyServiceOp_GetAssociations(t *testing.T) {
}
type args struct {
companyID string
toObjectType string
toObjectType hubspot.ObjectType
result *hubspot.AssociationsResponse
}
tests := []struct {
Expand Down Expand Up @@ -379,7 +379,7 @@ func TestCompanyServiceOp_GetAssociations(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := tt.fields.client.CRM.Company.GetAssociations(tt.args.companyID, tt.args.toObjectType, tt.args.result)
got, err := tt.fields.client.CRM.Company.GetAssociations(tt.args.companyID, tt.args.toObjectType)
if !reflect.DeepEqual(tt.wantErr, err) {
t.Errorf("Get() error mismatch: want %s got %s", tt.wantErr, err)
return
Expand Down

0 comments on commit b66728d

Please sign in to comment.