# generic
import "github.com/ansys/aali-flowkit/pkg/privatefunctions/generic"
## Index
- [func CreatePayloadAndSendHttpRequest\(url string, requestType string, requestObject interface\{\}, responsePtr interface\{\}\) \(funcError error, statusCode int\)](<#CreatePayloadAndSendHttpRequest>)
- [func ExtractStringFieldFromStruct\(data interface\{\}, fieldName string\) \(string, error\)](<#ExtractStringFieldFromStruct>)
- [func SnakeToCamel\(s string, upperFirst bool\) string](<#SnakeToCamel>)
## func CreatePayloadAndSendHttpRequest
func CreatePayloadAndSendHttpRequest(url string, requestType string, requestObject interface{}, responsePtr interface{}) (funcError error, statusCode int)
CreatePayloadAndSendHttpRequest creates a JSON payload from a request object and sends an HTTP POST request to the specified URL. The response body is decoded into the responsePtr object.
Parameters:
- url: the URL to send the HTTP POST request to.
- requestType: the type of HTTP request to send \(POST, GET, PUT, DELETE\).
- requestObject: the request object to create the JSON payload from.
- responsePtr: a pointer to the response object to decode the JSON response body into.
Returns:
- an error if there was an issue creating the JSON payload, sending the HTTP POST request, or decoding the JSON response body.
- the status code of the HTTP response.
## func ExtractStringFieldFromStruct
func ExtractStringFieldFromStruct(data interface{}, fieldName string) (string, error)
ExtractStringFieldFromStruct extracts a string field from a struct.
Parameters:
- data: the struct to extract the string field from.
- fieldName: the name of the field to extract.
Returns:
- the string field value.
- an error if the field is not found or is not a string.
## func SnakeToCamel
func SnakeToCamel(s string, upperFirst bool) string
SnakeToCamel converts a snake\_case string to camelCase or PascalCase based on upperFirst flag
Parameters:
- s: the snake\_case string to convert.
- upperFirst: a flag to determine if the first letter should be capitalized.
Returns:
- the camelCase or PascalCase string.
Generated by [gomarkdoc]()