changes contract classes to records
adds getinfo to image api
This commit is contained in:
parent
a8ad6ca9ff
commit
fadd9bc1a9
111
PiwigoDotnet/Piwigo.Client.Tests/ImageApi.getInfo.json
Normal file
111
PiwigoDotnet/Piwigo.Client.Tests/ImageApi.getInfo.json
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
{
|
||||||
|
stat: "ok",
|
||||||
|
result: {
|
||||||
|
id: 3,
|
||||||
|
file: "2017-05-24-20-35-c7d_6283.jpg",
|
||||||
|
date_available: "2022-10-20 22:01:31",
|
||||||
|
date_creation: "2017-05-24 20:35:44",
|
||||||
|
name: "2017-05-24-20-35-c7d 6283",
|
||||||
|
comment: null,
|
||||||
|
author: null,
|
||||||
|
hit: 5,
|
||||||
|
filesize: 4647,
|
||||||
|
width: 3961,
|
||||||
|
height: 2641,
|
||||||
|
coi: null,
|
||||||
|
representative_ext: null,
|
||||||
|
date_metadata_update: "2022-10-21",
|
||||||
|
rating_score: null,
|
||||||
|
level: "0",
|
||||||
|
md5sum: "9a567bdb978802f619c3610c206f0cdb",
|
||||||
|
added_by: "1",
|
||||||
|
rotation: "0",
|
||||||
|
latitude: null,
|
||||||
|
longitude: null,
|
||||||
|
lastmodified: "2022-10-20 22:01:31",
|
||||||
|
page_url: "http://localhost:8080/picture.php?/3",
|
||||||
|
element_url: "http://localhost:8080/upload/2022/10/20/20221020220131-9a567bdb.jpg",
|
||||||
|
derivatives: {
|
||||||
|
square: {
|
||||||
|
url: "http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-sq.jpg",
|
||||||
|
width: 120,
|
||||||
|
height: 120
|
||||||
|
},
|
||||||
|
thumb: {
|
||||||
|
url: "http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-th.jpg",
|
||||||
|
width: 144,
|
||||||
|
height: 96
|
||||||
|
},
|
||||||
|
2small: {
|
||||||
|
url: "http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-2s.jpg",
|
||||||
|
width: 240,
|
||||||
|
height: 160
|
||||||
|
},
|
||||||
|
xsmall: {
|
||||||
|
url: "http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-xs.jpg",
|
||||||
|
width: 432,
|
||||||
|
height: 288
|
||||||
|
},
|
||||||
|
small: {
|
||||||
|
url: "http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-sm.jpg",
|
||||||
|
width: 576,
|
||||||
|
height: 384
|
||||||
|
},
|
||||||
|
medium: {
|
||||||
|
url: "http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-me.jpg",
|
||||||
|
width: 792,
|
||||||
|
height: 528
|
||||||
|
},
|
||||||
|
large: {
|
||||||
|
url: "http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-la.jpg",
|
||||||
|
width: 1008,
|
||||||
|
height: 672
|
||||||
|
},
|
||||||
|
xlarge: {
|
||||||
|
url: "http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-xl.jpg",
|
||||||
|
width: 1224,
|
||||||
|
height: 816
|
||||||
|
},
|
||||||
|
xxlarge: {
|
||||||
|
url: "http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-xx.jpg",
|
||||||
|
width: 1656,
|
||||||
|
height: 1104
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rates: {
|
||||||
|
score: null,
|
||||||
|
count: 0,
|
||||||
|
average: null
|
||||||
|
},
|
||||||
|
categories: [
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
name: "LocalTestAlbum",
|
||||||
|
permalink: null,
|
||||||
|
uppercats: "7",
|
||||||
|
global_rank: "1",
|
||||||
|
url: "http://localhost:8080/index.php?/category/7",
|
||||||
|
page_url: "http://localhost:8080/picture.php?/3/category/7"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
tags: [],
|
||||||
|
comment_post: {
|
||||||
|
author: "admin",
|
||||||
|
key: "1666472481:2:c928621171e6b7b3ba199c59c778df09"
|
||||||
|
},
|
||||||
|
comments_paging: {
|
||||||
|
page: 0,
|
||||||
|
per_page: "10",
|
||||||
|
count: 1,
|
||||||
|
total_count: 1
|
||||||
|
},
|
||||||
|
comments: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
date: "2022-10-22 21:00:48",
|
||||||
|
author: "admin",
|
||||||
|
content: "testkommentar"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
width: 3961,
|
||||||
|
height: 2641,
|
||||||
|
hit: 5,
|
||||||
|
file: 2017-05-24-20-35-c7d_6283.jpg,
|
||||||
|
name: 2017-05-24-20-35-c7d 6283,
|
||||||
|
date_creation: DateTime_1,
|
||||||
|
date_available: DateTime_2,
|
||||||
|
page_url: http://localhost:8080/picture.php?/3,
|
||||||
|
element_url: http://localhost:8080/upload/2022/10/20/20221020220131-9a567bdb.jpg,
|
||||||
|
derivatives: {
|
||||||
|
2small: {
|
||||||
|
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-2s.jpg,
|
||||||
|
width: 240,
|
||||||
|
height: 160
|
||||||
|
},
|
||||||
|
large: {
|
||||||
|
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-la.jpg,
|
||||||
|
width: 1008,
|
||||||
|
height: 672
|
||||||
|
},
|
||||||
|
medium: {
|
||||||
|
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-me.jpg,
|
||||||
|
width: 792,
|
||||||
|
height: 528
|
||||||
|
},
|
||||||
|
small: {
|
||||||
|
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-sm.jpg,
|
||||||
|
width: 576,
|
||||||
|
height: 384
|
||||||
|
},
|
||||||
|
square: {
|
||||||
|
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-sq.jpg,
|
||||||
|
width: 120,
|
||||||
|
height: 120
|
||||||
|
},
|
||||||
|
thumb: {
|
||||||
|
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-th.jpg,
|
||||||
|
width: 144,
|
||||||
|
height: 96
|
||||||
|
},
|
||||||
|
xlarge: {
|
||||||
|
url: http://localhost:8080/i.php?/upload/2022/10/20/20221020220131-9a567bdb-xl.jpg,
|
||||||
|
width: 1224,
|
||||||
|
height: 816
|
||||||
|
},
|
||||||
|
xsmall: {
|
||||||
|
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-xs.jpg,
|
||||||
|
width: 432,
|
||||||
|
height: 288
|
||||||
|
},
|
||||||
|
xxlarge: {
|
||||||
|
url: http://localhost:8080/_data/i/upload/2022/10/20/20221020220131-9a567bdb-xx.jpg,
|
||||||
|
width: 1656,
|
||||||
|
height: 1104
|
||||||
|
}
|
||||||
|
},
|
||||||
|
categories: [
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
name: LocalTestAlbum,
|
||||||
|
url: http://localhost:8080/index.php?/category/7,
|
||||||
|
page_url: http://localhost:8080/picture.php?/3/category/7
|
||||||
|
}
|
||||||
|
],
|
||||||
|
comment_post: {
|
||||||
|
author: admin,
|
||||||
|
key: 1666472481:2:c928621171e6b7b3ba199c59c778df09
|
||||||
|
},
|
||||||
|
comments_paging: {
|
||||||
|
per_page: 10,
|
||||||
|
count: 1,
|
||||||
|
total_count: 1
|
||||||
|
},
|
||||||
|
comments: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
date: DateTime_3,
|
||||||
|
author: admin,
|
||||||
|
content: testkommentar
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -15,6 +15,21 @@ public class ImageApiTests : ApiTestsBase
|
|||||||
_imageApi = new ImageApi(Context, new NullLogger<ImageApi>());
|
_imageApi = new ImageApi(Context, new NullLogger<ImageApi>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task GetInfo_should_pass_request_and_return_data()
|
||||||
|
{
|
||||||
|
await SetJsonResultFromFileAsync("ImageApi.getInfo.json");
|
||||||
|
|
||||||
|
var response = await _imageApi.GetInfoAsync(3, 2, 100);
|
||||||
|
|
||||||
|
CorrectMethodShouldGetCalled("pwg.images.getInfo");
|
||||||
|
CorrectParamShouldGetSent("image_id", "3");
|
||||||
|
CorrectParamShouldGetSent("comments_page", "2");
|
||||||
|
CorrectParamShouldGetSent("comments_per_page", "100");
|
||||||
|
|
||||||
|
await Verify(response);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Update_should_pass_data_to_piwigo()
|
public async Task Update_should_pass_data_to_piwigo()
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,12 @@
|
|||||||
<None Update="AlbumApiTests.GetList_should_return_all_existing_albums.verified.txt">
|
<None Update="AlbumApiTests.GetList_should_return_all_existing_albums.verified.txt">
|
||||||
<DependentUpon>AlbumApiTests.cs</DependentUpon>
|
<DependentUpon>AlbumApiTests.cs</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="ImageApi.getInfo.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="ImageApiTests.GetInfo_should_pass_request_and_return_data.verified.txt">
|
||||||
|
<DependentUpon>ImageApiTests.cs</DependentUpon>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -4,7 +4,7 @@ using Newtonsoft.Json;
|
|||||||
namespace Piwigo.Client.Contract;
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "StringLiteralTypo")]
|
[SuppressMessage("ReSharper", "StringLiteralTypo")]
|
||||||
public class Album
|
public record Album
|
||||||
{
|
{
|
||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
public int Id { get; init; }
|
public int Id { get; init; }
|
||||||
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Piwigo.Client.Contract;
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
internal class AlbumAdded
|
internal record AlbumAdded
|
||||||
{
|
{
|
||||||
[JsonProperty("info")]
|
[JsonProperty("info")]
|
||||||
public string? Info { get; init; }
|
public string? Info { get; init; }
|
||||||
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Piwigo.Client.Contract;
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
public class AlbumList
|
public record AlbumList
|
||||||
{
|
{
|
||||||
[JsonProperty("Categories")]
|
[JsonProperty("Categories")]
|
||||||
public IList<Album> Albums { get; init; } = null!;
|
public IList<Album> Albums { get; init; } = null!;
|
||||||
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Piwigo.Client.Contract;
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
public class AlbumOrphans
|
public record AlbumOrphans
|
||||||
{
|
{
|
||||||
[JsonProperty("nb_images_associated_outside")]
|
[JsonProperty("nb_images_associated_outside")]
|
||||||
public int? AssociatedOutsideCount { get; init; }
|
public int? AssociatedOutsideCount { get; init; }
|
||||||
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Piwigo.Client.Contract;
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
public class CheckUpload
|
public record CheckUpload
|
||||||
{
|
{
|
||||||
[JsonProperty("message")]
|
[JsonProperty("message")]
|
||||||
public string? Message { get; init; }
|
public string? Message { get; init; }
|
||||||
|
18
PiwigoDotnet/Piwigo.Client/Contract/Comment.cs
Normal file
18
PiwigoDotnet/Piwigo.Client/Contract/Comment.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
|
public record Comment
|
||||||
|
{
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int Id { get; init; }
|
||||||
|
|
||||||
|
[JsonProperty("date")]
|
||||||
|
public DateTime? Date { get; init; }
|
||||||
|
|
||||||
|
[JsonProperty("author")]
|
||||||
|
public string? Author { get; init; }
|
||||||
|
|
||||||
|
[JsonProperty("content")]
|
||||||
|
public string? Content { get; init; }
|
||||||
|
}
|
7
PiwigoDotnet/Piwigo.Client/Contract/CommentPagingInfo.cs
Normal file
7
PiwigoDotnet/Piwigo.Client/Contract/CommentPagingInfo.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
|
public record CommentPagingInfo([property: JsonProperty("page")] int Page, [property: JsonProperty("per_page")] int PageSize, [property: JsonProperty("count")] int Count,
|
||||||
|
[property: JsonProperty("total_count")]
|
||||||
|
int TotalItems);
|
12
PiwigoDotnet/Piwigo.Client/Contract/CommentPost.cs
Normal file
12
PiwigoDotnet/Piwigo.Client/Contract/CommentPost.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
|
public record CommentPost
|
||||||
|
{
|
||||||
|
[JsonProperty("author")]
|
||||||
|
public string? Author { get; init; }
|
||||||
|
|
||||||
|
[JsonProperty("key")]
|
||||||
|
public string? Key { get; init; }
|
||||||
|
}
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Piwigo.Client.Contract;
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
public class Image
|
public record Image
|
||||||
{
|
{
|
||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
public int Id { get; init; }
|
public int Id { get; init; }
|
||||||
@ -42,4 +42,13 @@ public class Image
|
|||||||
|
|
||||||
[JsonProperty("categories")]
|
[JsonProperty("categories")]
|
||||||
public IReadOnlyCollection<ImageAlbum>? Albums { get; init; }
|
public IReadOnlyCollection<ImageAlbum>? Albums { get; init; }
|
||||||
|
|
||||||
|
[JsonProperty("comment_post")]
|
||||||
|
public CommentPost? CommentPost { get; init; }
|
||||||
|
|
||||||
|
[JsonProperty("comments_paging")]
|
||||||
|
public CommentPagingInfo? CommentPaging { get; init; }
|
||||||
|
|
||||||
|
[JsonProperty("comments")]
|
||||||
|
public IReadOnlyCollection<Comment>? Comments { get; init; }
|
||||||
}
|
}
|
@ -2,11 +2,17 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Piwigo.Client.Contract;
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
public class ImageAlbum
|
public record ImageAlbum
|
||||||
{
|
{
|
||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
public int Id { get; init; }
|
public int Id { get; init; }
|
||||||
|
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string? Name { get; init; }
|
||||||
|
|
||||||
|
[JsonProperty("permalink")]
|
||||||
|
public string? Permalink { get; init; }
|
||||||
|
|
||||||
[JsonProperty("url")]
|
[JsonProperty("url")]
|
||||||
public string? Url { get; init; }
|
public string? Url { get; init; }
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Piwigo.Client.Contract;
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
public class ImageDerivative
|
public record ImageDerivative
|
||||||
{
|
{
|
||||||
[JsonProperty("url")]
|
[JsonProperty("url")]
|
||||||
public string? Url { get; init; }
|
public string? Url { get; init; }
|
||||||
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Piwigo.Client.Contract;
|
namespace Piwigo.Client.Contract;
|
||||||
|
|
||||||
public class ImageUploaded
|
public record ImageUploaded
|
||||||
{
|
{
|
||||||
[JsonProperty("image_id")]
|
[JsonProperty("image_id")]
|
||||||
public int? ImageId { get; init; }
|
public int? ImageId { get; init; }
|
||||||
|
@ -7,15 +7,14 @@ public interface IImageApi
|
|||||||
Task<ImageUploaded> AddAsync(ImageUpload imageUpload, CancellationToken cancellationToken = default);
|
Task<ImageUploaded> AddAsync(ImageUpload imageUpload, CancellationToken cancellationToken = default);
|
||||||
Task<ImageUploaded> UpdateAsync(int imageId, ImageUpload imageUpload, CancellationToken cancellationToken = default);
|
Task<ImageUploaded> UpdateAsync(int imageId, ImageUpload imageUpload, CancellationToken cancellationToken = default);
|
||||||
Task AddChunkAsync(byte[] data, string originalSum, int position, CancellationToken cancellationToken = default);
|
Task AddChunkAsync(byte[] data, string originalSum, int position, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
Task<bool> ReadyForUploadAsync(CancellationToken cancellationToken = default);
|
Task<bool> ReadyForUploadAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<Image> GetInfoAsync(int imageId, int? commentsPage, int? commentsPerPage, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
Task<PagedImages> GetImages(int albumId, bool recursive, PagingInfo page, ImageFilter filter, ImageOrder order = ImageOrder.Name,
|
Task<PagedImages> GetImages(int albumId, bool recursive, PagingInfo page, ImageFilter filter, ImageOrder order = ImageOrder.Name,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
addComment
|
addComment
|
||||||
addFile
|
|
||||||
checkFiles
|
checkFiles
|
||||||
delete
|
delete
|
||||||
deleteOrphans
|
deleteOrphans
|
||||||
@ -24,7 +23,6 @@ exist
|
|||||||
-> formats
|
-> formats
|
||||||
delete
|
delete
|
||||||
searchImage
|
searchImage
|
||||||
getInfo
|
|
||||||
rate
|
rate
|
||||||
search
|
search
|
||||||
setInfo
|
setInfo
|
||||||
|
@ -44,6 +44,19 @@ public class ImageApi : IImageApi
|
|||||||
return AddOrUpdateAsync(imageId, imageUpload, cancellationToken);
|
return AddOrUpdateAsync(imageId, imageUpload, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<Image> GetInfoAsync(int imageId, int? commentsPage, int? commentsPerPage, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
var formParams = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "image_id", imageId.ToString() }
|
||||||
|
};
|
||||||
|
formParams.AddIfValueNotNull("comments_page", commentsPage?.ToString());
|
||||||
|
formParams.AddIfValueNotNull("comments_per_page", commentsPerPage?.ToString());
|
||||||
|
|
||||||
|
var response = await _context.PostAsync<PiwigoResponse<Image>>(_logger, "pwg.images.getInfo", formParams, cancellationToken);
|
||||||
|
return response.Result;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> ReadyForUploadAsync(CancellationToken cancellationToken = default)
|
public async Task<bool> ReadyForUploadAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var response = await _context.PostAsync<PiwigoResponse<CheckUpload>>(_logger, "pwg.images.checkUpload", new Dictionary<string, string>(), cancellationToken);
|
var response = await _context.PostAsync<PiwigoResponse<CheckUpload>>(_logger, "pwg.images.checkUpload", new Dictionary<string, string>(), cancellationToken);
|
||||||
|
Loading…
Reference in New Issue
Block a user