Exemple #1
0
        private string ConvertResponsefieldsToString(HyvesGadgetResponsefield responsefields)
        {
            StringBuilder responsefieldsBuilder = new StringBuilder();

            if (responsefields == HyvesGadgetResponsefield.All)
            {
                responsefieldsBuilder.Append(EnumHelper.GetAllValuesAsString <HyvesGadgetResponsefield>());
            }
            else
            {
                var userResponsefields = Enum.GetValues(typeof(HyvesGadgetResponsefield));
                foreach (HyvesGadgetResponsefield responseField in userResponsefields)
                {
                    if (EnumHelper.HasFlag(responsefields, responseField))
                    {
                        responsefieldsBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(responseField)));
                    }
                }
            }

            responsefieldsBuilder = responsefieldsBuilder.Replace(
                string.Format("{0},", EnumHelper.GetDescription(HyvesGadgetResponsefield.All)), string.Empty);
            string returnValue = responsefieldsBuilder.ToString();

            return(returnValue.Substring(0, returnValue.Length - 1));
        }
Exemple #2
0
        /// <summary>
        /// Gets the desired information about the specified gadget. This corresponds to the
        /// gadgets.get Hyves method.
        /// </summary>
        /// <param name="gadgetId">The requested gadgetIds.</param>
        /// <param name="responsefields">Get extra information from the gadget.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified gadget; null if the call fails.</returns>
        public Collection <Gadget> GetGadgets(Collection <string> gadgetIds, HyvesGadgetResponsefield responsefields, bool useFancyLayout)
        {
            if (gadgetIds == null || gadgetIds.Count == 0)
            {
                throw new ArgumentNullException("gadgetIds");
            }

            StringBuilder gadgetIdBuilder = new StringBuilder();

            if (gadgetIds != null)
            {
                foreach (string id in gadgetIds)
                {
                    if (gadgetIdBuilder.Length != 0)
                    {
                        gadgetIdBuilder.Append(",");
                    }
                    gadgetIdBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["gadgetid"]          = gadgetIdBuilder.ToString();
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.GadgetsGet, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Gadget>("gadget"));
            }

            return(null);
        }
		/// <summary>
		/// Gets the desired information about the specified gadget. This corresponds to the
		/// gadgets.get Hyves method.
		/// </summary>
		/// <param name="gadgetId">The requested gadgetId.</param>
		/// <param name="responsefields">Get extra information from the gadget.</param>
		/// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
		/// <returns>The information about the specified gadget; null if the call fails.</returns>
		public Gadget GetGadget(string gadgetId, HyvesGadgetResponsefield responsefields, bool useFancyLayout)
		{
			if (string.IsNullOrEmpty(gadgetId))
			{
				throw new ArgumentNullException("gadgetId");
			}

			HyvesRequest request = new HyvesRequest(this.session);
			request.Parameters["gadgetid"] = gadgetId;
			request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

			HyvesResponse response = request.InvokeMethod(HyvesMethod.GadgetsGet, useFancyLayout);
			if (response.Status == HyvesResponseStatus.Succeeded)
			{
        return response.ProcessSingleItemResponse<Gadget>("gadget");
      }

			return null;
		}
Exemple #4
0
        /// <summary>
        /// Gets the desired information about the specified gadget. This corresponds to the
        /// gadgets.get Hyves method.
        /// </summary>
        /// <param name="gadgetId">The requested gadgetId.</param>
        /// <param name="responsefields">Get extra information from the gadget.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified gadget; null if the call fails.</returns>
        public Gadget GetGadget(string gadgetId, HyvesGadgetResponsefield responsefields, bool useFancyLayout)
        {
            if (string.IsNullOrEmpty(gadgetId))
            {
                throw new ArgumentNullException("gadgetId");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["gadgetid"]          = gadgetId;
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.GadgetsGet, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessSingleItemResponse <Gadget>("gadget"));
            }

            return(null);
        }
