Skip to content

Commit ca76d45

Browse files
committed
Add transactions
1 parent 1d91fc3 commit ca76d45

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+797
-79
lines changed

Appwrite/Appwrite.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
44
<PackageId>Appwrite</PackageId>
5-
<Version>0.20.0</Version>
5+
<Version>0.21.0</Version>
66
<Authors>Appwrite Team</Authors>
77
<Company>Appwrite Team</Company>
88
<Description>

Appwrite/Client.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ public Client(
6969
_headers = new Dictionary<string, string>()
7070
{
7171
{ "content-type", "application/json" },
72-
{ "user-agent" , $"AppwriteDotNetSDK/0.20.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"},
72+
{ "user-agent" , $"AppwriteDotNetSDK/0.21.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"},
7373
{ "x-sdk-name", ".NET" },
7474
{ "x-sdk-platform", "server" },
7575
{ "x-sdk-language", "dotnet" },
76-
{ "x-sdk-version", "0.20.0"},
76+
{ "x-sdk-version", "0.21.0"},
7777
{ "X-Appwrite-Response-Format", "1.8.0" }
7878
};
7979

Appwrite/Models/Transaction.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
using System;
3+
using System.Linq;
4+
using System.Collections.Generic;
5+
using System.Text.Json;
6+
using System.Text.Json.Serialization;
7+
using Appwrite.Enums;
8+
9+
namespace Appwrite.Models
10+
{
11+
public class Transaction
12+
{
13+
[JsonPropertyName("$id")]
14+
public string Id { get; private set; }
15+
16+
[JsonPropertyName("$createdAt")]
17+
public string CreatedAt { get; private set; }
18+
19+
[JsonPropertyName("$updatedAt")]
20+
public string UpdatedAt { get; private set; }
21+
22+
[JsonPropertyName("status")]
23+
public string Status { get; private set; }
24+
25+
[JsonPropertyName("operations")]
26+
public long Operations { get; private set; }
27+
28+
[JsonPropertyName("expiresAt")]
29+
public string ExpiresAt { get; private set; }
30+
31+
public Transaction(
32+
string id,
33+
string createdAt,
34+
string updatedAt,
35+
string status,
36+
long operations,
37+
string expiresAt
38+
) {
39+
Id = id;
40+
CreatedAt = createdAt;
41+
UpdatedAt = updatedAt;
42+
Status = status;
43+
Operations = operations;
44+
ExpiresAt = expiresAt;
45+
}
46+
47+
public static Transaction From(Dictionary<string, object> map) => new Transaction(
48+
id: map["$id"].ToString(),
49+
createdAt: map["$createdAt"].ToString(),
50+
updatedAt: map["$updatedAt"].ToString(),
51+
status: map["status"].ToString(),
52+
operations: Convert.ToInt64(map["operations"]),
53+
expiresAt: map["expiresAt"].ToString()
54+
);
55+
56+
public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
57+
{
58+
{ "$id", Id },
59+
{ "$createdAt", CreatedAt },
60+
{ "$updatedAt", UpdatedAt },
61+
{ "status", Status },
62+
{ "operations", Operations },
63+
{ "expiresAt", ExpiresAt }
64+
};
65+
}
66+
}

Appwrite/Models/TransactionList.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
using System;
3+
using System.Linq;
4+
using System.Collections.Generic;
5+
using System.Text.Json;
6+
using System.Text.Json.Serialization;
7+
using Appwrite.Enums;
8+
9+
namespace Appwrite.Models
10+
{
11+
public class TransactionList
12+
{
13+
[JsonPropertyName("total")]
14+
public long Total { get; private set; }
15+
16+
[JsonPropertyName("transactions")]
17+
public List<Transaction> Transactions { get; private set; }
18+
19+
public TransactionList(
20+
long total,
21+
List<Transaction> transactions
22+
) {
23+
Total = total;
24+
Transactions = transactions;
25+
}
26+
27+
public static TransactionList From(Dictionary<string, object> map) => new TransactionList(
28+
total: Convert.ToInt64(map["total"]),
29+
transactions: map["transactions"] is JsonElement jsonArray2 ? jsonArray2.Deserialize<List<Dictionary<string, object>>>()!.Select(it => Transaction.From(map: it)).ToList() : ((IEnumerable<Dictionary<string, object>>)map["transactions"]).Select(it => Transaction.From(map: it)).ToList()
30+
);
31+
32+
public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
33+
{
34+
{ "total", Total },
35+
{ "transactions", Transactions.Select(it => it.ToMap()) }
36+
};
37+
}
38+
}

0 commit comments

Comments
 (0)