com.google.api.ads.dfa.lib.client
Class DfaSession.Builder

java.lang.Object
  extended by com.google.api.ads.dfa.lib.client.DfaSession.Builder
All Implemented Interfaces:
Builder<DfaSession>
Enclosing class:
DfaSession

public static class DfaSession.Builder
extends Object
implements Builder<DfaSession>

Builder for DfaSession.


Field Summary
 
Fields inherited from interface com.google.api.ads.common.lib.utils.Builder
DEFAULT_CONFIGURATION_FILENAME
 
Constructor Summary
DfaSession.Builder()
          Constructor.
 
Method Summary
 DfaSession build()
          Builds the DfaSession.
 DfaSession.Builder from(org.apache.commons.configuration.Configuration config)
          Reads properties from the provided Configuration object.

Known properties: api.dfa.username api.dfa.password api.dfa.applicationName api.dfa.token api.dfa.environment, e.g.
 DfaSession.Builder fromFile()
          Loads credentials from "ads.properties" file in one of the following locations according to the following order: in the current directory, in the user home directory, in the classpath
 DfaSession.Builder fromFile(File path)
          Populates this builder from a properties file from a specified path.
 DfaSession.Builder fromFile(String path)
          Populates this builder from a properties file from a specified path.
 DfaSession.Builder fromFile(URL path)
          Populates this builder from a properties file from a specified path.
 DfaSession.Builder withApplicationName(String applicationName)
          Includes application name.
 DfaSession.Builder withEndpoint(String endpoint)
          Override the endpoint server.
 DfaSession.Builder withEnvironment(DfaSession.Environment environment)
          Includes the specified environment, e.g.
 DfaSession.Builder withUsernameAndPassword(String username, String password)
          Includes username and password.
 DfaSession.Builder withUsernameAndToken(String username, String token)
          Includes a username with a hard-coded token to be used instead of fetching a new one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DfaSession.Builder

public DfaSession.Builder()
Constructor.

Method Detail

fromFile

public DfaSession.Builder fromFile()
                            throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Loads credentials from "ads.properties" file in one of the following locations according to the following order: in the current directory, in the user home directory, in the classpath

Specified by:
fromFile in interface Builder<DfaSession>
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

fromFile

public DfaSession.Builder fromFile(String path)
                            throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Populates this builder from a properties file from a specified path. If not absolute, will look in user home directory, the current classpath and the system classpath.

Specified by:
fromFile in interface Builder<DfaSession>
Parameters:
path - the path to try first as a resource, then as a file
Returns:
Builder populated with properties.
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

fromFile

public DfaSession.Builder fromFile(File path)
                            throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Populates this builder from a properties file from a specified path.

Specified by:
fromFile in interface Builder<DfaSession>
Parameters:
path - the path to load properties from
Returns:
Builder populated with properties.
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

fromFile

public DfaSession.Builder fromFile(URL path)
                            throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Populates this builder from a properties file from a specified path. If not absolute, will look in user home directory, the current classpath and the system classpath.

Specified by:
fromFile in interface Builder<DfaSession>
Parameters:
path - the path to try first as a resource, then as a file
Returns:
Builder populated with properties.
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

from

public DfaSession.Builder from(org.apache.commons.configuration.Configuration config)
Reads properties from the provided Configuration object.

Known properties:

Specified by:
from in interface Builder<DfaSession>
Parameters:
config -
Returns:
Builder populated from the Configuration

withEnvironment

public DfaSession.Builder withEnvironment(DfaSession.Environment environment)
Includes the specified environment, e.g. DfaSession.Environment.TEST The environment and endpoint in DFA are currently synonymous. Setting an environment will clear out any endpoint you have previously set.


withEndpoint

public DfaSession.Builder withEndpoint(String endpoint)
Override the endpoint server. The environment and endpoint in DFA are currently synonymous. Setting an endpoint will clear out any environment you have previously set.


withUsernameAndPassword

public DfaSession.Builder withUsernameAndPassword(String username,
                                                  String password)
Includes username and password.


withUsernameAndToken

public DfaSession.Builder withUsernameAndToken(String username,
                                               String token)
Includes a username with a hard-coded token to be used instead of fetching a new one.


withApplicationName

public DfaSession.Builder withApplicationName(String applicationName)
Includes application name.


build

public DfaSession build()
                 throws ValidationException
Builds the DfaSession.

Specified by:
build in interface Builder<DfaSession>
Returns:
the built DfaSession
Throws:
ValidationException - if the DfaSession did not validate


Copyright © 2012. All Rights Reserved.