/// <summary> /// Updates existing conversions. /// Documentation https://developers.google.com/dfareporting/v2.8/reference/conversions/batchupdate /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated Dfareporting service.</param> /// <param name="profileId">User profile ID associated with this request.</param> /// <param name="body">A valid Dfareporting v2.8 body.</param> /// <returns>ConversionsBatchUpdateResponseResponse</returns> public static ConversionsBatchUpdateResponse Batchupdate(DfareportingService service, string profileId, ConversionsBatchUpdateRequest body) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } if (profileId == null) { throw new ArgumentNullException(profileId); } // Make the request. return(service.Conversions.Batchupdate(body, profileId).Execute()); } catch (Exception ex) { throw new Exception("Request Conversions.Batchupdate failed.", ex); } }
/// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE")); // Values that identify the existing conversion. long floodlightActivityId = long.Parse(_T("INSERT_FLOODLIGHT_ACTIVITY_ID_HERE")); long conversionTimestamp = long.Parse(_T("INSERT_CONVERSION_TIMESTAMP_HERE")); string conversionOrdinal = _T("INSERT_CONVERSION_ORDINAL_VALUE_HERE"); string conversionMobileId = _T("INSERT_CONVERSION_MOBILE_ID_HERE"); // Values to update for the specified conversion. long newQuantity = long.Parse(_T("INSERT_NEW_CONVERSION_QUANTITY_HERE")); long newValue = long.Parse(_T("INSERT_NEW_CONVERSION_VALUE_HERE")); // Find the Floodlight configuration ID based on the provided activity ID. FloodlightActivity floodlightActivity = service.FloodlightActivities.Get(profileId, floodlightActivityId).Execute(); long floodlightConfigurationId = (long)floodlightActivity.FloodlightConfigurationId; // Construct the conversion object with values that identify the conversion to update. Conversion conversion = new Conversion(); conversion.MobileDeviceId = conversionMobileId; conversion.FloodlightActivityId = floodlightActivityId; conversion.FloodlightConfigurationId = floodlightConfigurationId; conversion.Ordinal = conversionOrdinal; conversion.TimestampMicros = conversionTimestamp; // Set the fields to be updated. These fields are required; to preserve a value from the // existing conversion, it must be copied over manually. conversion.Quantity = newQuantity; conversion.Value = newValue; // Update the conversion. ConversionsBatchUpdateRequest request = new ConversionsBatchUpdateRequest(); request.Conversions = new List <Conversion>() { conversion }; ConversionsBatchUpdateResponse response = service.Conversions.Batchupdate(request, profileId).Execute(); // Handle the batchupdate response. if (!response.HasFailures.Value) { Console.WriteLine("Successfully updated conversion for mobile device ID {0}.", conversionMobileId); } else { Console.WriteLine("Error(s) updating conversion for mobile device ID {0}:", conversionMobileId); ConversionStatus status = response.Status[0]; foreach (ConversionError error in status.Errors) { Console.WriteLine("\t[{0}]: {1}", error.Code, error.Message); } } }
/// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE")); // Value that specify how the existing conversion is encrypted. long encryptionEntityId = long.Parse(_T("INSERT_ENCRYPTION_ENTITY_TYPE")); string encryptionEntityType = _T("INSERT_ENCRYPTION_ENTITY_TYPE_HERE"); string encryptionSource = _T("INSERT_ENCRYPTION_SOURCE_HERE"); // Values that identify the existing conversion. long floodlightActivityId = long.Parse(_T("INSERT_FLOODLIGHT_ACTIVITY_ID_HERE")); long conversionTimestamp = long.Parse(_T("INSERT_CONVERSION_TIMESTAMP_HERE")); string conversionOrdinal = _T("INSERT_CONVERSION_ORDINAL_VALUE_HERE"); string conversionUserId = _T("INSERT_CONVERSION_USER_ID_HERE"); // Values to update for the specified conversion. long newQuantity = long.Parse(_T("INSERT_NEW_CONVERSION_QUANTITY_HERE")); long newValue = long.Parse(_T("INSERT_NEW_CONVERSION_VALUE_HERE")); // [START create_conversion] MOE:strip_line // Find the Floodlight configuration ID based on the provided activity ID. FloodlightActivity floodlightActivity = service.FloodlightActivities.Get(profileId, floodlightActivityId).Execute(); long floodlightConfigurationId = (long)floodlightActivity.FloodlightConfigurationId; // Construct the conversion object with values that identify the conversion to update. Conversion conversion = new Conversion(); conversion.EncryptedUserId = conversionUserId; conversion.FloodlightActivityId = floodlightActivityId; conversion.FloodlightConfigurationId = floodlightConfigurationId; conversion.Ordinal = conversionOrdinal; conversion.TimestampMicros = conversionTimestamp; // Set the fields to be updated. These fields are required; to preserve a value from the // existing conversion, it must be copied over manually. conversion.Quantity = newQuantity; conversion.Value = newValue; // [END create_conversion] MOE:strip_line // [START create_encryption_info] MOE:strip_line // Create the encryption info. EncryptionInfo encryptionInfo = new EncryptionInfo(); encryptionInfo.EncryptionEntityId = encryptionEntityId; encryptionInfo.EncryptionEntityType = encryptionEntityType; encryptionInfo.EncryptionSource = encryptionSource; // [END create_encryption_info] MOE:strip_line // [START update_conversion] MOE:strip_line // Insert the conversion. ConversionsBatchUpdateRequest request = new ConversionsBatchUpdateRequest(); request.Conversions = new List <Conversion>() { conversion }; request.EncryptionInfo = encryptionInfo; ConversionsBatchUpdateResponse response = service.Conversions.Batchupdate(request, profileId).Execute(); // [END update_conversion] MOE:strip_line // [START process_response] MOE:strip_line // Handle the batchinsert response. if (!response.HasFailures.Value) { Console.WriteLine("Successfully updated conversion for encrypted user ID {0}.", conversionUserId); } else { Console.WriteLine("Error(s) updating conversion for encrypted user ID {0}:", conversionUserId); ConversionStatus status = response.Status[0]; foreach (ConversionError error in status.Errors) { Console.WriteLine("\t[{0}]: {1}", error.Code, error.Message); } } // [END process_response] MOE:strip_line }