Skip to content

data is not required in getRules response #35

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

Merged
merged 3 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.twitter</groupId>
<artifactId>twitter-api-java-sdk</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
</dependency>
```

Expand All @@ -75,7 +75,7 @@ mavenLocal() // Needed if the 'twitter-api-java-sdk' jar has been publishe
}

dependencies {
implementation "com.twitter:twitter-api-java-sdk:2.0.1"
implementation "com.twitter:twitter-api-java-sdk:2.0.2"
}
```

Expand All @@ -89,7 +89,7 @@ mvn clean package

Then manually install the following JARs:

* `target/twitter-api-java-sdk-2.0.1.jar`
* `target/twitter-api-java-sdk-2.0.2.jar`
* `target/lib/*.jar`

## Twitter Credentials
Expand Down
2 changes: 1 addition & 1 deletion docs/RulesLookupResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**data** | [**List&lt;Rule&gt;**](Rule.md) | | |
|**data** | [**List&lt;Rule&gt;**](Rule.md) | | [optional] |
|**meta** | [**RulesResponseMetadata**](RulesResponseMetadata.md) | | |


Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<dependency>
<groupId>com.twitter</groupId>
<artifactId>twitter-api-java-sdk</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>twitter-api-java-sdk</artifactId>
<packaging>jar</packaging>
<name>twitter-api-java-sdk</name>
<version>2.0.1</version>
<version>2.0.2</version>
<url>https://github.com/twitterdev/twitter-api-java-sdk</url>
<description>Twitter API v2 available endpoints</description>
<scm>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/twitter/clientlib/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private void init() {
json = new JSON();

// Set default User-Agent.
setUserAgent("twitter-api-java-sdk/2.0.1");
setUserAgent("twitter-api-java-sdk/2.0.2");

authentications = new HashMap<String, Authentication>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
public class RulesLookupResponse {
public static final String SERIALIZED_NAME_DATA = "data";
@SerializedName(SERIALIZED_NAME_DATA)
private List<Rule> data = new ArrayList<>();
private List<Rule> data = null;

public static final String SERIALIZED_NAME_META = "meta";
@SerializedName(SERIALIZED_NAME_META)
Expand All @@ -80,6 +80,9 @@ public RulesLookupResponse data(List<Rule> data) {
}

public RulesLookupResponse addDataItem(Rule dataItem) {
if (this.data == null) {
this.data = new ArrayList<>();
}
this.data.add(dataItem);
return this;
}
Expand All @@ -88,8 +91,8 @@ public RulesLookupResponse addDataItem(Rule dataItem) {
* Get data
* @return data
**/
@javax.annotation.Nonnull
@ApiModelProperty(required = true, value = "")
@javax.annotation.Nullable
@ApiModelProperty(value = "")

public List<Rule> getData() {
return data;
Expand Down Expand Up @@ -176,7 +179,6 @@ private String toIndentedString(Object o) {

// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet<String>();
openapiRequiredFields.add("data");
openapiRequiredFields.add("meta");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,47 @@ private AddOrDeleteRulesResponse deleteRule(String ruleStrValue) throws ApiExcep
.execute();
}

private void deleteAllRules() throws ApiException {
RulesLookupResponse result = apiInstance.tweets().getRules().execute();
if(result.getData() != null) {
for(Rule rule : result.getData()) {
AddOrDeleteRulesRequest request = new AddOrDeleteRulesRequest();
DeleteRulesRequest dr = new DeleteRulesRequest();
DeleteRulesRequestDelete drd = new DeleteRulesRequestDelete();
drd.setValues(Arrays.asList(rule.getValue()));
dr.setDelete(drd);
request.setActualInstance(dr);
apiInstance.tweets().addOrDeleteRules(request).dryRun(false).execute();
}
}
}

/* @Test
@Test
public void getRulesAllTest() throws ApiException {
GetRulesResponse result = apiInstance.tweets().getRules(null, null, null);
assertNotNull(result.getData());
assertNotNull(result.getData().get(0));
assertNotNull(result.getData().get(0).getValue());
assertNotNull(result.getData().get(0).getId());
try {
addRule(ruleValue);
RulesLookupResponse result = apiInstance.tweets().getRules().execute();
assertNotNull(result.getData());
assertNotNull(result.getData().get(0));
assertNotNull(result.getData().get(0).getValue());
assertNotNull(result.getData().get(0).getId());
assertNotNull(result.getMeta());
assertNotNull(result.getMeta().getSent());
assertTrue(result.getMeta().getResultCount() > 0);
} finally {
deleteRule(ruleValue);
}
}

@Test
public void getRulesNoRulesTest() throws ApiException {
deleteAllRules();
RulesLookupResponse result = apiInstance.tweets().getRules().execute();
assertNull(result.getData());
assertNotNull(result.getMeta());
assertNotNull(result.getMeta().getSent());
assertTrue(result.getMeta().getResultCount() > 0);
} */
assertEquals(0, result.getMeta().getResultCount());
}

@Test
public void addOrDeleteRulesAddTest() throws ApiException {
Expand Down