in common/src/main/scala/com/gu/media/youtube/YouTubePartnerApi.scala [123:151]
private def updateClaim(atomId: String, claimId: String, assetId: String, videoId: String, blockAds: Boolean): Either[VideoUpdateError, String] = {
MAMLogger.info(s"Updating claim for $videoId", atomId, videoId)
val policy = getNewPolicy(blockAds)
val claim = new Claim()
.setAssetId(assetId)
.setVideoId(videoId)
.setPolicy(policy)
.setContentType("audiovisual")
try {
val request = partnerClient.claims
.patch(claimId, claim)
.setOnBehalfOfContentOwner(contentOwner)
YoutubeRequestLogger.logRequest(YoutubeApiType.PartnerApi, YoutubeRequestType.UpdateVideoClaim)
request.execute()
MAMLogger.info(s"Successfully updated claim for $videoId, setting blockAds to $blockAds", atomId, videoId)
Right(s"Updated claim for claim=$claimId asset=$assetId")
} catch {
case e: GoogleJsonResponseException => {
val error: GoogleJsonError = e.getDetails
MAMLogger.error(s"Failed to update claim. ${error.toString} ${error.getMessage}", atomId, videoId)
Left(VideoUpdateError(s"Error in claiming a video: ${error.toString()}", Some(error.getMessage)))
}
}
}