Skip to content

Commit

Permalink
ref
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-fbudzynski committed Dec 16, 2024
1 parent 38b8a3e commit 9f29c42
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/sdk/poc/generator/helper_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func newIDHelperMethod(structName string, objectIdentifier objectIdentifier) *He
return newHelperMethod("ID", structName, returnValue, string(objectIdentifier))
}

func newObjectTypeHelperMethod(structName string) *HelperMethod {
returnValue := fmt.Sprintf("ObjectType%v", structName)
return newHelperMethod("ObjectType", structName, returnValue, "ObjectType")
}

func containsFieldNames(fields []*Field, names ...string) bool {
fieldNames := map[string]any{}
for _, field := range fields {
Expand All @@ -85,17 +90,12 @@ func hasRequiredFieldsForIDMethod(operations []*Operation, structName string, re
return containsFieldNames(field.Fields, requiredFields...)
}
}
log.Printf("WARNING: Struct '%s' not found in '%s' operation. Couldn't generate ID() helper method.", structName, OperationKindShow)
log.Printf("WARNING: Struct: '%s' not found in '%s' operation. Couldn't generate ID() helper method.", structName, OperationKindShow)
}
log.Printf("WARNING: '%s' not found. Couldn't generate ID() helper method.", OperationKindShow)
log.Printf("WARNING: Operation: '%s' not found. Couldn't generate ID() helper method.", OperationKindShow)
return false
}

func newObjectTypeHelperMethod(structName string) *HelperMethod {
returnValue := fmt.Sprintf("ObjectType%v", structName)
return newHelperMethod("ObjectType", structName, returnValue, "ObjectType")
}

// HelperMethodID adds a helper method "ID()" to the interface file that returns the ObjectIdentifier of the object
func (i *Interface) HelperMethodID() *Interface {
identifierKind := identifierStringToObjectIdentifier(i.IdentifierKind)
Expand Down

0 comments on commit 9f29c42

Please sign in to comment.