/// <summary> /// Get a single content share by its id and associated user. /// </summary> /// <param name="shareId">The id of the share.</param> /// <param name="userId">(Optional) The user with whom the share is associated with. Self by default.</param> /// <returns>The share.</returns> /// <remarks> /// The current user must be an observer of <paramref name="userId"/>, or an administrator. /// </remarks> public async Task <ContentShare> GetContentShare(ulong shareId, ulong?userId = null) { var response = await _client.GetAsync($"users/{userId.IdOrSelf()}/content_shares/{shareId}"); var model = JsonConvert.DeserializeObject <ContentShareModel>(await response.Content.ReadAsStringAsync()); return(ContentShare.NewContentShare(this, model)); }
public async Task <ContentShare> CreateContentShare([NotNull] IEnumerable <ulong> receivers, ContentShareType contentType, ulong contentId, ulong?senderId = null) { var args = new List <(string, string)> { ("content_id", contentId.ToString()), ("content_type", contentType.GetApiRepresentation()) }; args.AddRange(receivers.Select(id => ("receiver_ids[]", id.ToString()))); var response = await _client.PostAsync($"users/{senderId?.ToString() ?? "self"}/content_shares", BuildHttpArguments(args)); var model = JsonConvert.DeserializeObject <ContentShareModel>(await response.Content.ReadAsStringAsync()); return(ContentShare.NewContentShare(this, model)); }