vonage-go-sdk icon indicating copy to clipboard operation
vonage-go-sdk copied to clipboard

Some public API returns types have private subtypes, makes SDK hard to work with

Open sichan-vonage opened this issue 3 years ago • 1 comments

Please update public API return types to not come from internal packages, as it make it impossible to mock. It's also kind of bad practice to be returning private data type on a public API as it makes it harder for people to work with and test etc.

for example type vonage.ApplicationResponse is exposed on the public API but contains subtypes application.ApplicationResponseKeys which is internal to the module. Therefore when I try to create my own type in my tests like so, I will get a compilation error.

vonage.ApplicationResponse{
	Id:   applicationID,
	Name: applicationName,
	Keys: application.ApplicationResponseKeys{
		PublicKey:  publicKeyString,
		PrivateKey: privateKeyString,
	},
}

the vonage package it self should also define it's own type ApplicationResponseKeys

sichan-vonage avatar Dec 07 '21 16:12 sichan-vonage

I'm having the same issue when trying to create tests for my SMS APIs that are testing the return values of my mock client. Propose moving all types into a models directory to better match convention?

theZMC avatar May 26 '22 14:05 theZMC