Closed leongersen closed 5 years ago
Hello and thanks for the detailed explanation.
We are aware of this issue and we are actually already working on an improvement, soon to be released, that will add getters setters with scalar types to resource classes.
Once this is released, hopefully in the next release of the client library, you will be able to keep calling, for instance, setName
as you currently do, passing a StringValue
object, but you will also have convenience functions like setNameValue
, that will allow you to pass a string.
In the same way, you will have a function called getNameValue
that will allow you to get the name as a string, while still maintaining the existing getName
returning a StringValue
.
As of V1_2, the convenience functions mentioned in my previous comments have been implemented for all resources.
Currently, all conversions to GRPC types have to be made in user code, resulting in rather unwieldy object creation.
Please consider the following example:
Arguably, this code could look like the following, with the SDK abstracting away the encapsulation in
StringValue
,Int64Value
, etc.The same issue applies when handling responses, where scalar values and Protobuf objects are mixed. This has some ergonomic issues, because the user has to check the return type for every method/property individually:
Since the SDK has a minimum requirement of PHP > 7.1, typing could be enforced using PHP's native type hints, resulting in more accurate static analysis and generally leaner code.
In the AdWords SDK for the Soap based API, the protocol specifics are abstracted away. The user does need to know about the Soap envelope, namespacing or encoding specifics.
Was the choice to work directly with the Protobuf types in user code deliberate, or is this merely the result of generating the PHP classes from protocol buffers? Is the current SDK design "final", or could changes in this area be expected?