use of com.google.api.ads.admanager.axis.v202205.CustomFieldOption in project googleads-java-lib by googleads.
the class CreateCustomFieldsAndOptions method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
// Get the CustomFieldService.
CustomFieldServiceInterface customFieldService = adManagerServices.get(session, CustomFieldServiceInterface.class);
// Create a number custom field that can be used for an external ID in the
// API.
CustomField numberCustomField = new CustomField();
numberCustomField.setName("External ID #" + new Random().nextInt(Integer.MAX_VALUE));
numberCustomField.setEntityType(CustomFieldEntityType.LINE_ITEM);
numberCustomField.setDataType(CustomFieldDataType.NUMBER);
numberCustomField.setVisibility(CustomFieldVisibility.API_ONLY);
// Create a drop-down custom field that can be used in the UI.
CustomField dropDownCustomField = new CustomField();
dropDownCustomField.setName("Internal approval status #" + new Random().nextInt(Integer.MAX_VALUE));
dropDownCustomField.setEntityType(CustomFieldEntityType.LINE_ITEM);
dropDownCustomField.setDataType(CustomFieldDataType.DROP_DOWN);
dropDownCustomField.setVisibility(CustomFieldVisibility.FULL);
// Create the custom fields on the server.
CustomField[] customFields = customFieldService.createCustomFields(new CustomField[] { numberCustomField, dropDownCustomField });
for (CustomField createdCustomField : customFields) {
System.out.printf("A custom field with ID %d and name '%s' was created.%n", createdCustomField.getId(), createdCustomField.getName());
}
// Set the created drop-down custom field.
dropDownCustomField = customFields[1];
// Create approved custom field option.
CustomFieldOption approvedCustomFieldOption = new CustomFieldOption();
approvedCustomFieldOption.setDisplayName("APPROVED");
approvedCustomFieldOption.setCustomFieldId(dropDownCustomField.getId());
// Create unapproved custom field option.
CustomFieldOption unapprovedCustomFieldOption = new CustomFieldOption();
unapprovedCustomFieldOption.setDisplayName("UNAPPROVED");
unapprovedCustomFieldOption.setCustomFieldId(dropDownCustomField.getId());
// Create the custom field options on the server.
CustomFieldOption[] customFieldOptions = customFieldService.createCustomFieldOptions(new CustomFieldOption[] { approvedCustomFieldOption, unapprovedCustomFieldOption });
for (CustomFieldOption createdCustomFieldOption : customFieldOptions) {
System.out.printf("A custom field option with ID %d and display name '%s' was created.%n", createdCustomFieldOption.getId(), createdCustomFieldOption.getDisplayName());
}
}
use of com.google.api.ads.admanager.axis.v202205.CustomFieldOption in project googleads-java-lib by googleads.
the class CreateCustomFieldsAndOptions method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
// Get the CustomFieldService.
CustomFieldServiceInterface customFieldService = adManagerServices.get(session, CustomFieldServiceInterface.class);
// Create a number custom field that can be used for an external ID in the
// API.
CustomField numberCustomField = new CustomField();
numberCustomField.setName("External ID #" + new Random().nextInt(Integer.MAX_VALUE));
numberCustomField.setEntityType(CustomFieldEntityType.LINE_ITEM);
numberCustomField.setDataType(CustomFieldDataType.NUMBER);
numberCustomField.setVisibility(CustomFieldVisibility.API_ONLY);
// Create a drop-down custom field that can be used in the UI.
CustomField dropDownCustomField = new CustomField();
dropDownCustomField.setName("Internal approval status #" + new Random().nextInt(Integer.MAX_VALUE));
dropDownCustomField.setEntityType(CustomFieldEntityType.LINE_ITEM);
dropDownCustomField.setDataType(CustomFieldDataType.DROP_DOWN);
dropDownCustomField.setVisibility(CustomFieldVisibility.FULL);
// Create the custom fields on the server.
CustomField[] customFields = customFieldService.createCustomFields(new CustomField[] { numberCustomField, dropDownCustomField });
for (CustomField createdCustomField : customFields) {
System.out.printf("A custom field with ID %d and name '%s' was created.%n", createdCustomField.getId(), createdCustomField.getName());
}
// Set the created drop-down custom field.
dropDownCustomField = customFields[1];
// Create approved custom field option.
CustomFieldOption approvedCustomFieldOption = new CustomFieldOption();
approvedCustomFieldOption.setDisplayName("APPROVED");
approvedCustomFieldOption.setCustomFieldId(dropDownCustomField.getId());
// Create unapproved custom field option.
CustomFieldOption unapprovedCustomFieldOption = new CustomFieldOption();
unapprovedCustomFieldOption.setDisplayName("UNAPPROVED");
unapprovedCustomFieldOption.setCustomFieldId(dropDownCustomField.getId());
// Create the custom field options on the server.
CustomFieldOption[] customFieldOptions = customFieldService.createCustomFieldOptions(new CustomFieldOption[] { approvedCustomFieldOption, unapprovedCustomFieldOption });
for (CustomFieldOption createdCustomFieldOption : customFieldOptions) {
System.out.printf("A custom field option with ID %d and display name '%s' was created.%n", createdCustomFieldOption.getId(), createdCustomFieldOption.getDisplayName());
}
}
use of com.google.api.ads.admanager.axis.v202205.CustomFieldOption in project googleads-java-lib by googleads.
the class CreateCustomFieldsAndOptions method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
// Get the CustomFieldService.
CustomFieldServiceInterface customFieldService = adManagerServices.get(session, CustomFieldServiceInterface.class);
// Create a number custom field that can be used for an external ID in the
// API.
CustomField numberCustomField = new CustomField();
numberCustomField.setName("External ID #" + new Random().nextInt(Integer.MAX_VALUE));
numberCustomField.setEntityType(CustomFieldEntityType.LINE_ITEM);
numberCustomField.setDataType(CustomFieldDataType.NUMBER);
numberCustomField.setVisibility(CustomFieldVisibility.API_ONLY);
// Create a drop-down custom field that can be used in the UI.
CustomField dropDownCustomField = new CustomField();
dropDownCustomField.setName("Internal approval status #" + new Random().nextInt(Integer.MAX_VALUE));
dropDownCustomField.setEntityType(CustomFieldEntityType.LINE_ITEM);
dropDownCustomField.setDataType(CustomFieldDataType.DROP_DOWN);
dropDownCustomField.setVisibility(CustomFieldVisibility.FULL);
// Create the custom fields on the server.
CustomField[] customFields = customFieldService.createCustomFields(new CustomField[] { numberCustomField, dropDownCustomField });
for (CustomField createdCustomField : customFields) {
System.out.printf("A custom field with ID %d and name '%s' was created.%n", createdCustomField.getId(), createdCustomField.getName());
}
// Set the created drop-down custom field.
dropDownCustomField = customFields[1];
// Create approved custom field option.
CustomFieldOption approvedCustomFieldOption = new CustomFieldOption();
approvedCustomFieldOption.setDisplayName("APPROVED");
approvedCustomFieldOption.setCustomFieldId(dropDownCustomField.getId());
// Create unapproved custom field option.
CustomFieldOption unapprovedCustomFieldOption = new CustomFieldOption();
unapprovedCustomFieldOption.setDisplayName("UNAPPROVED");
unapprovedCustomFieldOption.setCustomFieldId(dropDownCustomField.getId());
// Create the custom field options on the server.
CustomFieldOption[] customFieldOptions = customFieldService.createCustomFieldOptions(new CustomFieldOption[] { approvedCustomFieldOption, unapprovedCustomFieldOption });
for (CustomFieldOption createdCustomFieldOption : customFieldOptions) {
System.out.printf("A custom field option with ID %d and display name '%s' was created.%n", createdCustomFieldOption.getId(), createdCustomFieldOption.getDisplayName());
}
}
use of com.google.api.ads.admanager.axis.v202205.CustomFieldOption in project googleads-java-lib by googleads.
the class CreateCustomFieldsAndOptions method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
// Get the CustomFieldService.
CustomFieldServiceInterface customFieldService = adManagerServices.get(session, CustomFieldServiceInterface.class);
// Create a number custom field that can be used for an external ID in the
// API.
CustomField numberCustomField = new CustomField();
numberCustomField.setName("External ID #" + new Random().nextInt(Integer.MAX_VALUE));
numberCustomField.setEntityType(CustomFieldEntityType.LINE_ITEM);
numberCustomField.setDataType(CustomFieldDataType.NUMBER);
numberCustomField.setVisibility(CustomFieldVisibility.API_ONLY);
// Create a drop-down custom field that can be used in the UI.
CustomField dropDownCustomField = new CustomField();
dropDownCustomField.setName("Internal approval status #" + new Random().nextInt(Integer.MAX_VALUE));
dropDownCustomField.setEntityType(CustomFieldEntityType.LINE_ITEM);
dropDownCustomField.setDataType(CustomFieldDataType.DROP_DOWN);
dropDownCustomField.setVisibility(CustomFieldVisibility.FULL);
// Create the custom fields on the server.
CustomField[] customFields = customFieldService.createCustomFields(new CustomField[] { numberCustomField, dropDownCustomField });
for (CustomField createdCustomField : customFields) {
System.out.printf("A custom field with ID %d and name '%s' was created.%n", createdCustomField.getId(), createdCustomField.getName());
}
// Set the created drop-down custom field.
dropDownCustomField = customFields[1];
// Create approved custom field option.
CustomFieldOption approvedCustomFieldOption = new CustomFieldOption();
approvedCustomFieldOption.setDisplayName("APPROVED");
approvedCustomFieldOption.setCustomFieldId(dropDownCustomField.getId());
// Create unapproved custom field option.
CustomFieldOption unapprovedCustomFieldOption = new CustomFieldOption();
unapprovedCustomFieldOption.setDisplayName("UNAPPROVED");
unapprovedCustomFieldOption.setCustomFieldId(dropDownCustomField.getId());
// Create the custom field options on the server.
CustomFieldOption[] customFieldOptions = customFieldService.createCustomFieldOptions(new CustomFieldOption[] { approvedCustomFieldOption, unapprovedCustomFieldOption });
for (CustomFieldOption createdCustomFieldOption : customFieldOptions) {
System.out.printf("A custom field option with ID %d and display name '%s' was created.%n", createdCustomFieldOption.getId(), createdCustomFieldOption.getDisplayName());
}
}
Aggregations