Class WPSiteInfo

java.lang.Object
net.ygbstudio.powerwp4j.models.entities.WPSiteInfo

public final class WPSiteInfo extends Object
Holds the site information required to interact with a WordPress site.

Stores the WordPress base URI and application-password credentials.

Since:
0.1.0
  • Constructor Details

    • WPSiteInfo

      public WPSiteInfo(@NotNull @NotNull URI wpURI, @NotNull @NotNull String wpUser, @NotNull @NotNull String wpAppPass)
      Creates site info from a WordPress base URI and credentials.
      Parameters:
      wpURI - URI of the WordPress site (host, scheme and port are extracted)
      wpUser - username for the WordPress site
      wpAppPass - application password for the WordPress site
  • Method Details

    • apiBaseUrl

      @Contract(pure=true) @NotNull public @NotNull String apiBaseUrl()
      Returns the base URL of the WordPress REST API.
      Returns:
      the base URL of the WordPress REST API
    • fromConfigResource

      @NotNull public static @NotNull WPSiteInfo fromConfigResource(String fileName)
      Loads site info from a configuration resource properties file.
      Parameters:
      fileName - name of the resource file to load properties from
      Returns:
      site info loaded from the resource
      Throws:
      LocalConfigurationException - if the resource is missing or required properties are absent
    • fromEnv

      @NotNull public static @NotNull WPSiteInfo fromEnv()
      Loads site info from environment variables defined in EnvironmentScope.
      Returns:
      site info loaded from the environment
      Throws:
      LocalConfigurationException - if any required environment variable is unset
    • wpURI

      public URI wpURI()
      Returns the WordPress base URI.
      Returns:
      base URI of the WordPress site
    • wpUser

      public String wpUser()
      Returns the WordPress username.
      Returns:
      application username
    • wpAppPass

      public String wpAppPass()
      Returns the WordPress application password.
      Returns:
      application password
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object