Closed zhawtof closed 8 months ago
Hi @zhawtof thanks for asking this. Most of the web API response types are auto-generated, so those types could not be compatible with the ones hand-craffted in slack-edge project.
Having said that, manipulating blocks and attachements in a message object is a very common use case, so the code generator replaces the auto-generated ones with the properly crafted types this way: https://github.com/seratch/slack-web-api-client/blob/0.7.4/scripts/code_generator.rb#L30-L44
As for the file element type, doing the same could be more complicated and I am not sure if your use case is common enough to make efforts. Web API calls with file data usually require file IDs and a limited set of the properties. More specficially, your app is unable to manipulate the properties such as the "cc", which can be generated by the email forwarder app. Can you tell me more about the need?
Ah, perhaps your code compares the data between the request payload and the web API response, right? If that's the case, customizing lots of properties among web API response types is not feasible in the Ruby code... so, please go ahead with casting the types for the specific use case.
Great thanks! I'll continue with my current approach.
And good to know how it all works behind the scenes.
There seem to be discrepancies between
FileElement
on slack-edge andFileElement
on slack-web-api-client. This is not the only one but it is one of the problems that prevents them from being used together without type casting.Here it is given a type
EmailAddress
https://github.com/seratch/slack-edge/blob/05eecb8cafeeed7ef648671ba197b20ad8115bac/src/request/payload/event.ts#L1874Here it is given a type
Cc
https://github.com/seratch/slack-web-api-client/blob/855308a88ab3f28e0da91684f9cdc53cb5456688/src/client/generated-response/ConversationsRepliesResponse.ts#L353The problem is most evident in that
EmailAddress
has required properties andCc
has optional properties.https://github.com/seratch/slack-edge/blob/05eecb8cafeeed7ef648671ba197b20ad8115bac/src/request/payload/event.ts#L1785-L1789
https://github.com/seratch/slack-web-api-client/blob/855308a88ab3f28e0da91684f9cdc53cb5456688/src/client/generated-response/ConversationsRepliesResponse.ts#L499-L503
I was hoping to make a PR to fix the overlap but I don't know which one was more correct given the direction you're building in. Thanks!