Search in sources :

Example 61 with Statement

use of com.google.api.ads.admanager.axis.v202111.Statement in project googleads-java-lib by googleads.

the class UpdateUserTeamAssociations method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param userId the user ID of the user team association to update.
 * @param teamId the team ID of the user team association to update.
 * @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, long userId, long teamId) throws RemoteException {
    // Get the UserTeamAssociationService.
    UserTeamAssociationServiceInterface userTeamAssociationService = adManagerServices.get(session, UserTeamAssociationServiceInterface.class);
    // Create a statement to only select a single user team association by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("userId = :userId AND teamId = :teamId").orderBy("userId, teamId ASC").limit(1).withBindVariableValue("userId", userId).withBindVariableValue("teamId", teamId);
    // Get the user team association.
    UserTeamAssociationPage page = userTeamAssociationService.getUserTeamAssociationsByStatement(statementBuilder.toStatement());
    UserTeamAssociation userTeamAssociation = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the user's access type on the team.
    userTeamAssociation.setOverriddenTeamAccessType(TeamAccessType.READ_ONLY);
    // Update the user team associations on the server.
    UserTeamAssociation[] userTeamAssociations = userTeamAssociationService.updateUserTeamAssociations(new UserTeamAssociation[] { userTeamAssociation });
    for (UserTeamAssociation updatedUserTeamAssociation : userTeamAssociations) {
        System.out.printf("User team association with user ID %d and team ID %d was updated.%n", updatedUserTeamAssociation.getUserId(), updatedUserTeamAssociation.getTeamId());
    }
}
Also used : UserTeamAssociationServiceInterface(com.google.api.ads.admanager.axis.v202111.UserTeamAssociationServiceInterface) UserTeamAssociation(com.google.api.ads.admanager.axis.v202111.UserTeamAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) UserTeamAssociationPage(com.google.api.ads.admanager.axis.v202111.UserTeamAssociationPage)

Example 62 with Statement

use of com.google.api.ads.admanager.axis.v202111.Statement in project googleads-java-lib by googleads.

the class StatementBuilderTest method testFrom_stripsFrom.

@Test
public void testFrom_stripsFrom() {
    StatementBuilder statementBuilder = new StatementBuilder();
    Statement statement = statementBuilder.from("FROM line_item").toStatement();
    assertEquals("FROM line_item", statement.getQuery());
}
Also used : Statement(com.google.api.ads.admanager.axis.v202111.Statement) Test(org.junit.Test)

Example 63 with Statement

use of com.google.api.ads.admanager.axis.v202111.Statement in project googleads-java-lib by googleads.

the class StatementBuilderTest method testWhere.

@Test
public void testWhere() {
    StatementBuilder statementBuilder = new StatementBuilder();
    Statement statement = statementBuilder.where("id = 12345").toStatement();
    assertEquals("WHERE id = 12345", statement.getQuery());
}
Also used : Statement(com.google.api.ads.admanager.axis.v202111.Statement) Test(org.junit.Test)

Example 64 with Statement

use of com.google.api.ads.admanager.axis.v202111.Statement in project googleads-java-lib by googleads.

the class StatementBuilderTest method testBindVariables_text.

@Test
public void testBindVariables_text() {
    StatementBuilder statementBuilder = new StatementBuilder();
    Statement statement = statementBuilder.where("text = :text").withBindVariableValue("text", "foo").toStatement();
    String_ValueMapEntry entry = statement.getValues(0);
    assertEquals("text", entry.getKey());
    assertEquals(TextValue.class, entry.getValue().getClass());
    assertEquals("foo", ((TextValue) entry.getValue()).getValue());
}
Also used : String_ValueMapEntry(com.google.api.ads.admanager.axis.v202111.String_ValueMapEntry) Statement(com.google.api.ads.admanager.axis.v202111.Statement) Test(org.junit.Test)

Example 65 with Statement

use of com.google.api.ads.admanager.axis.v202111.Statement in project googleads-java-lib by googleads.

the class StatementBuilderTest method testLimitOffsetDefaults.

@Test
public void testLimitOffsetDefaults() {
    StatementBuilder statementBuilder = new StatementBuilder();
    Statement initialOffset = statementBuilder.limit(100).toStatement();
    assertEquals("LIMIT 100", initialOffset.getQuery());
    Statement increasedOffset = statementBuilder.increaseOffsetBy(100).toStatement();
    assertEquals("LIMIT 100 OFFSET 100", increasedOffset.getQuery());
}
Also used : Statement(com.google.api.ads.admanager.axis.v202111.Statement) Test(org.junit.Test)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)119 Test (org.junit.Test)77 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)18 Statement (com.google.api.ads.admanager.axis.v202105.Statement)16 Statement (com.google.api.ads.admanager.axis.v202108.Statement)16 Statement (com.google.api.ads.admanager.axis.v202111.Statement)16 Statement (com.google.api.ads.admanager.axis.v202202.Statement)16 Statement (com.google.api.ads.admanager.axis.v202205.Statement)16 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202111.CustomTargetingServiceInterface)8 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202111.InventoryServiceInterface)8 AdUnit (com.google.api.ads.admanager.axis.v202111.AdUnit)7 AdUnitPage (com.google.api.ads.admanager.axis.v202111.AdUnitPage)7 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202111.PublisherQueryLanguageServiceInterface)7 ResultSet (com.google.api.ads.admanager.axis.v202111.ResultSet)7 ArrayList (java.util.ArrayList)6 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface)5 Statement (org.neo4j.driver.v1.Statement)5 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202105.String_ValueMapEntry)4 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202108.String_ValueMapEntry)4 LineItem (com.google.api.ads.admanager.axis.v202111.LineItem)4