ConfigService

public interface ConfigService

Config service, manages SMS Configs. A config represents the way a particular user connects to an SMS provider. See org.motechproject.sms.configs.Config

Methods

getConfig

Config getConfig(String name)

Returns the confguration with the given name.

Parameters:
  • name – the name of the configuration
Throws:
Returns:

the config with the given name, never null

getConfigList

List<Config> getConfigList()

Returns a collection containing all SMS configurations from the system.

Returns:all SMS configurations

getConfigOrDefault

Config getConfigOrDefault(String name)

Returns the config with the given name, or the default config if the provided name is null or empty.

Parameters:
  • name – the name of the desired configuration, or null/empty string for the default configuration
Throws:
Returns:

the matching configuration

getConfigs

Configs getConfigs()

Returns an object containing all SMS configurations from the system.

Returns:all SMS configurations

getDefaultConfig

Config getDefaultConfig()

Returns the default configuration for sending SMS message. Only one of the configurations can be marked as the default by the user.

Throws:
Returns:

the default configuration, never null

getServerUrl

String getServerUrl()

Returns the base url to this MOTECH server. The url is read from the platform settings.

Returns:the base url to this MOTECH server

hasConfig

boolean hasConfig(String name)

Checks whether a configuration with the given name exists.

Parameters:
  • name – the name of the configuration to check
Returns:

true if the configuration exists, false otherwise

hasConfigs

boolean hasConfigs()

Checks whether there are no configurations available.

Returns:true if there are no configurations, false otherwise

updateConfigs

void updateConfigs(Configs configs)

Updates the SMS configs using the provided object. The configuration will be persisted with the Motech config system. Configurations which are no longer part of the provided object will be dropped.

Parameters:
  • configs – an object containing all the SMS configurations