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

Commit

Permalink
added show many request (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
Taz03 authored Nov 12, 2023
1 parent cc0d5b3 commit fa97627
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
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());
}
}
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(","))
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

/**
* Represents an Instagram request, used to show your connection info with others.
*
* @see io.github.taz03.jia.requests.friendships.ShowManyRequest
*/
public final class ShowRequest extends InstagramGetRequest<ShowResponse> {
/**
Expand Down
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 + '}';
}
}

0 comments on commit fa97627

Please sign in to comment.