mirror of
https://github.com/LukeHagar/plexjava.git
synced 2025-12-06 04:20:46 +00:00
336 lines
12 KiB
Java
336 lines
12 KiB
Java
/*
|
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
*/
|
|
|
|
package dev.plexapi.sdk;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
import dev.plexapi.sdk.models.operations.Connections;
|
|
import dev.plexapi.sdk.models.operations.Friend;
|
|
import dev.plexapi.sdk.models.operations.GeoData;
|
|
import dev.plexapi.sdk.models.operations.GetCompanionsDataResponse;
|
|
import dev.plexapi.sdk.models.operations.GetGeoDataGeoData;
|
|
import dev.plexapi.sdk.models.operations.GetGeoDataResponse;
|
|
import dev.plexapi.sdk.models.operations.GetHomeDataResponse;
|
|
import dev.plexapi.sdk.models.operations.GetHomeDataResponseBody;
|
|
import dev.plexapi.sdk.models.operations.GetPinAuthPinContainer;
|
|
import dev.plexapi.sdk.models.operations.GetPinRequest;
|
|
import dev.plexapi.sdk.models.operations.GetPinResponse;
|
|
import dev.plexapi.sdk.models.operations.GetServerResourcesResponse;
|
|
import dev.plexapi.sdk.models.operations.GetTokenByPinIdAuthPinContainer;
|
|
import dev.plexapi.sdk.models.operations.GetTokenByPinIdGeoData;
|
|
import dev.plexapi.sdk.models.operations.GetTokenByPinIdRequest;
|
|
import dev.plexapi.sdk.models.operations.GetTokenByPinIdResponse;
|
|
import dev.plexapi.sdk.models.operations.GetUserFriendsResponse;
|
|
import dev.plexapi.sdk.models.operations.IncludeHttps;
|
|
import dev.plexapi.sdk.models.operations.IncludeIPv6;
|
|
import dev.plexapi.sdk.models.operations.IncludeRelay;
|
|
import dev.plexapi.sdk.models.operations.PlexDevice;
|
|
import dev.plexapi.sdk.models.operations.Protocol;
|
|
import dev.plexapi.sdk.models.operations.ResponseBody;
|
|
import dev.plexapi.sdk.models.operations.SharedServers;
|
|
import dev.plexapi.sdk.models.operations.SharedSources;
|
|
import dev.plexapi.sdk.models.operations.Status;
|
|
import java.lang.Exception;
|
|
import java.time.OffsetDateTime;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
import org.junit.jupiter.api.Disabled;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.openapitools.jackson.nullable.JsonNullable;
|
|
|
|
public class PlexTests {
|
|
|
|
@Disabled // test marked as skipped for java or generated unit tests not production ready yet
|
|
@Test
|
|
public void testPlex_GetCompanionsData() throws Exception {
|
|
|
|
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.accessToken("<YOUR_API_KEY_HERE>")
|
|
.clientID("gcgzw5rz2xovp84b4vha3a40")
|
|
.clientName("Plex Web")
|
|
.clientVersion("4.133.0")
|
|
.clientPlatform("Chrome")
|
|
.deviceName("Linux")
|
|
.build();
|
|
|
|
GetCompanionsDataResponse res = sdk.plex().getCompanionsData()
|
|
.call();
|
|
|
|
assertEquals(
|
|
List.of(
|
|
ResponseBody.builder()
|
|
.identifier("tv.plex.sonos")
|
|
.baseURL("https://sonos.plex.tv")
|
|
.title("Sonos")
|
|
.linkURL("https://sonos.plex.tv/link")
|
|
.provides("client,player")
|
|
.token("<value>")
|
|
.build()),
|
|
res.responseBodies().get());
|
|
}
|
|
|
|
@Disabled // test marked as skipped for java or generated unit tests not production ready yet
|
|
@Test
|
|
public void testPlex_GetUserFriends() throws Exception {
|
|
|
|
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.accessToken("<YOUR_API_KEY_HERE>")
|
|
.clientID("gcgzw5rz2xovp84b4vha3a40")
|
|
.clientName("Plex Web")
|
|
.clientVersion("4.133.0")
|
|
.clientPlatform("Chrome")
|
|
.deviceName("Linux")
|
|
.build();
|
|
|
|
GetUserFriendsResponse res = sdk.plex().getUserFriends()
|
|
.call();
|
|
|
|
assertEquals(
|
|
List.of(
|
|
Friend.builder()
|
|
.email("username@email.com")
|
|
.friendlyName(Optional.empty())
|
|
.home(false)
|
|
.id(437587)
|
|
.sharedServers(List.of(
|
|
SharedServers.builder()
|
|
.build()))
|
|
.sharedSources(List.of(
|
|
SharedSources.builder()
|
|
.build()))
|
|
.status(Status.ACCEPTED)
|
|
.thumb("https://plex.tv/users/7d1916e0d8f6e76b/avatar?c=1694481578")
|
|
.title("username123")
|
|
.username("username123")
|
|
.uuid("7d1916e0d8f6e76b")
|
|
.restricted(false)
|
|
.build()),
|
|
res.friends().get());
|
|
}
|
|
|
|
@Disabled // test marked as skipped for java or generated unit tests not production ready yet
|
|
@Test
|
|
public void testPlex_GetGeoData() throws Exception {
|
|
|
|
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.clientID("gcgzw5rz2xovp84b4vha3a40")
|
|
.clientName("Plex Web")
|
|
.clientVersion("4.133.0")
|
|
.clientPlatform("Chrome")
|
|
.deviceName("Linux")
|
|
.build();
|
|
|
|
GetGeoDataResponse res = sdk.plex().getGeoData()
|
|
.call();
|
|
|
|
assertEquals(
|
|
GetGeoDataGeoData.builder()
|
|
.code("VI")
|
|
.continentCode("NA")
|
|
.country("United States Virgin Islands")
|
|
.city("Amsterdam")
|
|
.timeZone("America/St_Thomas")
|
|
.postalCode("802")
|
|
.subdivisions("Saint Thomas")
|
|
.coordinates("18.3381, -64.8941")
|
|
.europeanUnionMember(true)
|
|
.inPrivacyRestrictedCountry(true)
|
|
.inPrivacyRestrictedRegion(true)
|
|
.build(),
|
|
res.geoData().get());
|
|
}
|
|
|
|
@Disabled // test marked as skipped for java or generated unit tests not production ready yet
|
|
@Test
|
|
public void testPlex_GetHomeData() throws Exception {
|
|
|
|
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.accessToken("<YOUR_API_KEY_HERE>")
|
|
.clientID("gcgzw5rz2xovp84b4vha3a40")
|
|
.clientName("Plex Web")
|
|
.clientVersion("4.133.0")
|
|
.clientPlatform("Chrome")
|
|
.deviceName("Linux")
|
|
.build();
|
|
|
|
GetHomeDataResponse res = sdk.plex().getHomeData()
|
|
.call();
|
|
|
|
assertEquals(
|
|
GetHomeDataResponseBody.builder()
|
|
.id(1841489d)
|
|
.name("Blindkitty38's home")
|
|
.guestUserID(58815432d)
|
|
.guestUserUUID("f3df4e01bfca0787")
|
|
.build(),
|
|
res.object().get());
|
|
}
|
|
|
|
@Disabled // test marked as skipped for java or generated unit tests not production ready yet
|
|
@Test
|
|
public void testPlex_GetServerResources() throws Exception {
|
|
|
|
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.accessToken("<YOUR_API_KEY_HERE>")
|
|
.clientID("gcgzw5rz2xovp84b4vha3a40")
|
|
.clientName("Plex Web")
|
|
.clientVersion("4.133.0")
|
|
.clientPlatform("Chrome")
|
|
.deviceName("Linux")
|
|
.build();
|
|
|
|
GetServerResourcesResponse res = sdk.plex().getServerResources()
|
|
.includeHttps(IncludeHttps.Enable)
|
|
.includeRelay(IncludeRelay.Enable)
|
|
.includeIPv6(IncludeIPv6.Enable)
|
|
.call();
|
|
|
|
assertEquals(
|
|
List.of(
|
|
PlexDevice.builder()
|
|
.name("<value>")
|
|
.product("Small Wooden Fish")
|
|
.productVersion("<value>")
|
|
.platform("<value>")
|
|
.platformVersion("<value>")
|
|
.device("Mobile")
|
|
.clientIdentifier("<value>")
|
|
.createdAt(OffsetDateTime.parse("2019-06-24T11:38:02Z"))
|
|
.lastSeenAt(OffsetDateTime.parse("2019-06-24T11:38:02Z"))
|
|
.provides("<value>")
|
|
.ownerId(528895L)
|
|
.sourceTitle("<value>")
|
|
.publicAddress("<value>")
|
|
.accessToken("<value>")
|
|
.owned(false)
|
|
.home(false)
|
|
.synced(false)
|
|
.relay(false)
|
|
.presence(false)
|
|
.httpsRequired(false)
|
|
.publicAddressMatches(false)
|
|
.dnsRebindingProtection(false)
|
|
.natLoopbackSupported(false)
|
|
.connections(List.of(
|
|
Connections.builder()
|
|
.protocol(Protocol.HTTP)
|
|
.address("9000 Station Road")
|
|
.port(57017)
|
|
.uri("https://steep-independence.net")
|
|
.local(false)
|
|
.relay(false)
|
|
.iPv6(false)
|
|
.build()))
|
|
.build()),
|
|
res.plexDevices().get());
|
|
}
|
|
|
|
@Disabled // test marked as skipped for java or generated unit tests not production ready yet
|
|
@Test
|
|
public void testPlex_GetPin_() throws Exception {
|
|
|
|
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.clientID("gcgzw5rz2xovp84b4vha3a40")
|
|
.clientName("Plex Web")
|
|
.clientVersion("4.133.0")
|
|
.clientPlatform("Chrome")
|
|
.deviceName("Linux")
|
|
.build();
|
|
|
|
GetPinRequest req = GetPinRequest.builder()
|
|
.build();
|
|
|
|
GetPinResponse res = sdk.plex().getPin()
|
|
.request(req)
|
|
.call();
|
|
|
|
assertEquals(
|
|
GetPinAuthPinContainer.builder()
|
|
.id(308667304L)
|
|
.code("7RQZ")
|
|
.product("Tautulli")
|
|
.qr("https://plex.tv/api/v2/pins/qr/7RQZ")
|
|
.clientIdentifier("Tautulli")
|
|
.location(GeoData.builder()
|
|
.code("VI")
|
|
.continentCode("NA")
|
|
.country("United States Virgin Islands")
|
|
.city("Amsterdam")
|
|
.timeZone("America/St_Thomas")
|
|
.postalCode("802")
|
|
.subdivisions("Saint Thomas")
|
|
.coordinates("18.3381, -64.8941")
|
|
.europeanUnionMember(true)
|
|
.inPrivacyRestrictedCountry(true)
|
|
.inPrivacyRestrictedRegion(true)
|
|
.build())
|
|
.createdAt(OffsetDateTime.parse("2024-07-16T17:03:05Z"))
|
|
.expiresAt(OffsetDateTime.parse("2024-07-16T17:18:05Z"))
|
|
.trusted(false)
|
|
.expiresIn(876L)
|
|
.authToken(JsonNullable.of(null))
|
|
.newRegistration(JsonNullable.of(null))
|
|
.build(),
|
|
res.authPinContainer().get());
|
|
}
|
|
|
|
@Disabled // test marked as skipped for java or generated unit tests not production ready yet
|
|
@Test
|
|
public void testPlex_GetTokenByPinId_() throws Exception {
|
|
|
|
|
|
PlexAPI sdk = PlexAPI.builder()
|
|
.clientID("gcgzw5rz2xovp84b4vha3a40")
|
|
.clientName("Plex Web")
|
|
.clientVersion("4.133.0")
|
|
.clientPlatform("Chrome")
|
|
.deviceName("Linux")
|
|
.build();
|
|
|
|
GetTokenByPinIdRequest req = GetTokenByPinIdRequest.builder()
|
|
.pinID(118274L)
|
|
.build();
|
|
|
|
GetTokenByPinIdResponse res = sdk.plex().getTokenByPinId()
|
|
.request(req)
|
|
.call();
|
|
|
|
assertEquals(
|
|
GetTokenByPinIdAuthPinContainer.builder()
|
|
.id(308667304L)
|
|
.code("7RQZ")
|
|
.product("Tautulli")
|
|
.qr("https://plex.tv/api/v2/pins/qr/7RQZ")
|
|
.clientIdentifier("Tautulli")
|
|
.location(GetTokenByPinIdGeoData.builder()
|
|
.code("VI")
|
|
.continentCode("NA")
|
|
.country("United States Virgin Islands")
|
|
.city("Amsterdam")
|
|
.timeZone("America/St_Thomas")
|
|
.postalCode("802")
|
|
.subdivisions("Saint Thomas")
|
|
.coordinates("18.3381, -64.8941")
|
|
.europeanUnionMember(true)
|
|
.inPrivacyRestrictedCountry(true)
|
|
.inPrivacyRestrictedRegion(true)
|
|
.build())
|
|
.createdAt(OffsetDateTime.parse("2024-07-16T17:03:05Z"))
|
|
.expiresAt(OffsetDateTime.parse("2024-07-16T17:18:05Z"))
|
|
.trusted(false)
|
|
.expiresIn(876L)
|
|
.authToken(JsonNullable.of(null))
|
|
.newRegistration(JsonNullable.of(null))
|
|
.build(),
|
|
res.authPinContainer().get());
|
|
}
|
|
|
|
} |