github.com/Ingenico-ePayments/connect-sdk-go@v0.0.0-20240318153750-1f8cd329b9c9/webhooks/validation/APIVersionMismatchError.go (about) 1 package validation 2 3 import "fmt" 4 5 var ( 6 mismatchErrorFormat = `"event API version "%v" is not compatible with SDK API version "%v"` 7 ) 8 9 // APIVersionMismatchError represents an error because a webhooks event has an API version 10 // that this version of the SDK does not support. 11 type APIVersionMismatchError struct { 12 eventAPIVersion string 13 sdkAPIVersion string 14 15 message string 16 } 17 18 // Error implements the error interface 19 func (ame *APIVersionMismatchError) Error() string { 20 return ame.message 21 } 22 23 // EventAPIVersion represents the APIVersion found in the event 24 func (ame *APIVersionMismatchError) EventAPIVersion() string { 25 return ame.eventAPIVersion 26 } 27 28 // SDKAPIVersion represents the APIVersion found in the SDK 29 func (ame *APIVersionMismatchError) SDKAPIVersion() string { 30 return ame.sdkAPIVersion 31 } 32 33 // NewAPIVersionMismatchError creates a APIVersionMismatchError with the given eventAPIVersion and sdkAPIVersion 34 func NewAPIVersionMismatchError(eventAPIVersion, sdkAPIVersion string) *APIVersionMismatchError { 35 message := fmt.Sprintf(mismatchErrorFormat, eventAPIVersion, sdkAPIVersion) 36 37 return &APIVersionMismatchError{eventAPIVersion, sdkAPIVersion, message} 38 }