Vonage / vonage-go-sdk

A lightweight library to help Go users everywhere integrate with the Vonage APIs. Issues and PRs all really welcome!!
https://vonage.github.io/vonage-go-sdk/
Apache License 2.0
51 stars 32 forks source link

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

Open sichan-vonage opened 2 years ago

sichan-vonage commented 2 years ago

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

theZMC commented 2 years ago

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?