implement PictureService and social gallery models
This commit is contained in:
@@ -16,6 +16,89 @@ namespace Chtn.CSharp.SDK.Models.Media
|
|||||||
[JsonProperty("path")] public string Path { get; set; }
|
[JsonProperty("path")] public string Path { get; set; }
|
||||||
[JsonProperty("title")] public string Title { get; set; }
|
[JsonProperty("title")] public string Title { get; set; }
|
||||||
[JsonProperty("uploaded_at")] public TimeStamp UploadedAt { get; set; }
|
[JsonProperty("uploaded_at")] public TimeStamp UploadedAt { get; set; }
|
||||||
|
[JsonProperty("likes")] public int Likes { get; set; }
|
||||||
|
[JsonProperty("visibility")] public string Visibility { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Comment
|
||||||
|
{
|
||||||
|
[JsonProperty("id")] public string Id { get; set; }
|
||||||
|
[JsonProperty("authorId")] public string AuthorId { get; set; }
|
||||||
|
[JsonProperty("content")] public string Content { get; set; }
|
||||||
|
[JsonProperty("createdAt")] public TimeStamp CreatedAt{ get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetReq
|
||||||
|
{
|
||||||
|
[JsonProperty("id")] public string Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CreateAlbumReq
|
||||||
|
{
|
||||||
|
[JsonProperty("name")] public string Name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FinalizeUploadReq
|
||||||
|
{
|
||||||
|
[JsonProperty("uploadId")] public string UploadId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeleteImageReq
|
||||||
|
{
|
||||||
|
[JsonProperty("id")] public string Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ChangePictureVisibilityReq
|
||||||
|
{
|
||||||
|
[JsonProperty("id")] public string Id { get; set; }
|
||||||
|
[JsonProperty("visibility")] public string Visibility { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EditPictureTitle
|
||||||
|
{
|
||||||
|
[JsonProperty("id")] public string Id { get; set; }
|
||||||
|
[JsonProperty("title")] public string Title { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TogglePictureLikeReq
|
||||||
|
{
|
||||||
|
[JsonProperty("id")] public string Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PostCommentReq
|
||||||
|
{
|
||||||
|
[JsonProperty("imageId")] public string ImageId { get; set; }
|
||||||
|
[JsonProperty("content")] public string Content { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ToggleFollowReq
|
||||||
|
{
|
||||||
|
[JsonProperty("targetUserId")] public string TargetUserId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAlbumsReq
|
||||||
|
{
|
||||||
|
[JsonProperty("userId")] public string UserId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetCommentsReq
|
||||||
|
{
|
||||||
|
[JsonProperty("imageId")] public string ImageId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UploadImageReq
|
||||||
|
{
|
||||||
|
[JsonProperty("albumId")] public string AlbumId { get; set; }
|
||||||
|
[JsonProperty("data")] public byte[] Data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetResp
|
||||||
|
{
|
||||||
|
[JsonProperty("image")] public Image Image { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DiscoveryResp
|
||||||
|
{
|
||||||
|
[JsonProperty("trending")] public List<Image> Trending { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
63
Services/PictureMethods.cs
Normal file
63
Services/PictureMethods.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Chtn.CSharp.SDK.Core;
|
||||||
|
using Chtn.CSharp.SDK.Models.Media;
|
||||||
|
|
||||||
|
namespace Chtn.CSharp.SDK.Services
|
||||||
|
{
|
||||||
|
public interface IPictureService
|
||||||
|
{
|
||||||
|
Task<GetResp> Get(GetReq req);
|
||||||
|
Task<DiscoveryResp> Discovery();
|
||||||
|
Task CreateAlbum(CreateAlbumReq req);
|
||||||
|
Task FinalizeUpload(FinalizeUploadReq req);
|
||||||
|
Task Delete(DeleteImageReq req);
|
||||||
|
Task ChangeVisibility(ChangePictureVisibilityReq req);
|
||||||
|
Task EditTitle(EditPictureTitle req);
|
||||||
|
Task ToggleLike(TogglePictureLikeReq req);
|
||||||
|
Task Comment(PostCommentReq req);
|
||||||
|
Task ToggleFollow(ToggleFollowReq req);
|
||||||
|
Task<List<Album>> GetAlbums(GetAlbumsReq req);
|
||||||
|
Task<List<Comment>> GetComments(GetCommentsReq req);
|
||||||
|
Task UploadPicture(UploadImageReq req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PictureServiceProvider : IPictureService
|
||||||
|
{
|
||||||
|
private readonly ApiClient _apiClient;
|
||||||
|
|
||||||
|
public PictureServiceProvider(ApiClient apiClient)
|
||||||
|
{
|
||||||
|
_apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GetResp> Get(GetReq req) =>
|
||||||
|
await _apiClient.PostAsync<GetReq, GetResp>("picture/pictures", req);
|
||||||
|
|
||||||
|
public async Task<DiscoveryResp> Discovery() =>
|
||||||
|
await _apiClient.PostAsync<object, DiscoveryResp>("picture/discovery", new { });
|
||||||
|
public async Task CreateAlbum(CreateAlbumReq req) =>
|
||||||
|
await _apiClient.PostAsync<CreateAlbumReq, object>("picture/createAlbum", req);
|
||||||
|
public async Task FinalizeUpload(FinalizeUploadReq req) =>
|
||||||
|
await _apiClient.PostAsync<FinalizeUploadReq, object>("picture/finalizeUpload", req);
|
||||||
|
public async Task Delete(DeleteImageReq req) =>
|
||||||
|
await _apiClient.PostAsync<DeleteImageReq, object>("picture/delete", req);
|
||||||
|
public async Task ChangeVisibility(ChangePictureVisibilityReq req) =>
|
||||||
|
await _apiClient.PostAsync<ChangePictureVisibilityReq, object>("picture/changeVisibility", req);
|
||||||
|
public async Task EditTitle(EditPictureTitle req) =>
|
||||||
|
await _apiClient.PostAsync<EditPictureTitle, object>("picture/editTitle", req);
|
||||||
|
public async Task ToggleLike(TogglePictureLikeReq req) =>
|
||||||
|
await _apiClient.PostAsync<TogglePictureLikeReq, object>("picture/toggleLike", req);
|
||||||
|
public async Task Comment(PostCommentReq req) =>
|
||||||
|
await _apiClient.PostAsync<PostCommentReq, object>("picture/comment", req);
|
||||||
|
public async Task ToggleFollow(ToggleFollowReq req) =>
|
||||||
|
await _apiClient.PostAsync<ToggleFollowReq, object>("picture/toggleFollow", req);
|
||||||
|
public async Task<List<Album>> GetAlbums(GetAlbumsReq req) =>
|
||||||
|
await _apiClient.PostAsync<GetAlbumsReq, List<Album>>("picture/getAlbums", req);
|
||||||
|
public async Task<List<Comment>> GetComments(GetCommentsReq req) =>
|
||||||
|
await _apiClient.PostAsync<GetCommentsReq, List<Comment>>("picture/comment", req);
|
||||||
|
public async Task UploadPicture(UploadImageReq req) =>
|
||||||
|
await _apiClient.PostAsync<UploadImageReq, object>("picture/upload", req);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user