Class: NSCredential

nationscript/requests/base~NSCredential(nation, passwordnullable, autologinnullable)

Helper class for saving login credentials of a nation.

If passed to an NSRequest that authenticates with the NS API upon execution, the autologin and pin properties of the passed instance are updated automatically from the API's response, so ideally there should be only a single instance for any one nation, so that the PIN can be properly kept.

Constructor

new NSCredential(nation, passwordnullable, autologinnullable)

Creates a new NSCredential instance with the given details.

Parameters:
Name Type Attributes Default Description
nation string

Name of the nation the login credentials are for

password string <nullable>
null

Password for the nation

autologin string <nullable>
null

Autologin code for the nation

Members

(nullable) autologin :string

The nation's password in encrypted form, as provided by NationStates.

Type:
  • string

nation :string

Name of the nation the login credentials are for.

Type:
  • string

(nullable) password :string

The nation's password.

Type:
  • string

(nullable) pin :string

The login PIN of the current session. Valid until the nation next logins without it, logs out, or is idle for two hours.

Type:
  • string

Methods

updateFromResponse(responseHeaders)

Updates the autologin and PIN data from the provided header data.

Parameters:
Name Type Description
responseHeaders http.IncomingHttpHeaders

HTTP headers returned by the NS API.