Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

new direct message api #229

Merged
merged 22 commits into from
Dec 1, 2018
Merged

Conversation

mitgard
Copy link
Contributor

@mitgard mitgard commented Sep 25, 2018

No description provided.

@codecov
Copy link

codecov bot commented Sep 26, 2018

Codecov Report

Merging #229 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #229      +/-   ##
==========================================
+ Coverage    94.2%   94.26%   +0.05%     
==========================================
  Files          75       76       +1     
  Lines        1157     1168      +11     
  Branches       11       12       +1     
==========================================
+ Hits         1090     1101      +11     
  Misses         67       67
Impacted Files Coverage Δ
...sfregola/twitter4s/http/oauth/OAuth1Provider.scala 100% <ø> (ø) ⬆️
...asfregola/twitter4s/entities/enums/TweetType.scala 100% <100%> (ø)
...st/directmessages/TwitterDirectMessageClient.scala 100% <100%> (ø) ⬆️
...egola/twitter4s/http/serializers/EnumFormats.scala 100% <100%> (ø) ⬆️
...ola/twitter4s/http/serializers/CustomFormats.scala 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc3e35c...99d848a. Read the comment docs.

Copy link
Owner

@DanielaSfregola DanielaSfregola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mitgard,
thanks for your PR!

I think we are almost there. Could you please:

  • clarify the reason of the changes in OAuth1Provider.scala
  • rename class as per comment
  • add return types to the public methods
  • Could we please add a deprecation annotation to the methods linked to the methods that Twitter is deprecating? Something like @deprecated("Twitter endpoint deprecated from 17th Sep 2018. Please use 'whatever' instead.")

@DanielaSfregola
Copy link
Owner

This fixes #227

@mitgard
Copy link
Contributor Author

mitgard commented Oct 1, 2018

@DanielaSfregola What we do with tests for deprecated function? Exclude -depcrecation or -Xfatal-warnings from build settings or delete tests?

@DanielaSfregola
Copy link
Owner

I would probably temporary remove the compiler flag, rather than removing the tests

@@ -23,6 +65,7 @@ trait TwitterDirectMessageClient {
* @param id : The ID of the direct message.
* @return : The direct message.
* */
@deprecated("Twitter endpoint deprecated from 17th Sep 2018. Please use 'eventShow' instead.", "twitter4s 5.6")
Copy link
Owner

@DanielaSfregola DanielaSfregola Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be released as part of twitter4s 6.0, so can you please change the since message of the deprecated annotation?

@DanielaSfregola DanielaSfregola changed the title fix direct message api new direct message api Oct 2, 2018
build.sbt Outdated
@@ -74,7 +74,6 @@ lazy val standardSettings = Seq(
"UTF-8",
"-Xlint",
"-deprecation",
"-Xfatal-warnings",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fatal-warnings flag is too important to remove it.
If you cannot find a way to let the tests involving deprecation pass, I would rather delete them that removing the flag.

@mitgard
Copy link
Contributor Author

mitgard commented Oct 16, 2018

@DanielaSfregola It seems I've finished with that. Could you please check.

Copy link
Owner

@DanielaSfregola DanielaSfregola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good.
Before we can merge we need to:

  • use more specific types in the entity so that the API can be easier to use (e.g.: enums rather than string, time related types rather than string, etc).

  • [ME] double check that the changes on the token authentication don't break the other endpoints. We do have unit tests, but it is such a delicate part of the code that I'd like to do some manual testing that uses the actual Twitter API, just to be sure.

@@ -0,0 +1,18 @@
package com.danielasfregola.twitter4s.entities

final case class DirectMessageEvent(`type`: String,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type should be an enum as we should know the set of possible values accepted by the Twitter API
ids general are of type Long, any particular reason they are of type String here?
timestamps should have a type consistent to the other types of timestamp in the code. Also, we may want to add a default to "now", so that people can just create the entity without providing one explicitly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import com.danielasfregola.twitter4s.entities.streaming.UserStreamingMessage

final case class DirectMessageEventList(events: List[DirectMessageEvent],
apps: Option[Map[String, Apps]],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why an Option[Map[.., ...]] and not just a Map[..., ...]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Owner

@DanielaSfregola DanielaSfregola Nov 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be changed to just Map[..., ...] unless there is a specific reason to keep the optional wrapper


private[twitter4s] final case class NewDirectMessageEvent(event: NewEvent)

private[twitter4s] final case class NewEvent(`type`: String = "message_create", message_create: MessageCreate)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type should be an enum

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (cleanBody.nonEmpty) {
if (cleanBody.nonEmpty && request.entity
.getContentType()
.mediaType == MediaTypes.`application/x-www-form-urlencoded`) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check this before merging, as this could break other endpoints' authentication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we return Map() if we cannot calculate Map

id to Long
timestamp to LocalDateTime
@mitgard
Copy link
Contributor Author

mitgard commented Nov 12, 2018

@DanielaSfregola, Could you please check. I fixed you comments.


final case class DirectMessageEvent(`type`: TweetType.Value = TweetType.messageCreate,
id: DirectMessageId,
created_timestamp: LocalDateTime,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created_timestamp cannot be a local date as we need to consider timezones as well. I suggest to change it to Instant and to add a default of Instant.now.

@DanielaSfregola
Copy link
Owner

Hi @mitgard,
thanks for your awesome work! We are almost there. The only things still missing:

  • get rid of Option[Map[..., ...]] or convince me why we need to keep the distintion between no map and empty map
  • change created_timestamp form LocalDateTime to Instant.

I know you have been working on this PR for quite some time now, so I am happy to merge it as it and prepare a patch for it if you no longer have the time to work on it.

Cheers,
Daniela

@mitgard
Copy link
Contributor Author

mitgard commented Nov 19, 2018

Hi @mitgard,
thanks for your awesome work! We are almost there. The only things still missing:

  • get rid of Option[Map[..., ...]] or convince me why we need to keep the distintion between no map and empty map
  • change created_timestamp form LocalDateTime to Instant.

I know you have been working on this PR for quite some time now, so I am happy to merge it as it and prepare a patch for it if you no longer have the time to work on it.

Cheers,
Daniela

Hi @DanielaSfregola, sorry for my long time patch. I've fixed last comment.

Copy link
Owner

@DanielaSfregola DanielaSfregola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@DanielaSfregola DanielaSfregola merged commit 34f6c59 into DanielaSfregola:master Dec 1, 2018
DanielaSfregola added a commit that referenced this pull request Dec 1, 2018
@DanielaSfregola DanielaSfregola added this to the 6.0 milestone Dec 1, 2018
DanielaSfregola added a commit that referenced this pull request Dec 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants