Ejemplo n.º 1
0
        public async Task <WallPostResponse> PostponeAsync([NotNull] WallPostInfo info, CancellationToken ct)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            if (info.Message == null)
            {
                info.Message = "";
            }

            var parameters = QueryParameters.New()
                             .Add("owner_id", info.OwnerId)
                             .Add("publish_date", info.PostponedDate)
                             .Add("message", info.Message);

            //it's a group
            if (info.OwnerId < 0)
            {
                parameters
                .Add("signed", info.Signed ? 1 : 0)
                .Add("from_group", info.FromGroup ? 1 : 0);
            }

            parameters.Append(info.Attachments.GetAsParameters());

            var response = await postAsync(parameters, ct);

            OnPostSuccessful(info);
            return(response);
        }
Ejemplo n.º 2
0
 public Task <WallPostResponse> PostponeAsync([NotNull] WallPostInfo info)
 {
     if (info == null)
     {
         throw new ArgumentNullException(nameof(info));
     }
     return(PostponeAsync(info, CancellationToken.None));
 }
Ejemplo n.º 3
0
        //private static QueryParameters makeAQuery(int wallId, string message, int date, [NotNull] Attachments attachments) {
        //   if (attachments == null) throw new ArgumentNullException(nameof(attachments));
        //   if (message == null) {
        //      message = "";
        //   }

        //   var parameters = QueryParameters.New()
        //      .Add("owner_id", wallId)
        //      .Add("filter", "postponed")
        //      .Add("publish_date", date)
        //      .Add("signed", 0)
        //      .Add("from_group", 1)
        //      .Add("message", message);

        //   parameters.Append(attachments.GetAsParameters());

        //   return parameters;
        //}

        protected virtual void OnPostSuccessful(WallPostInfo e)
        {
            e.PublishingDate = UnixTimeConverter.ToUnix(DateTimeOffset.Now.DateTime);
            PostSuccessful?.Invoke(this, e);
        }