Verifying Extension Environment and Client ID

Understanding SettingsService

The ISettingsService is an Interface that is used to get the company settings you’d find in the Corporate Admin > Settings > Advanced Settings page. It has a method called ExtensionContext() that refers to the ExtensionContext class that is used to obtain contextual information about the Client Extension’s hosting environment. This class has the following properties:

  • ClientId - Returns the ClientId for the current Extension environment.
  • EnvironmentType - Returns the environment type in which the Extension is hosted. EnvironmentType is an enum, and can be either Sandbox or Live.

Verifying Extension Environment

Depending on your client tier, you may have both Live and Stage (sandbox) environments. The same version of the Extension can run in both Stage and Live, although it is not required. It is possible to have a different version on Stage than on Live.

There are times when you may need to know which environment you’re running. For example, you have a third-party email system that you want to send messages when an Associate places an order. You only want this to happen in Live, so you say in your code, “if I’m in Live, send out this message.” Another scenario is where you must change outbound API calls based on which environment the code is running in.

To verify the Extension environment:

DirectScale.Disco.Extension.EnvironmentType envType = _settingsService.ExtensionContext().EnvironmentType;

Verifying Client ID

The Client ID is a client’s unique key chosen when they sign with DirectScale found in the Admin URL ({Client_ID}.admin.directscale.com). If you have a solution you use for multiple clients, and you want to use the same code (or a NuGet package that you can install on the Extension), you can discern which client is running the code:

string clientId = _settingsService.ExtensionContext().ClientId;  // IE, "demo"
Was this article helpful?
0 out of 0 found this helpful
Previous Next

Comments

0 comments

Please sign in to leave a comment.