Skip to content

Commit b7d3490

Browse files
authored
Change MentionEntity.id to be not mandatory. (#29)
* Change MentionEntity.id to be not mandatory. * Add integration tests.
1 parent 926c988 commit b7d3490

File tree

15 files changed

+455
-240
lines changed

15 files changed

+455
-240
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Add this dependency to your project's POM:
6060
<dependency>
6161
<groupId>com.twitter</groupId>
6262
<artifactId>twitter-api-java-sdk</artifactId>
63-
<version>2.0.0</version>
63+
<version>2.0.1</version>
6464
</dependency>
6565
```
6666

@@ -75,7 +75,7 @@ mavenLocal() // Needed if the 'twitter-api-java-sdk' jar has been publishe
7575
}
7676
7777
dependencies {
78-
implementation "com.twitter:twitter-api-java-sdk:2.0.0"
78+
implementation "com.twitter:twitter-api-java-sdk:2.0.1"
7979
}
8080
```
8181

@@ -89,7 +89,7 @@ mvn clean package
8989

9090
Then manually install the following JARs:
9191

92-
* `target/twitter-api-java-sdk-2.0.0.jar`
92+
* `target/twitter-api-java-sdk-2.0.1.jar`
9393
* `target/lib/*.jar`
9494

9595
## Twitter Credentials
@@ -120,7 +120,8 @@ You can use the following objects in order to set the credentials:
120120

121121
```java
122122

123-
TwitterApi apiInstance = new TwitterApi(new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
123+
TwitterApi apiInstance = new TwitterApi(new TwitterCredentialsOAuth2(
124+
System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
124125
System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
125126
System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
126127
System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN")));
@@ -152,7 +153,8 @@ public class TwitterApiExample {
152153
* Check the 'security' tag of the required APIs in https://api.twitter.com/2/openapi.json in order
153154
* to use the right credential object.
154155
*/
155-
TwitterApi apiInstance = new TwitterApi(new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
156+
TwitterApi apiInstance = new TwitterApi(new TwitterCredentialsOAuth2(
157+
System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
156158
System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
157159
System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
158160
System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN")));

docs/MentionEntity.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
|------------ | ------------- | ------------- | -------------|
1010
|**end** | **Integer** | Index (zero-based) at which position this entity ends. The index is exclusive. | |
1111
|**start** | **Integer** | Index (zero-based) at which position this entity starts. The index is inclusive. | |
12-
|**id** | **String** | Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. | |
12+
|**id** | **String** | Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. | [optional] |
1313
|**username** | **String** | The Twitter handle (screen name) of this user. | |
1414

1515

docs/MentionFields.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Represent the portion of text recognized as a User mention, and its start and en
88

99
| Name | Type | Description | Notes |
1010
|------------ | ------------- | ------------- | -------------|
11-
|**id** | **String** | Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. | |
11+
|**id** | **String** | Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. | [optional] |
1212
|**username** | **String** | The Twitter handle (screen name) of this user. | |
1313

1414

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<dependency>
1717
<groupId>com.twitter</groupId>
1818
<artifactId>twitter-api-java-sdk</artifactId>
19-
<version>2.0.0</version>
19+
<version>2.0.1</version>
2020
<scope>compile</scope>
2121
</dependency>
2222
</dependencies>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>twitter-api-java-sdk</artifactId>
66
<packaging>jar</packaging>
77
<name>twitter-api-java-sdk</name>
8-
<version>2.0.0</version>
8+
<version>2.0.1</version>
99
<url>https://github.com/twitterdev/twitter-api-java-sdk</url>
1010
<description>Twitter API v2 available endpoints</description>
1111
<scm>

src/main/java/com/twitter/clientlib/ApiClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private void init() {
225225
json = new JSON();
226226

227227
// Set default User-Agent.
228-
setUserAgent("twitter-api-java-sdk/2.0.0");
228+
setUserAgent("twitter-api-java-sdk/2.0.1");
229229

230230
authentications = new HashMap<String, Authentication>();
231231
}

src/main/java/com/twitter/clientlib/JSON.java

Lines changed: 212 additions & 212 deletions
Large diffs are not rendered by default.

src/main/java/com/twitter/clientlib/model/MentionEntity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ public MentionEntity id(String id) {
137137
* Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
138138
* @return id
139139
**/
140-
@javax.annotation.Nonnull
141-
@ApiModelProperty(example = "2244994945", required = true, value = "Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.")
140+
@javax.annotation.Nullable
141+
@ApiModelProperty(example = "2244994945", value = "Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.")
142142

143143
public String getId() {
144144
return id;
@@ -233,7 +233,6 @@ private String toIndentedString(Object o) {
233233
openapiRequiredFields = new HashSet<String>();
234234
openapiRequiredFields.add("end");
235235
openapiRequiredFields.add("start");
236-
openapiRequiredFields.add("id");
237236
openapiRequiredFields.add("username");
238237
}
239238

src/main/java/com/twitter/clientlib/model/MentionFields.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public MentionFields id(String id) {
8080
* Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
8181
* @return id
8282
**/
83-
@javax.annotation.Nonnull
84-
@ApiModelProperty(example = "2244994945", required = true, value = "Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.")
83+
@javax.annotation.Nullable
84+
@ApiModelProperty(example = "2244994945", value = "Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.")
8585

8686
public String getId() {
8787
return id;
@@ -168,7 +168,6 @@ private String toIndentedString(Object o) {
168168

169169
// a set of required properties/fields (JSON key names)
170170
openapiRequiredFields = new HashSet<String>();
171-
openapiRequiredFields.add("id");
172171
openapiRequiredFields.add("username");
173172
}
174173

src/test/java/com/twitter/clientlib/integration/ApiBookmarksTester.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void createDeleteTweetErrorTest() throws ApiException {
141141
apiInstance.bookmarks().postUsersIdBookmarks(req, userId).execute();
142142
});
143143
checkGenericProblem(exception.getErrorObject().getProblem(),
144-
"You are not permitted to bookmark this Tweet.", "Forbidden",
145-
403);
144+
"You cannot bookmark a Tweet that does not exist.", "Bad Request",
145+
400);
146146
}
147147
}

0 commit comments

Comments
 (0)