Send and receive additional properties not defined in the SDK
The Square Go SDK supports sending and receiving extra properties that are not explicitly defined in the SDK types. This is useful when you need to interact with unreleased features, beta functionality, or properties that haven’t been added to the SDK yet.
Use option.WithQueryParameters() to add query parameters that aren’t directly supported by the request type.For example, suppose a new feature was rolled out that allowed you to filter team members by status. You can add the relevant query parameters like this:
Every response type in the SDK includes the GetExtraProperties() method, which returns a map containing any properties in the JSON response that were not defined in the response struct.
Extra properties can contain nested structures. Use type assertions to work with them:
extraProperties := response.GetExtraProperties()if metadata, ok := extraProperties["metadata"].(map[string]interface{}); ok { if customField, ok := metadata["custom_field"].(string); ok { fmt.Printf("Custom field: %s\n", customField) }}
The extra properties feature is implemented in the SDK’s code generation:
All response structs include an extraProperties map[string]interface{} field
The JSON unmarshaling process captures unknown fields into this map
The GetExtraProperties() method provides safe access to these fields
// Example implementation from the SDKfunc (a *AcceptedPaymentMethods) GetExtraProperties() map[string]interface{} { if a == nil { return nil } return a.extraProperties}
Always check if the response is nil before calling GetExtraProperties() to avoid nil pointer panics.