/// <summary> /// Sets the data of a request. This is a low level method. You would usually /// one of the other overloads of this method to send text or JSON data. /// </summary> /// <param name="body">The body data of the request.</param> /// <returns>Returns this <see cref="UnityAgentRequest"/> object so that calls can be chained.</returns> public UnityAgentRequest Send(UnityAgentDataType data) { if (_data != null) { throw new Exception("Cannot send more than data type objects"); } else { _data = data; } return(this); }
/// <summary> /// Sets the body data of the request as a JSON object. This method assumes the use of /// the application/x-www-form-urlencoded data type (<see cref="UnityAgentFormDataType"/>) and /// will append the data each time this method is called seperated by an ampersand. /// To set a custom data type use the other overloads. /// </summary> /// <param name="data">The body data of the request.</param> /// <returns>Returns this <see cref="UnityAgentRequest"/> object so that calls can be chained.</returns> public UnityAgentRequest Send(JsonData data) { if (_data == null) { var jsonDataPayload = new UnityAgentJsonDataType(); jsonDataPayload.SetJsonData(data); _data = jsonDataPayload; } else { throw new Exception("Can only send one JSON payload per request."); } return(this); }
/// <summary> /// Sets the body data of the request as a string. This method assumes the use of /// the application/x-www-form-urlencoded data type (<see cref="UnityAgentFormDataType"/>) and /// will append the data each time this method is called seperated by an ampersand. /// To set a custom data type use the other overloads. /// </summary> /// <param name="data">The body data of the request.</param> /// <returns>Returns this <see cref="UnityAgentRequest"/> object so that calls can be chained.</returns> public UnityAgentRequest Send(string data) { if (_data == null) { var formData = new UnityAgentFormDataType(); formData.AppendData(data); _data = formData; } else { if (_data is UnityAgentFormDataType) { (_data as UnityAgentFormDataType).AppendData(data); } else { throw new Exception("Data type is already set to something other than form. Cannot use this method."); } } return(this); }
/// <summary> /// Sets the data of a request. This is a low level method. You would usually /// one of the other overloads of this method to send text or JSON data. /// </summary> /// <param name="body">The body data of the request.</param> /// <returns>Returns this <see cref="UnityAgentRequest"/> object so that calls can be chained.</returns> public UnityAgentRequest Send(UnityAgentDataType data) { if (_data != null) { throw new Exception("Cannot send more than data type objects"); } else { _data = data; } return this; }
/// <summary> /// Sets the body data of the request as a JSON object. This method assumes the use of /// the application/x-www-form-urlencoded data type (<see cref="UnityAgentFormDataType"/>) and /// will append the data each time this method is called seperated by an ampersand. /// To set a custom data type use the other overloads. /// </summary> /// <param name="data">The body data of the request.</param> /// <returns>Returns this <see cref="UnityAgentRequest"/> object so that calls can be chained.</returns> public UnityAgentRequest Send(JsonData data) { if (_data == null) { var jsonDataPayload = new UnityAgentJsonDataType(); jsonDataPayload.SetJsonData(data); _data = jsonDataPayload; } else { throw new Exception("Can only send one JSON payload per request."); } return this; }
/// <summary> /// Sets the body data of the request as a string. This method assumes the use of /// the application/x-www-form-urlencoded data type (<see cref="UnityAgentFormDataType"/>) and /// will append the data each time this method is called seperated by an ampersand. /// To set a custom data type use the other overloads. /// </summary> /// <param name="data">The body data of the request.</param> /// <returns>Returns this <see cref="UnityAgentRequest"/> object so that calls can be chained.</returns> public UnityAgentRequest Send(string data) { if (_data == null) { var formData = new UnityAgentFormDataType(); formData.AppendData(data); _data = formData; } else { if (_data is UnityAgentFormDataType) { (_data as UnityAgentFormDataType).AppendData(data); } else { throw new Exception("Data type is already set to something other than form. Cannot use this method."); } } return this; }