Search in sources :

Example 1 with OrderPage

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

the class ApproveOrders method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param orderId the ID of the order to approve.
 * @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 orderId) throws RemoteException {
    // Get the OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to select an order.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", orderId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get orders by statement.
        OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Order order : page.getResults()) {
                System.out.printf("%d) Order with ID %d will be approved.%n", i++, order.getId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of orders to be approved: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202108.ApproveOrders action = new com.google.api.ads.admanager.axis.v202108.ApproveOrders();
        // Perform action.
        UpdateResult result = orderService.performOrderAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of orders approved: %d%n", result.getNumChanges());
        } else {
            System.out.println("No orders were approved.");
        }
    }
}
Also used : Order(com.google.api.ads.admanager.axis.v202108.Order) OrderPage(com.google.api.ads.admanager.axis.v202108.OrderPage) OrderServiceInterface(com.google.api.ads.admanager.axis.v202108.OrderServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) UpdateResult(com.google.api.ads.admanager.axis.v202108.UpdateResult)

Example 2 with OrderPage

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

the class GetAllOrders 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 OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to select all orders.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get orders by statement.
        OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Order order : page.getResults()) {
                System.out.printf("%d) Order with ID %d and name '%s' was found.%n", i++, order.getId(), order.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : Order(com.google.api.ads.admanager.axis.v202202.Order) OrderPage(com.google.api.ads.admanager.axis.v202202.OrderPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) OrderServiceInterface(com.google.api.ads.admanager.axis.v202202.OrderServiceInterface)

Example 3 with OrderPage

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

the class ApproveOrders method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param orderId the ID of the order to approve.
 * @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 orderId) throws RemoteException {
    // Get the OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to select an order.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", orderId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get orders by statement.
        OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Order order : page.getResults()) {
                System.out.printf("%d) Order with ID %d will be approved.%n", i++, order.getId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of orders to be approved: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202111.ApproveOrders action = new com.google.api.ads.admanager.axis.v202111.ApproveOrders();
        // Perform action.
        UpdateResult result = orderService.performOrderAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of orders approved: %d%n", result.getNumChanges());
        } else {
            System.out.println("No orders were approved.");
        }
    }
}
Also used : Order(com.google.api.ads.admanager.axis.v202111.Order) OrderPage(com.google.api.ads.admanager.axis.v202111.OrderPage) OrderServiceInterface(com.google.api.ads.admanager.axis.v202111.OrderServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) UpdateResult(com.google.api.ads.admanager.axis.v202111.UpdateResult)

Example 4 with OrderPage

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

the class GetAllOrders 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 OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to select all orders.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get orders by statement.
        OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Order order : page.getResults()) {
                System.out.printf("%d) Order with ID %d and name '%s' was found.%n", i++, order.getId(), order.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : Order(com.google.api.ads.admanager.axis.v202111.Order) OrderPage(com.google.api.ads.admanager.axis.v202111.OrderPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) OrderServiceInterface(com.google.api.ads.admanager.axis.v202111.OrderServiceInterface)

Example 5 with OrderPage

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

the class GetAllOrders 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 OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to select all orders.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get orders by statement.
        OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Order order : page.getResults()) {
                System.out.printf("%d) Order with ID %d and name '%s' was found.%n", i++, order.getId(), order.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : Order(com.google.api.ads.admanager.axis.v202205.Order) OrderPage(com.google.api.ads.admanager.axis.v202205.OrderPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) OrderServiceInterface(com.google.api.ads.admanager.axis.v202205.OrderServiceInterface)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)4 Order (com.google.api.ads.admanager.axis.v202108.Order)4 OrderPage (com.google.api.ads.admanager.axis.v202108.OrderPage)4 OrderServiceInterface (com.google.api.ads.admanager.axis.v202108.OrderServiceInterface)4 Order (com.google.api.ads.admanager.axis.v202111.Order)4 OrderPage (com.google.api.ads.admanager.axis.v202111.OrderPage)4 OrderServiceInterface (com.google.api.ads.admanager.axis.v202111.OrderServiceInterface)4 Order (com.google.api.ads.admanager.axis.v202202.Order)4 OrderPage (com.google.api.ads.admanager.axis.v202202.OrderPage)4 OrderServiceInterface (com.google.api.ads.admanager.axis.v202202.OrderServiceInterface)4 Order (com.google.api.ads.admanager.axis.v202205.Order)4 OrderPage (com.google.api.ads.admanager.axis.v202205.OrderPage)4 OrderServiceInterface (com.google.api.ads.admanager.axis.v202205.OrderServiceInterface)4 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202202.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202205.UpdateResult)1