/// <summary> /// Initializes a new instance of the <see cref="CreateFriendshipCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="userId">The userid.</param> /// <param name="optionalProperties">The optional properties.</param> public CreateFriendshipCommand(OAuthTokens tokens, decimal userId, CreateFriendshipOptions optionalProperties) : base(HTTPVerb.POST, Path, tokens, optionalProperties) { if (tokens == null) { throw new ArgumentNullException("tokens"); } if (userId <= 0) { throw new ArgumentException("userId"); } this.UserId = userId; }
/// <summary> /// Initializes a new instance of the <see cref="CreateFriendshipCommand"/> class. /// </summary> /// <param name="tokens">The request tokens.</param> /// <param name="userName">Name of the user.</param> /// <param name="optionalProperties">The optional properties.</param> public CreateFriendshipCommand(OAuthTokens tokens, string userName, CreateFriendshipOptions optionalProperties) : base(HTTPVerb.POST, Path, tokens, optionalProperties) { if (tokens == null) { throw new ArgumentNullException("tokens"); } if (string.IsNullOrEmpty(userName)) { throw new ArgumentNullException("userName"); } this.UserName = userName; }
/// <summary> /// Initializes the command. /// </summary> public override void Init() { if (this.UserId > 0) { this.RequestParameters.Add("user_id", this.UserId.ToString("#")); } else if (!string.IsNullOrEmpty(this.UserName)) { this.RequestParameters.Add("screen_name", this.UserName); } CreateFriendshipOptions options = this.OptionalProperties as CreateFriendshipOptions; if (options != null) { if (options.Follow) { this.RequestParameters.Add("follow", "true"); } } }