-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Java API example for listing TvCampaignDetail
PiperOrigin-RevId: 673471249
- Loading branch information
1 parent
3920f96
commit 605dda2
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...a/com/google/api/services/samples/dfareporting/tvcampaigndetails/GetTvCampaignDetail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2024 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.api.services.samples.dfareporting.tvcampaigndetails; | ||
|
||
import com.google.api.services.dfareporting.Dfareporting; | ||
import com.google.api.services.dfareporting.model.TvCampaignDetail; | ||
import com.google.api.services.dfareporting.model.TvCampaignTimepoint; | ||
import com.google.api.services.samples.dfareporting.DfaReportingFactory; | ||
|
||
/** This example illustrates how to get a TvCampaignDetail by ID. */ | ||
public class GetTvCampaignDetail { | ||
private static final String USER_PROFILE_ID = "INSERT_USER_PROFILE_ID_HERE"; | ||
private static final String ACCOUNT_ID = "INSERT_ACCOUNT_ID_HERE"; | ||
private static final String ID = "INSERT_TV_CAMPAIGN_DETAIL_ID_HERE"; | ||
|
||
public static void runExample(Dfareporting reporting, long profileId, long accountId, String id) | ||
throws Exception { | ||
|
||
TvCampaignDetail tvCampaignDetail = null; | ||
|
||
System.out.printf("Searching for TV campaign detail with ID: %s", id); | ||
// Create and execute the TV campaign detail get request. | ||
tvCampaignDetail = | ||
reporting.tvCampaignDetails().get(profileId, id).setAccountId(accountId).execute(); | ||
|
||
for (TvCampaignTimepoint timepoint : tvCampaignDetail.getTimepoints()) { | ||
System.out.printf( | ||
"Found timepoint with start date %s and date window %s for TvCampaignDetail with ID %s", | ||
timepoint.getStartDate(), timepoint.getDateWindow(), tvCampaignDetail.getId()); | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
Dfareporting reporting = DfaReportingFactory.getInstance(); | ||
|
||
long profileId = Long.parseLong(USER_PROFILE_ID); | ||
long accountId = Long.parseLong(ACCOUNT_ID); | ||
|
||
runExample(reporting, profileId, accountId, ID); | ||
} | ||
} |