Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Slack Specification and rewrite all the patches #45

Merged
merged 10 commits into from
Sep 16, 2019

Conversation

damienalexandre
Copy link
Member

  • some patches are removed thanks to Slack updating his specification
  • some remains, specifically the one handling:
    • message attachments;
    • timestamps as string instead of number.

@damienalexandre damienalexandre added the enhancement New feature or request label Aug 7, 2019
@damienalexandre damienalexandre changed the base branch from updateJane to master August 7, 2019 08:47
@pyrech
Copy link
Member

pyrech commented Aug 7, 2019

Looks like Slack changed some object definition and used items to describe possible variant for some object. In particular, the objs_user changed to differentiate normal users and enterprise users and is now rendered as two classes ObjsUserItem0 and ObjsUserItem1 instead of the previous ObjsUser. The denormilizer even returns stdClass instead of these classes.

We should probably apply a patch to transform back the user model in one class. Should we also fix other models that are now described with the items notation?

@damienalexandre
Copy link
Member Author

You were right, the Slack specification introduced some polymorphic objects that cannot be handled gracefully in the generated client.

I added two patches to merge those objects.

  • objs_user
  • objs_conversation

Could you please test again?

@jamesgraham
Copy link

@damienalexandre does this fix #7 ?

@damienalexandre
Copy link
Member Author

As far as I can guess, yes... maybe? But it should be ok on master too... did you try again recently?

Look at this part:

/**
* {@inheritdoc}
*
*
* @return \JoliCode\Slack\Api\Model\UsersListGetResponse200|\JoliCode\Slack\Api\Model\UsersListGetResponsedefault|null
*/
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer)
{
if (200 === $status) {
return $serializer->deserialize($body, 'JoliCode\\Slack\\Api\\Model\\UsersListGetResponse200', 'json');
}
return $serializer->deserialize($body, 'JoliCode\\Slack\\Api\\Model\\UsersListGetResponsedefault', 'json');
}
}

If the status is not 200, the UsersListGetResponsedefault object is used, and the error string is here:

class UsersListGetResponsedefault
{
/**
* @var string
*/
protected $error;
/**
* @var bool
*/
protected $ok;

@pyrech
Copy link
Member

pyrech commented Sep 16, 2019

The PR now works great on https://github.com/jolicode/secret-santa. Great jobs 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants