solarnetwork-api-core
    Preparing search index...

    Class EnvironmentConfig

    A network environment configuration utility object.

    This extends Util.Configuration to add support for standard properties needed to access the SolarNetwork API, such as host and protocol values.

    Hierarchy (View Summary)

    Index
    • Constructor.

      This will define the following default properties, if not supplied on the config argument:

      host
      `data.solarnetwork.net`
      protocol
      `https`
      port
      `443`

      These properties correspond to those on the window.location object when running in a browser. Thus to construct an environment based on the location of the current page you can create an instance like this:

      const env = new Environment(window.location);
      

      Parameters

      • Optionalconfig: Partial<HostConfigInfo>

        an optional set of properties to start with

      Returns EnvironmentConfig

    • get props(): Map<string, any>

      Get direct access to the underlying property map.

      Returns Map<string, any>

    • Set or toggle the enabled status of a given key.

      If the enabled parameter is not passed, then the enabled status will be toggled to its opposite value.

      Parameters

      • key: string

        the key to set

      • Optionalenabled: boolean

        the optional enabled value to set

      Returns this

      this object to allow method chaining

    • Check if TLS is in use via the https protocol.

      Returns boolean

      true if the protocol is set to https

    • Get a configuration value.

      Parameters

      • key: string

        the key to get

      Returns any

      the associated value for the given key

    • Set a configuration value.

      Parameters

      • key: string

        the key to get or set the value for

      • newValue: any

        the new value to set for the given key. If null then the value will be removed.

      Returns this

      this object.