Ejemplo n.º 1
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The Dfa user object running the code example.
        /// </param>
        public override void Run(DfaUser user)
        {
            // Create CreativeFieldRemoteService instance.
            CreativeFieldRemoteService service = (CreativeFieldRemoteService)user.GetService(
                DfaService.v1_20.CreativeFieldRemoteService);

            long   creativeFieldId        = long.Parse(_T("INSERT_CREATIVE_FIELD_ID_HERE"));
            String creativeFieldValueName = _T("INSERT_CREATIVE_FIELD_VALUE_NAME_HERE");

            // Create creative field value structure.
            CreativeFieldValue creativeFieldValue = new CreativeFieldValue();

            creativeFieldValue.id              = -1;
            creativeFieldValue.name            = creativeFieldValueName;
            creativeFieldValue.creativeFieldId = creativeFieldId;

            try {
                // Create creative field value.
                CreativeFieldValueSaveResult creativeFieldValueSaveResult =
                    service.saveCreativeFieldValue(creativeFieldValue);

                // Display creative field value id.
                Console.WriteLine("Creative field value with id \"{0}\" was created.",
                                  creativeFieldValueSaveResult.id);
            } catch (Exception ex) {
                Console.WriteLine("Failed to add creative field value. Exception says \"{0}\"",
                                  ex.Message);
            }
        }
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="service">An initialized Dfa Reporting service object
    /// </param>
    public override void Run(DfareportingService service) {
      long creativeFieldId = long.Parse(_T("INSERT_CREATIVE_FIELD_ID_HERE"));
      long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

      string creativeFieldValueName = _T("INSERT_CREATIVE_FIELD_VALUE_NAME_HERE");

      // Create the creative field value.
      CreativeFieldValue creativeFieldValue = new CreativeFieldValue();
      creativeFieldValue.Value = creativeFieldValueName;

      // Insert the creative field value.
      CreativeFieldValue result = service.CreativeFieldValues
          .Insert(creativeFieldValue, profileId, creativeFieldId).Execute();

      // Display the new creative field value ID.
      Console.WriteLine("Creative field value with ID {0} was created.", result.Id);
    }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long creativeFieldId = long.Parse(_T("INSERT_CREATIVE_FIELD_ID_HERE"));
            long profileId       = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            string creativeFieldValueName = _T("INSERT_CREATIVE_FIELD_VALUE_NAME_HERE");

            // Create the creative field value.
            CreativeFieldValue creativeFieldValue = new CreativeFieldValue();

            creativeFieldValue.Value = creativeFieldValueName;

            // Insert the creative field value.
            CreativeFieldValue result = service.CreativeFieldValues
                                        .Insert(creativeFieldValue, profileId, creativeFieldId).Execute();

            // Display the new creative field value ID.
            Console.WriteLine("Creative field value with ID {0} was created.", result.Id);
        }
        /// <summary>
        /// Updates an existing creative field value.
        /// Documentation https://developers.google.com/dfareporting/v2.6/reference/creativeFieldValues/update
        /// 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="creativeFieldId">Creative field ID for this creative field value.</param>
        /// <param name="body">A valid dfareporting v2.6 body.</param>
        /// <returns>CreativeFieldValueResponse</returns>
        public static CreativeFieldValue Update(dfareportingService service, string profileId, string creativeFieldId, CreativeFieldValue 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);
                }
                if (creativeFieldId == null)
                {
                    throw new ArgumentNullException(creativeFieldId);
                }

                // Make the request.
                return(service.CreativeFieldValues.Update(body, profileId, creativeFieldId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request CreativeFieldValues.Update failed.", ex);
            }
        }