Exemple #5
0
        /// <summary>
        /// Gets the desired gadgets from the specified hub. This corresponds to the
        /// gadgets.getByHub Hyves method.
        /// </summary>
        /// <param name="hubId">The requested hub Id.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <param name="page">The requested page.</param>
        /// <param name="resultsPerPage">The number of results per page.</param>
        /// <returns>The information about the specified gadget; null if the call fails.</returns>
        public Collection <Gadget> GetGadgetsByHub(string hubId, HyvesGadgetResponsefield responsefields, bool useFancyLayout, int page, int resultsPerPage)
        {
            if (string.IsNullOrEmpty(hubId))
            {
                throw new ArgumentNullException("hubId");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["hubid"]             = hubId;
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.GadgetsGetByHub, useFancyLayout, page, resultsPerPage);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Gadget>("gadget"));
            }

            return(null);
        }
		/// <summary>
		/// Gets the desired information about the specified gadget. This corresponds to the
		/// gadgets.get Hyves method.
		/// </summary>
		/// <param name="gadgetId">The requested gadgetId.</param>
		/// <param name="responsefields">Get extra information from the gadget.</param>
		/// <returns>The information about the specified gadget; null if the call fails.</returns>
		public Gadget GetGadget(string gadgetId, HyvesGadgetResponsefield responsefield)
		{
			return GetGadget(gadgetId, responsefield, false);
		}
		private string ConvertResponsefieldsToString(HyvesGadgetResponsefield responsefields)
    {
      StringBuilder responsefieldsBuilder = new StringBuilder();
      if (responsefields == HyvesGadgetResponsefield.All)
      {
        responsefieldsBuilder.Append(EnumHelper.GetAllValuesAsString<HyvesGadgetResponsefield>());
      }
      else
      {
        var userResponsefields = Enum.GetValues(typeof(HyvesGadgetResponsefield));
        foreach (HyvesGadgetResponsefield responseField in userResponsefields)
        {
          if (EnumHelper.HasFlag(responsefields, responseField))
          {
            responsefieldsBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(responseField)));
          }
        }
      }

      responsefieldsBuilder = responsefieldsBuilder.Replace(
        string.Format("{0},", EnumHelper.GetDescription(HyvesGadgetResponsefield.All)), string.Empty);
      string returnValue = responsefieldsBuilder.ToString();
      return returnValue.Substring(0, returnValue.Length - 1);
		}
		/// <summary>
		/// Gets the desired gadgets from the specified hub. This corresponds to the
		/// gadgets.getByHub Hyves method.
		/// </summary>
		/// <param name="hubId">The requested hub Id.</param>
		/// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
		/// <param name="page">The requested page.</param>
		/// <param name="resultsPerPage">The number of results per page.</param>
		/// <returns>The information about the specified gadget; null if the call fails.</returns>
		public Collection<Gadget> GetGadgetsByHub(string hubId, HyvesGadgetResponsefield responsefields, bool useFancyLayout, int page, int resultsPerPage)
		{
			if (string.IsNullOrEmpty(hubId))
			{
				throw new ArgumentNullException("hubId");
			}

			HyvesRequest request = new HyvesRequest(this.session);
			request.Parameters["hubid"] = hubId;
			request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

			HyvesResponse response = request.InvokeMethod(HyvesMethod.GadgetsGetByHub, useFancyLayout, page, resultsPerPage);
			if (response.Status == HyvesResponseStatus.Succeeded)
      {
        return response.ProcessResponse<Gadget>("gadget");
			}

			return null;
		}
		/// <summary>
		/// Gets the desired gadgets from the specified hub. This corresponds to the
		/// gadgets.getByHub Hyves method.
		/// </summary>
		/// <param name="hubId">The requested hub Id.</param>
		/// <returns>The information about the specified gadget; null if the call fails.</returns>
		public Collection<Gadget> GetGadgetsByHub(string hubId, HyvesGadgetResponsefield responsefield)
		{
			return GetGadgetsByHub(hubId, responsefield, false, -1, -1);
		}
		/// <summary>
		/// Gets the desired gadgets from the specified user. This corresponds to the
		/// gadgets.getByUser Hyves method.
		/// </summary>
		/// <param name="userId">The requested user Id.</param>
		/// <returns>The information about the specified gadget; null if the call fails.</returns>
		public Collection<Gadget> GetGadgetsByUser(string userId, HyvesGadgetResponsefield responsefield)
		{
			return GetGadgetsByUser(userId, responsefield, false, -1, -1);
		}
		/// <summary>
		/// Gets the desired information about the specified gadget. This corresponds to the
		/// gadgets.get Hyves method.
		/// </summary>
		/// <param name="gadgetId">The requested gadgetIds.</param>
		/// <param name="responsefields">Get extra information from the gadget.</param>
		/// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
		/// <returns>The information about the specified gadget; null if the call fails.</returns>
		public Collection<Gadget> GetGadgets(Collection<string> gadgetIds, HyvesGadgetResponsefield responsefields, bool useFancyLayout)
		{
			if (gadgetIds == null || gadgetIds.Count == 0)
			{
				throw new ArgumentNullException("gadgetIds");
			}

			StringBuilder gadgetIdBuilder = new StringBuilder();
			if (gadgetIds != null)
			{
				foreach (string id in gadgetIds)
				{
					if (gadgetIdBuilder.Length != 0)
					{
						gadgetIdBuilder.Append(",");
					}
					gadgetIdBuilder.Append(id);
				}
			}

			HyvesRequest request = new HyvesRequest(this.session);
			request.Parameters["gadgetid"] = gadgetIdBuilder.ToString();
			request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

			HyvesResponse response = request.InvokeMethod(HyvesMethod.GadgetsGet, useFancyLayout);
			if (response.Status == HyvesResponseStatus.Succeeded)
      {
        return response.ProcessResponse<Gadget>("gadget");
			}

			return null;
		}
		/// <summary>
		/// Gets the desired information about the specified gadget. This corresponds to the
		/// gadgets.get Hyves method.
		/// </summary>
		/// <param name="gadgetId">The requested gadgetIds.</param>
		/// <param name="responsefields">Get extra information from the gadget.</param>
		/// <returns>The information about the specified gadget; null if the call fails.</returns>
		public Collection<Gadget> GetGadgets(Collection<string> gadgetIds, HyvesGadgetResponsefield responsefield)
		{
			return GetGadgets(gadgetIds, responsefield, false);
		}
