Search in sources :

Example 11 with OrderServiceInterface

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

the class UpdateOrders method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param orderId the ID of the order 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 orderId) throws RemoteException {
    // Get the OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to only select a single order by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", orderId);
    // Get the order.
    OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
    Order order = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the order's notes.
    order.setNotes("Spoke to advertiser. All is well.");
    // Update the order on the server.
    Order[] orders = orderService.updateOrders(new Order[] { order });
    for (Order updatedOrder : orders) {
        System.out.printf("Order with ID %d and name '%s' was updated.%n", updatedOrder.getId(), updatedOrder.getName());
    }
}
Also used : Order(com.google.api.ads.admanager.axis.v202108.Order) OrderPage(com.google.api.ads.admanager.axis.v202108.OrderPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) OrderServiceInterface(com.google.api.ads.admanager.axis.v202108.OrderServiceInterface)

Example 12 with OrderServiceInterface

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

the class CreateOrders method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param advertiserId the ID of the advertiser (company) that all creatives will be assigned to.
 * @param traffickerId the ID of the trafficker (user) associated with this order.
 * @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 advertiserId, long traffickerId) throws RemoteException {
    // Get the OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create an order.
    Order order = new Order();
    order.setName("Order #" + new Random().nextInt(Integer.MAX_VALUE));
    order.setAdvertiserId(advertiserId);
    order.setTraffickerId(traffickerId);
    // Create the order on the server.
    Order[] orders = orderService.createOrders(new Order[] { order });
    for (Order createdOrder : orders) {
        System.out.printf("An order with ID %d and name '%s' was created.%n", createdOrder.getId(), createdOrder.getName());
    }
}
Also used : Order(com.google.api.ads.admanager.axis.v202108.Order) Random(java.util.Random) OrderServiceInterface(com.google.api.ads.admanager.axis.v202108.OrderServiceInterface)

Example 13 with OrderServiceInterface

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

the class GetOrdersStartingSoon 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 {
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to select orders.
    StatementBuilder statementBuilder = new StatementBuilder().where("status = :status and startDateTime >= :now and startDateTime <= :soon").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", OrderStatus.APPROVED.toString()).withBindVariableValue("now", DateTimes.toDateTime(Instant.now(), "America/New_York")).withBindVariableValue("soon", DateTimes.toDateTime(Instant.now().plus(Duration.standardDays(5L)), "America/New_York"));
    // Retrieve a small amount of orders at a time, paging through
    // until all orders have been retrieved.
    int totalResultSetSize = 0;
    do {
        OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each order.
            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.v202108.Order) OrderPage(com.google.api.ads.admanager.axis.v202108.OrderPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) OrderServiceInterface(com.google.api.ads.admanager.axis.v202108.OrderServiceInterface)

Example 14 with OrderServiceInterface

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

the class GetOrdersStartingSoon 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 {
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to select orders.
    StatementBuilder statementBuilder = new StatementBuilder().where("status = :status and startDateTime >= :now and startDateTime <= :soon").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", OrderStatus.APPROVED.toString()).withBindVariableValue("now", DateTimes.toDateTime(Instant.now(), "America/New_York")).withBindVariableValue("soon", DateTimes.toDateTime(Instant.now().plus(Duration.standardDays(5L)), "America/New_York"));
    // Retrieve a small amount of orders at a time, paging through
    // until all orders have been retrieved.
    int totalResultSetSize = 0;
    do {
        OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each order.
            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 15 with OrderServiceInterface

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

the class UpdateOrders method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param orderId the ID of the order 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 orderId) throws RemoteException {
    // Get the OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to only select a single order by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", orderId);
    // Get the order.
    OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
    Order order = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the order's notes.
    order.setNotes("Spoke to advertiser. All is well.");
    // Update the order on the server.
    Order[] orders = orderService.updateOrders(new Order[] { order });
    for (Order updatedOrder : orders) {
        System.out.printf("Order with ID %d and name '%s' was updated.%n", updatedOrder.getId(), updatedOrder.getName());
    }
}
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)

Aggregations

Order (com.google.api.ads.admanager.axis.v202108.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202108.OrderServiceInterface)5 Order (com.google.api.ads.admanager.axis.v202111.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202111.OrderServiceInterface)5 Order (com.google.api.ads.admanager.axis.v202202.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202202.OrderServiceInterface)5 Order (com.google.api.ads.admanager.axis.v202205.Order)5 OrderServiceInterface (com.google.api.ads.admanager.axis.v202205.OrderServiceInterface)5 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 OrderPage (com.google.api.ads.admanager.axis.v202108.OrderPage)4 OrderPage (com.google.api.ads.admanager.axis.v202111.OrderPage)4 OrderPage (com.google.api.ads.admanager.axis.v202202.OrderPage)4 OrderPage (com.google.api.ads.admanager.axis.v202205.OrderPage)4 Random (java.util.Random)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