Skip to content

Java 11+ client for the Apex Legends API and Origin's XMPP server

License

Notifications You must be signed in to change notification settings

RobertoGraham/nadir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central

nadir

Features

  • Get UID of authenticated account
  • Get UIDs of other accounts by their usernames
  • Lazily reestablishes authentication session
  • Can establish connection to Origin's XMPP server

Usage

Get UID of authenticated account

import io.github.robertograham.nadir.Account;
import io.github.robertograham.nadir.Nadir;

import java.io.IOException;

public final class Main {

    public static void main(final String[] args) {
        try (final var nadir = Nadir.newNadir("emailAddress", "password")) {
            nadir.accounts()
                .findOneBySessionToken()
                .map(Account::userId)
                .ifPresent(System.out::println);
        } catch (final IOException exception) {
            exception.printStackTrace();
        }
    }
}

Get UID of other account by its username

import io.github.robertograham.nadir.Account;
import io.github.robertograham.nadir.Nadir;

import java.io.IOException;

public final class Main {

    public static void main(final String[] args) {
        try (final var nadir = Nadir.newNadir("emailAddress", "password")) {
            final var usernameString = "DiegosaursTTV";
            nadir.accounts()
                .findAllBySearchTerms(usernameString)
                .flatMap((final var accountList) -> accountList.stream()
                    .filter((final var account) -> usernameString.equalsIgnoreCase(account.username()))
                    .findFirst()
                    .map(Account::userId))
                .ifPresent(System.out::println);
        } catch (final IOException exception) {
            exception.printStackTrace();
        }
    }
}

Establish connection to Origin's XMPP server

import io.github.robertograham.nadir.Nadir;
import org.jivesoftware.smack.AbstractXMPPConnection;

import java.io.IOException;

public final class Main {

    public static void main(final String[] args) {
        try (final var nadir = Nadir.newBuilder("emailAddress", "password")
            .establishXmppConnection(true)
            .debugXmppTraffic(true)
            .build()) {
            nadir.xmppConnection()
                .map(AbstractXMPPConnection::isAuthenticated)
                .ifPresent(System.out::println);
        } catch (final IOException exception) {
            exception.printStackTrace();
        }
    }
}