This repository has been archived by the owner on Mar 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
lib/src/integrationTest/java/io/github/taz03/jia/friendships/ShowManyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.github.taz03.jia.friendships; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import io.github.taz03.jia.InstagramClient; | ||
import io.github.taz03.jia.TestConfiguration; | ||
import io.github.taz03.jia.requests.friendships.ShowManyRequest; | ||
import io.github.taz03.jia.responses.friendships.ShowManyResponse; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
@ExtendWith(SpringExtension.class) | ||
@ContextConfiguration(classes = TestConfiguration.class) | ||
public final class ShowManyTest { | ||
@Autowired | ||
private InstagramClient client; | ||
|
||
@Autowired | ||
private long instagramPk; | ||
|
||
@Test | ||
public void showManyTest() throws Exception { | ||
ShowManyRequest request = new ShowManyRequest(instagramPk); | ||
ShowManyResponse response = client.sendRequest(request).get(); | ||
|
||
assertEquals("ok", response.getStatus()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
lib/src/main/java/io/github/taz03/jia/requests/friendships/ShowManyRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.github.taz03.jia.requests.friendships; | ||
|
||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import io.github.taz03.jia.requests.InstagramPostRequest; | ||
import io.github.taz03.jia.responses.friendships.ShowManyResponse; | ||
|
||
/** | ||
* Represents an Instagram show many request, used to show multiple connections in same request. | ||
* | ||
* @see io.github.taz03.jia.requests.friendships.ShowRequest | ||
*/ | ||
public final class ShowManyRequest extends InstagramPostRequest<ShowManyResponse> { | ||
/** | ||
* Creates an Instagram show many request. | ||
* | ||
* @param userIds pk of the users to show the connections to | ||
*/ | ||
public ShowManyRequest(long... userIds) { | ||
super(ShowManyResponse.class, "/api/v1/friendships/show_many/", null, Map.of( | ||
"user_ids", Arrays.stream(userIds).mapToObj(String::valueOf).collect(Collectors.joining(",")) | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
lib/src/main/java/io/github/taz03/jia/responses/friendships/ShowManyResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.github.taz03.jia.responses.friendships; | ||
|
||
import java.util.Map; | ||
|
||
import io.github.taz03.jia.responses.InstagramResponse; | ||
import io.github.taz03.jia.responses.models.friendships.Status; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public final class ShowManyResponse extends InstagramResponse { | ||
@JsonProperty("friendship_statuses") | ||
Map<String, Status> statuses; | ||
|
||
public Map<String, Status> getStatuses() { | ||
return statuses; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ShowManyResponse{" + "statuses=" + statuses + '}'; | ||
} | ||
} |