File tree Expand file tree Collapse file tree 4 files changed +45
-47
lines changed Expand file tree Collapse file tree 4 files changed +45
-47
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -590,5 +590,20 @@ interface TwitterV2 {
590
590
userFields : String? = null,
591
591
): SpacesResponse
592
592
593
+ /* *
594
+ * The recent search endpoint returns Tweets from the last seven days that match a search query.
595
+ *
596
+ * @throws TwitterException when Twitter service or network is unavailable
597
+ * @see "https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent"
598
+ */
599
+ @Throws(TwitterException ::class )
600
+ fun searchSpaces (
601
+ query : String ,
602
+ state : Space .State ,
603
+ expansions : String? = null,
604
+ maxResults : Int? = null,
605
+ spaceFields : String? = null,
606
+ userFields : String? = null,
607
+ ): SpacesResponse
593
608
594
609
}
Original file line number Diff line number Diff line change @@ -1057,6 +1057,32 @@ class TwitterV2Impl(private val twitter: Twitter) : TwitterV2 {
1057
1057
)
1058
1058
}
1059
1059
1060
+ @Throws(TwitterException ::class )
1061
+ override fun searchSpaces (
1062
+ query : String ,
1063
+ state : Space .State ,
1064
+ expansions : String? ,
1065
+ maxResults : Int? ,
1066
+ spaceFields : String? ,
1067
+ userFields : String? ,
1068
+ ): SpacesResponse {
1069
+
1070
+ val params = arrayListOf (
1071
+ HttpParameter (" query" , query),
1072
+ HttpParameter (" state" , state.rawValue),
1073
+ )
1074
+
1075
+ V2Util .addHttpParamIfNotNull(params, " expansions" , expansions)
1076
+ V2Util .addHttpParamIfNotNull(params, " max_results" , maxResults)
1077
+ V2Util .addHttpParamIfNotNull(params, " space.fields" , spaceFields)
1078
+ V2Util .addHttpParamIfNotNull(params, " user.fields" , userFields)
1079
+
1080
+ return V2ResponseFactory ().createSpacesResponse(
1081
+ get(conf.v2Configuration.baseURL + " spaces/search" , params.toTypedArray()),
1082
+ conf
1083
+ )
1084
+ }
1085
+
1060
1086
// --------------------------------------------------
1061
1087
// get/post/delete
1062
1088
// --------------------------------------------------
Original file line number Diff line number Diff line change @@ -7,14 +7,14 @@ import org.junit.Test
7
7
class SearchSpacesTest {
8
8
9
9
private val twitter by lazy { V2TestUtil .createOAuth2TwitterInstance() }
10
- private val myId by lazy { twitter.verifyCredentials().id }
10
+ // private val myId by lazy { twitter.verifyCredentials().id }
11
11
12
12
@Test
13
13
@Ignore(" expiration time of oauth2.accessToken is too short" )
14
14
fun searchSpaces_minimum () {
15
15
16
16
// Scheduled
17
- twitter.searchSpaces(" a" , Space .State .Scheduled ).let { res ->
17
+ twitter.v2. searchSpaces(" a" , Space .State .Scheduled ).let { res ->
18
18
println (res)
19
19
20
20
val json = JSONObject (TwitterObjectFactory .getRawJSON(res))
@@ -33,7 +33,7 @@ class SearchSpacesTest {
33
33
}
34
34
35
35
// Live
36
- twitter.searchSpaces(" a" , Space .State .Live ).let { res ->
36
+ twitter.v2. searchSpaces(" a" , Space .State .Live ).let { res ->
37
37
println (res)
38
38
39
39
val json = JSONObject (TwitterObjectFactory .getRawJSON(res))
@@ -56,7 +56,7 @@ class SearchSpacesTest {
56
56
@Ignore(" expiration time of oauth2.accessToken is too short" )
57
57
fun searchSpaces_full_result () {
58
58
59
- val res = twitter.searchSpaces(
59
+ val res = twitter.v2. searchSpaces(
60
60
" a" ,
61
61
Space .State .Live ,
62
62
maxResults = 10 ,
You can’t perform that action at this time.
0 commit comments