Exemple #13
0
 /// <summary>
 /// Gets the desired information about the specified gadget. This corresponds to the
 /// gadgets.get Hyves method.
 /// </summary>
 /// <param name="gadgetId">The requested gadgetId.</param>
 /// <param name="responsefields">Get extra information from the gadget.</param>
 /// <returns>The information about the specified gadget; null if the call fails.</returns>
 public Gadget GetGadget(string gadgetId, HyvesGadgetResponsefield responsefield)
 {
     return(GetGadget(gadgetId, responsefield, false));
 }
Exemple #14
0
 /// <summary>
 /// Gets the desired gadgets from the specified hub. This corresponds to the
 /// gadgets.getByHub Hyves method.
 /// </summary>
 /// <param name="hubId">The requested hub Id.</param>
 /// <returns>The information about the specified gadget; null if the call fails.</returns>
 public Collection <Gadget> GetGadgetsByHub(string hubId, HyvesGadgetResponsefield responsefield)
 {
     return(GetGadgetsByHub(hubId, responsefield, false, -1, -1));
 }
Exemple #15
0
 /// <summary>
 /// Gets the desired gadgets from the specified user. This corresponds to the
 /// gadgets.getByUser Hyves method.
 /// </summary>
 /// <param name="userId">The requested user Id.</param>
 /// <returns>The information about the specified gadget; null if the call fails.</returns>
 public Collection <Gadget> GetGadgetsByUser(string userId, HyvesGadgetResponsefield responsefield)
 {
     return(GetGadgetsByUser(userId, responsefield, false, -1, -1));
 }
Exemple #16
0
 /// <summary>
 /// Gets the desired information about the specified gadget. This corresponds to the
 /// gadgets.get Hyves method.
 /// </summary>
 /// <param name="gadgetId">The requested gadgetIds.</param>
 /// <param name="responsefields">Get extra information from the gadget.</param>
 /// <returns>The information about the specified gadget; null if the call fails.</returns>
 public Collection <Gadget> GetGadgets(Collection <string> gadgetIds, HyvesGadgetResponsefield responsefield)
 {
     return(GetGadgets(gadgetIds, responsefield, false));
 }