-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add implementation for coop product provider
- Loading branch information
Showing
8 changed files
with
209 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace GrocyScanner.Core.Extensions; | ||
|
||
public static class DateTimeExtensions | ||
{ | ||
public static long GetUnixMilliseconds(this DateTime date) | ||
{ | ||
DateTime zero = new DateTime(1970, 1, 1); | ||
TimeSpan span = date.Subtract(zero); | ||
|
||
return (long)span.TotalMilliseconds; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace GrocyScanner.Core.Models.Coop; | ||
|
||
public class CoopProduct | ||
{ | ||
[JsonPropertyName("success")] | ||
public required bool Success { get; set; } | ||
|
||
[JsonPropertyName("contentJsons")] | ||
public required CoopProductContentJson ContentJsons { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace GrocyScanner.Core.Models.Coop; | ||
|
||
public class CoopProductAnhor | ||
{ | ||
[JsonPropertyName("anchor")] | ||
public required string Anchor { get; set; } | ||
|
||
[JsonPropertyName("name")] | ||
public required string Name { get; set; } | ||
|
||
[JsonPropertyName("json")] | ||
public required CoopProductTile Json { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace GrocyScanner.Core.Models.Coop; | ||
|
||
public class CoopProductContentJson | ||
{ | ||
[JsonPropertyName("anchors")] | ||
public required List<CoopProductAnhor> Anchors { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace GrocyScanner.Core.Models.Coop; | ||
|
||
public class CoopProductElement | ||
{ | ||
[JsonPropertyName("elementType")] | ||
public required string ElementType { get; set; } | ||
|
||
[JsonPropertyName("id")] | ||
public required string Id { get; set; } | ||
|
||
[JsonPropertyName("title")] | ||
public required string Title { get; set; } | ||
|
||
[JsonPropertyName("type")] | ||
public required string Type { get; set; } | ||
|
||
[JsonPropertyName("href")] | ||
public required string Href { get; set; } | ||
|
||
[JsonPropertyName("image")] | ||
public required CoopProductImage Image { get; set; } | ||
|
||
[JsonPropertyName("quantity")] | ||
public required string Quantity { get; set; } | ||
|
||
[JsonPropertyName("ratingAmount")] | ||
public required int RatingAmount { get; set; } | ||
|
||
[JsonPropertyName("ratingValue")] | ||
public required double RatingValue { get; set; } | ||
|
||
[JsonPropertyName("ratingLink")] | ||
public required string RatingLink { get; set; } | ||
|
||
[JsonPropertyName("brand")] | ||
public string? Brand { get; set; } | ||
|
||
[JsonPropertyName("price")] | ||
public required string Price { get; set; } | ||
|
||
[JsonPropertyName("udoCat")] | ||
public required List<string> UdoCat { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace GrocyScanner.Core.Models.Coop; | ||
|
||
public class CoopProductImage | ||
{ | ||
[JsonPropertyName("lazyload")] | ||
public required bool Lazyload { get; set; } | ||
|
||
[JsonPropertyName("lazyloadSrc")] | ||
public required string LazyloadSrc { get; set; } | ||
|
||
[JsonPropertyName("loader")] | ||
public required string Loader { get; set; } | ||
|
||
[JsonPropertyName("sizes")] | ||
public required Dictionary<string, string> Sizes { get; set; } | ||
|
||
[JsonPropertyName("src")] | ||
public required string Src { get; set; } | ||
|
||
[JsonPropertyName("srcset")] | ||
public required List<List<string>> Srcset { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace GrocyScanner.Core.Models.Coop; | ||
|
||
public class CoopProductTile | ||
{ | ||
[JsonPropertyName("elements")] | ||
public required List<CoopProductElement> Elements { get; set; } | ||
|
||
[JsonPropertyName("context")] | ||
public required string Context { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters