diff --git a/Appwrite/Appwrite.csproj b/Appwrite/Appwrite.csproj index 2d5e714..b0ba8a8 100644 --- a/Appwrite/Appwrite.csproj +++ b/Appwrite/Appwrite.csproj @@ -2,7 +2,7 @@ netstandard2.0;net462 Appwrite - 0.16.0 + 0.17.0 Appwrite Team Appwrite Team diff --git a/Appwrite/Client.cs b/Appwrite/Client.cs index 82cef55..cfed64e 100644 --- a/Appwrite/Client.cs +++ b/Appwrite/Client.cs @@ -69,11 +69,11 @@ public Client( _headers = new Dictionary() { { "content-type", "application/json" }, - { "user-agent" , $"AppwriteDotNetSDK/0.16.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"}, + { "user-agent" , $"AppwriteDotNetSDK/0.17.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"}, { "x-sdk-name", ".NET" }, { "x-sdk-platform", "server" }, { "x-sdk-language", "dotnet" }, - { "x-sdk-version", "0.16.0"}, + { "x-sdk-version", "0.17.0"}, { "X-Appwrite-Response-Format", "1.8.0" } }; diff --git a/Appwrite/Enums/CreditCard.cs b/Appwrite/Enums/CreditCard.cs index 3c8b3ee..be6c71a 100644 --- a/Appwrite/Enums/CreditCard.cs +++ b/Appwrite/Enums/CreditCard.cs @@ -23,7 +23,7 @@ public CreditCard(string value) public static CreditCard Mastercard => new CreditCard("mastercard"); public static CreditCard Naranja => new CreditCard("naranja"); public static CreditCard TarjetaShopping => new CreditCard("targeta-shopping"); - public static CreditCard UnionChinaPay => new CreditCard("union-china-pay"); + public static CreditCard UnionPay => new CreditCard("unionpay"); public static CreditCard Visa => new CreditCard("visa"); public static CreditCard MIR => new CreditCard("mir"); public static CreditCard Maestro => new CreditCard("maestro"); diff --git a/Appwrite/Enums/ExecutionMethod.cs b/Appwrite/Enums/ExecutionMethod.cs index 6b2787b..b097cc3 100644 --- a/Appwrite/Enums/ExecutionMethod.cs +++ b/Appwrite/Enums/ExecutionMethod.cs @@ -17,5 +17,6 @@ public ExecutionMethod(string value) public static ExecutionMethod PATCH => new ExecutionMethod("PATCH"); public static ExecutionMethod DELETE => new ExecutionMethod("DELETE"); public static ExecutionMethod OPTIONS => new ExecutionMethod("OPTIONS"); + public static ExecutionMethod HEAD => new ExecutionMethod("HEAD"); } } diff --git a/Appwrite/Enums/IndexType.cs b/Appwrite/Enums/IndexType.cs index 095fa16..eee4618 100644 --- a/Appwrite/Enums/IndexType.cs +++ b/Appwrite/Enums/IndexType.cs @@ -14,5 +14,6 @@ public IndexType(string value) public static IndexType Key => new IndexType("key"); public static IndexType Fulltext => new IndexType("fulltext"); public static IndexType Unique => new IndexType("unique"); + public static IndexType Spatial => new IndexType("spatial"); } } diff --git a/Appwrite/Models/AttributeLine.cs b/Appwrite/Models/AttributeLine.cs new file mode 100644 index 0000000..32a9c2c --- /dev/null +++ b/Appwrite/Models/AttributeLine.cs @@ -0,0 +1,86 @@ + +using System; +using System.Linq; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Appwrite.Models +{ + public class AttributeLine + { + [JsonPropertyName("key")] + public string Key { get; private set; } + + [JsonPropertyName("type")] + public string Type { get; private set; } + + [JsonPropertyName("status")] + public string Status { get; private set; } + + [JsonPropertyName("error")] + public string Error { get; private set; } + + [JsonPropertyName("required")] + public bool Required { get; private set; } + + [JsonPropertyName("array")] + public bool? Array { get; private set; } + + [JsonPropertyName("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonPropertyName("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonPropertyName("default")] + public List? Default { get; private set; } + + public AttributeLine( + string key, + string type, + string status, + string error, + bool required, + bool? array, + string createdAt, + string updatedAt, + List? xdefault + ) { + Key = key; + Type = type; + Status = status; + Error = error; + Required = required; + Array = array; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Default = xdefault; + } + + public static AttributeLine From(Dictionary map) => new AttributeLine( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + error: map["error"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + xdefault: map["default"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize>()! : (List)map["default"] + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "error", Error }, + { "required", Required }, + { "array", Array }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "default", Default } + }; + } +} diff --git a/Appwrite/Models/AttributePoint.cs b/Appwrite/Models/AttributePoint.cs new file mode 100644 index 0000000..799d2e7 --- /dev/null +++ b/Appwrite/Models/AttributePoint.cs @@ -0,0 +1,86 @@ + +using System; +using System.Linq; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Appwrite.Models +{ + public class AttributePoint + { + [JsonPropertyName("key")] + public string Key { get; private set; } + + [JsonPropertyName("type")] + public string Type { get; private set; } + + [JsonPropertyName("status")] + public string Status { get; private set; } + + [JsonPropertyName("error")] + public string Error { get; private set; } + + [JsonPropertyName("required")] + public bool Required { get; private set; } + + [JsonPropertyName("array")] + public bool? Array { get; private set; } + + [JsonPropertyName("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonPropertyName("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonPropertyName("default")] + public List? Default { get; private set; } + + public AttributePoint( + string key, + string type, + string status, + string error, + bool required, + bool? array, + string createdAt, + string updatedAt, + List? xdefault + ) { + Key = key; + Type = type; + Status = status; + Error = error; + Required = required; + Array = array; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Default = xdefault; + } + + public static AttributePoint From(Dictionary map) => new AttributePoint( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + error: map["error"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + xdefault: map["default"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize>()! : (List)map["default"] + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "error", Error }, + { "required", Required }, + { "array", Array }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "default", Default } + }; + } +} diff --git a/Appwrite/Models/AttributePolygon.cs b/Appwrite/Models/AttributePolygon.cs new file mode 100644 index 0000000..8558933 --- /dev/null +++ b/Appwrite/Models/AttributePolygon.cs @@ -0,0 +1,86 @@ + +using System; +using System.Linq; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Appwrite.Models +{ + public class AttributePolygon + { + [JsonPropertyName("key")] + public string Key { get; private set; } + + [JsonPropertyName("type")] + public string Type { get; private set; } + + [JsonPropertyName("status")] + public string Status { get; private set; } + + [JsonPropertyName("error")] + public string Error { get; private set; } + + [JsonPropertyName("required")] + public bool Required { get; private set; } + + [JsonPropertyName("array")] + public bool? Array { get; private set; } + + [JsonPropertyName("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonPropertyName("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonPropertyName("default")] + public List? Default { get; private set; } + + public AttributePolygon( + string key, + string type, + string status, + string error, + bool required, + bool? array, + string createdAt, + string updatedAt, + List? xdefault + ) { + Key = key; + Type = type; + Status = status; + Error = error; + Required = required; + Array = array; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Default = xdefault; + } + + public static AttributePolygon From(Dictionary map) => new AttributePolygon( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + error: map["error"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + xdefault: map["default"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize>()! : (List)map["default"] + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "error", Error }, + { "required", Required }, + { "array", Array }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "default", Default } + }; + } +} diff --git a/Appwrite/Models/ColumnLine.cs b/Appwrite/Models/ColumnLine.cs new file mode 100644 index 0000000..c00c8c6 --- /dev/null +++ b/Appwrite/Models/ColumnLine.cs @@ -0,0 +1,86 @@ + +using System; +using System.Linq; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Appwrite.Models +{ + public class ColumnLine + { + [JsonPropertyName("key")] + public string Key { get; private set; } + + [JsonPropertyName("type")] + public string Type { get; private set; } + + [JsonPropertyName("status")] + public string Status { get; private set; } + + [JsonPropertyName("error")] + public string Error { get; private set; } + + [JsonPropertyName("required")] + public bool Required { get; private set; } + + [JsonPropertyName("array")] + public bool? Array { get; private set; } + + [JsonPropertyName("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonPropertyName("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonPropertyName("default")] + public List? Default { get; private set; } + + public ColumnLine( + string key, + string type, + string status, + string error, + bool required, + bool? array, + string createdAt, + string updatedAt, + List? xdefault + ) { + Key = key; + Type = type; + Status = status; + Error = error; + Required = required; + Array = array; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Default = xdefault; + } + + public static ColumnLine From(Dictionary map) => new ColumnLine( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + error: map["error"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + xdefault: map["default"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize>()! : (List)map["default"] + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "error", Error }, + { "required", Required }, + { "array", Array }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "default", Default } + }; + } +} diff --git a/Appwrite/Models/ColumnPoint.cs b/Appwrite/Models/ColumnPoint.cs new file mode 100644 index 0000000..38b70c4 --- /dev/null +++ b/Appwrite/Models/ColumnPoint.cs @@ -0,0 +1,86 @@ + +using System; +using System.Linq; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Appwrite.Models +{ + public class ColumnPoint + { + [JsonPropertyName("key")] + public string Key { get; private set; } + + [JsonPropertyName("type")] + public string Type { get; private set; } + + [JsonPropertyName("status")] + public string Status { get; private set; } + + [JsonPropertyName("error")] + public string Error { get; private set; } + + [JsonPropertyName("required")] + public bool Required { get; private set; } + + [JsonPropertyName("array")] + public bool? Array { get; private set; } + + [JsonPropertyName("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonPropertyName("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonPropertyName("default")] + public List? Default { get; private set; } + + public ColumnPoint( + string key, + string type, + string status, + string error, + bool required, + bool? array, + string createdAt, + string updatedAt, + List? xdefault + ) { + Key = key; + Type = type; + Status = status; + Error = error; + Required = required; + Array = array; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Default = xdefault; + } + + public static ColumnPoint From(Dictionary map) => new ColumnPoint( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + error: map["error"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + xdefault: map["default"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize>()! : (List)map["default"] + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "error", Error }, + { "required", Required }, + { "array", Array }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "default", Default } + }; + } +} diff --git a/Appwrite/Models/ColumnPolygon.cs b/Appwrite/Models/ColumnPolygon.cs new file mode 100644 index 0000000..7262f65 --- /dev/null +++ b/Appwrite/Models/ColumnPolygon.cs @@ -0,0 +1,86 @@ + +using System; +using System.Linq; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Appwrite.Models +{ + public class ColumnPolygon + { + [JsonPropertyName("key")] + public string Key { get; private set; } + + [JsonPropertyName("type")] + public string Type { get; private set; } + + [JsonPropertyName("status")] + public string Status { get; private set; } + + [JsonPropertyName("error")] + public string Error { get; private set; } + + [JsonPropertyName("required")] + public bool Required { get; private set; } + + [JsonPropertyName("array")] + public bool? Array { get; private set; } + + [JsonPropertyName("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonPropertyName("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonPropertyName("default")] + public List? Default { get; private set; } + + public ColumnPolygon( + string key, + string type, + string status, + string error, + bool required, + bool? array, + string createdAt, + string updatedAt, + List? xdefault + ) { + Key = key; + Type = type; + Status = status; + Error = error; + Required = required; + Array = array; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Default = xdefault; + } + + public static ColumnPolygon From(Dictionary map) => new ColumnPolygon( + key: map["key"].ToString(), + type: map["type"].ToString(), + status: map["status"].ToString(), + error: map["error"].ToString(), + required: (bool)map["required"], + array: (bool?)map["array"], + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + xdefault: map["default"] is JsonElement jsonArrayProp9 ? jsonArrayProp9.Deserialize>()! : (List)map["default"] + ); + + public Dictionary ToMap() => new Dictionary() + { + { "key", Key }, + { "type", Type }, + { "status", Status }, + { "error", Error }, + { "required", Required }, + { "array", Array }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "default", Default } + }; + } +} diff --git a/Appwrite/Query.cs b/Appwrite/Query.cs index bc8bef9..f7c9c5a 100644 --- a/Appwrite/Query.cs +++ b/Appwrite/Query.cs @@ -186,6 +186,10 @@ public static string CreatedAfter(string value) { return new Query("createdAfter", null, value).ToString(); } + public static string CreatedBetween(string start, string end) { + return new Query("createdBetween", null, new List { start, end }).ToString(); + } + public static string UpdatedBefore(string value) { return new Query("updatedBefore", null, value).ToString(); } @@ -194,6 +198,10 @@ public static string UpdatedAfter(string value) { return new Query("updatedAfter", null, value).ToString(); } + public static string UpdatedBetween(string start, string end) { + return new Query("updatedBetween", null, new List { start, end }).ToString(); + } + public static string Or(List queries) { return new Query("or", null, queries.Select(q => JsonSerializer.Deserialize(q, Client.DeserializerOptions)).ToList()).ToString(); } @@ -201,5 +209,65 @@ public static string Or(List queries) { public static string And(List queries) { return new Query("and", null, queries.Select(q => JsonSerializer.Deserialize(q, Client.DeserializerOptions)).ToList()).ToString(); } + + public static string DistanceEqual(string attribute, object values, double distance, bool meters = true) + { + return new Query("distanceEqual", attribute, new List { new List { values, distance, meters } }).ToString(); + } + + public static string DistanceNotEqual(string attribute, object values, double distance, bool meters = true) + { + return new Query("distanceNotEqual", attribute, new List { new List { values, distance, meters } }).ToString(); + } + + public static string DistanceGreaterThan(string attribute, object values, double distance, bool meters = true) + { + return new Query("distanceGreaterThan", attribute, new List { new List { values, distance, meters } }).ToString(); + } + + public static string DistanceLessThan(string attribute, object values, double distance, bool meters = true) + { + return new Query("distanceLessThan", attribute, new List { new List { values, distance, meters } }).ToString(); + } + + public static string Intersects(string attribute, object values) + { + return new Query("intersects", attribute, new List { values }).ToString(); + } + + public static string NotIntersects(string attribute, object values) + { + return new Query("notIntersects", attribute, new List { values }).ToString(); + } + + public static string Crosses(string attribute, object values) + { + return new Query("crosses", attribute, new List { values }).ToString(); + } + + public static string NotCrosses(string attribute, object values) + { + return new Query("notCrosses", attribute, new List { values }).ToString(); + } + + public static string Overlaps(string attribute, object values) + { + return new Query("overlaps", attribute, new List { values }).ToString(); + } + + public static string NotOverlaps(string attribute, object values) + { + return new Query("notOverlaps", attribute, new List { values }).ToString(); + } + + public static string Touches(string attribute, object values) + { + return new Query("touches", attribute, new List { values }).ToString(); + } + + public static string NotTouches(string attribute, object values) + { + return new Query("notTouches", attribute, new List { values }).ToString(); + } } } \ No newline at end of file diff --git a/Appwrite/Services/Account.cs b/Appwrite/Services/Account.cs index 0f9efda..a247409 100644 --- a/Appwrite/Services/Account.cs +++ b/Appwrite/Services/Account.cs @@ -1252,7 +1252,7 @@ static Models.Session Convert(Dictionary it) => /// flows initiated by token creation. For example, magic URL and phone login. /// /// - [Obsolete("This API has been deprecated.")] + [Obsolete("This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.")] public Task UpdateMagicURLSession(string userId, string secret) { var apiPath = "/account/sessions/magic-url"; @@ -1287,7 +1287,7 @@ static Models.Session Convert(Dictionary it) => /// flows initiated by token creation. For example, magic URL and phone login. /// /// - [Obsolete("This API has been deprecated.")] + [Obsolete("This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.")] public Task UpdatePhoneSession(string userId, string secret) { var apiPath = "/account/sessions/phone"; diff --git a/Appwrite/Services/Databases.cs b/Appwrite/Services/Databases.cs index 7fdee32..5df70ce 100644 --- a/Appwrite/Services/Databases.cs +++ b/Appwrite/Services/Databases.cs @@ -52,7 +52,7 @@ static Models.DatabaseList Convert(Dictionary it) => /// /// /// - [Obsolete("This API has been deprecated since 1.8.0. Please use `TablesDB.createDatabase` instead.")] + [Obsolete("This API has been deprecated since 1.8.0. Please use `TablesDB.create` instead.")] public Task Create(string databaseId, string name, bool? enabled = null) { var apiPath = "/databases"; @@ -935,6 +935,228 @@ static Models.AttributeIp Convert(Dictionary it) => } + /// + /// Create a geometric line attribute. + /// + /// + [Obsolete("This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead.")] + public Task CreateLineAttribute(string databaseId, string collectionId, string key, bool required, List? xdefault = null) + { + var apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/line" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var apiParameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.AttributeLine Convert(Dictionary it) => + Models.AttributeLine.From(map: it); + + return _client.Call( + method: "POST", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update a line attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// + [Obsolete("This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead.")] + public Task UpdateLineAttribute(string databaseId, string collectionId, string key, bool required, List? xdefault = null, string? newKey = null) + { + var apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var apiParameters = new Dictionary() + { + { "required", required }, + { "default", xdefault }, + { "newKey", newKey } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.AttributeLine Convert(Dictionary it) => + Models.AttributeLine.From(map: it); + + return _client.Call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create a geometric point attribute. + /// + /// + [Obsolete("This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead.")] + public Task CreatePointAttribute(string databaseId, string collectionId, string key, bool required, List? xdefault = null) + { + var apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/point" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var apiParameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.AttributePoint Convert(Dictionary it) => + Models.AttributePoint.From(map: it); + + return _client.Call( + method: "POST", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update a point attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// + [Obsolete("This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead.")] + public Task UpdatePointAttribute(string databaseId, string collectionId, string key, bool required, List? xdefault = null, string? newKey = null) + { + var apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var apiParameters = new Dictionary() + { + { "required", required }, + { "default", xdefault }, + { "newKey", newKey } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.AttributePoint Convert(Dictionary it) => + Models.AttributePoint.From(map: it); + + return _client.Call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create a geometric polygon attribute. + /// + /// + [Obsolete("This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead.")] + public Task CreatePolygonAttribute(string databaseId, string collectionId, string key, bool required, List? xdefault = null) + { + var apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId); + + var apiParameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.AttributePolygon Convert(Dictionary it) => + Models.AttributePolygon.From(map: it); + + return _client.Call( + method: "POST", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update a polygon attribute. Changing the `default` value will not update + /// already existing documents. + /// + /// + [Obsolete("This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead.")] + public Task UpdatePolygonAttribute(string databaseId, string collectionId, string key, bool required, List? xdefault = null, string? newKey = null) + { + var apiPath = "/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{collectionId}", collectionId) + .Replace("{key}", key); + + var apiParameters = new Dictionary() + { + { "required", required }, + { "default", xdefault }, + { "newKey", newKey } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.AttributePolygon Convert(Dictionary it) => + Models.AttributePolygon.From(map: it); + + return _client.Call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + /// /// Create relationship attribute. [Learn more about relationship /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). diff --git a/Appwrite/Services/TablesDb.cs b/Appwrite/Services/TablesDb.cs index bda4b8f..89cd69a 100644 --- a/Appwrite/Services/TablesDb.cs +++ b/Appwrite/Services/TablesDb.cs @@ -909,6 +909,222 @@ static Models.ColumnIp Convert(Dictionary it) => } + /// + /// Create a geometric line column. + /// + /// + public Task CreateLineColumn(string databaseId, string tableId, string key, bool required, List? xdefault = null) + { + var apiPath = "/tablesdb/{databaseId}/tables/{tableId}/columns/line" + .Replace("{databaseId}", databaseId) + .Replace("{tableId}", tableId); + + var apiParameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.ColumnLine Convert(Dictionary it) => + Models.ColumnLine.From(map: it); + + return _client.Call( + method: "POST", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update a line column. Changing the `default` value will not update already + /// existing rows. + /// + /// + public Task UpdateLineColumn(string databaseId, string tableId, string key, bool required, List? xdefault = null, string? newKey = null) + { + var apiPath = "/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{tableId}", tableId) + .Replace("{key}", key); + + var apiParameters = new Dictionary() + { + { "required", required }, + { "default", xdefault }, + { "newKey", newKey } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.ColumnLine Convert(Dictionary it) => + Models.ColumnLine.From(map: it); + + return _client.Call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create a geometric point column. + /// + /// + public Task CreatePointColumn(string databaseId, string tableId, string key, bool required, List? xdefault = null) + { + var apiPath = "/tablesdb/{databaseId}/tables/{tableId}/columns/point" + .Replace("{databaseId}", databaseId) + .Replace("{tableId}", tableId); + + var apiParameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.ColumnPoint Convert(Dictionary it) => + Models.ColumnPoint.From(map: it); + + return _client.Call( + method: "POST", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update a point column. Changing the `default` value will not update already + /// existing rows. + /// + /// + public Task UpdatePointColumn(string databaseId, string tableId, string key, bool required, List? xdefault = null, string? newKey = null) + { + var apiPath = "/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{tableId}", tableId) + .Replace("{key}", key); + + var apiParameters = new Dictionary() + { + { "required", required }, + { "default", xdefault }, + { "newKey", newKey } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.ColumnPoint Convert(Dictionary it) => + Models.ColumnPoint.From(map: it); + + return _client.Call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create a geometric polygon column. + /// + /// + public Task CreatePolygonColumn(string databaseId, string tableId, string key, bool required, List? xdefault = null) + { + var apiPath = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon" + .Replace("{databaseId}", databaseId) + .Replace("{tableId}", tableId); + + var apiParameters = new Dictionary() + { + { "key", key }, + { "required", required }, + { "default", xdefault } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.ColumnPolygon Convert(Dictionary it) => + Models.ColumnPolygon.From(map: it); + + return _client.Call( + method: "POST", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update a polygon column. Changing the `default` value will not update + /// already existing rows. + /// + /// + public Task UpdatePolygonColumn(string databaseId, string tableId, string key, bool required, List? xdefault = null, string? newKey = null) + { + var apiPath = "/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}" + .Replace("{databaseId}", databaseId) + .Replace("{tableId}", tableId) + .Replace("{key}", key); + + var apiParameters = new Dictionary() + { + { "required", required }, + { "default", xdefault }, + { "newKey", newKey } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.ColumnPolygon Convert(Dictionary it) => + Models.ColumnPolygon.From(map: it); + + return _client.Call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + /// /// Create relationship column. [Learn more about relationship /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). diff --git a/README.md b/README.md index 4c5bb22..4d2fdf9 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,17 @@ Appwrite is an open-source backend as a service server that abstract and simplif Add this reference to your project's `.csproj` file: ```xml - + ``` You can install packages from the command line: ```powershell # Package Manager -Install-Package Appwrite -Version 0.16.0 +Install-Package Appwrite -Version 0.17.0 # or .NET CLI -dotnet add package Appwrite --version 0.16.0 +dotnet add package Appwrite --version 0.17.0 ``` diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 0b348a9..80f42aa 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -10,5 +10,9 @@ Client client = new Client() Account account = new Account(client); User result = await account.UpdatePrefs( - prefs: [object] + prefs: new { + language = "en", + timezone = "UTC", + darkTheme = true + } ); \ No newline at end of file diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 52254e0..4a7444d 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -13,6 +13,12 @@ Document result = await databases.CreateDocument( databaseId: "", collectionId: "", documentId: "", - data: [object], + data: new { + username = "walter.obrien", + email = "walter.obrien@example.com", + fullName = "Walter O'Brien", + age = 30, + isAdmin = false + }, permissions: ["read("any")"] // optional ); \ No newline at end of file diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md new file mode 100644 index 0000000..11b0654 --- /dev/null +++ b/docs/examples/databases/create-line-attribute.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Databases databases = new Databases(client); + +AttributeLine result = await databases.CreateLineAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md new file mode 100644 index 0000000..6698e6d --- /dev/null +++ b/docs/examples/databases/create-point-attribute.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Databases databases = new Databases(client); + +AttributePoint result = await databases.CreatePointAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md new file mode 100644 index 0000000..b4de8bd --- /dev/null +++ b/docs/examples/databases/create-polygon-attribute.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Databases databases = new Databases(client); + +AttributePolygon result = await databases.CreatePolygonAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md new file mode 100644 index 0000000..90bd643 --- /dev/null +++ b/docs/examples/databases/update-line-attribute.md @@ -0,0 +1,19 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Databases databases = new Databases(client); + +AttributeLine result = await databases.UpdateLineAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md new file mode 100644 index 0000000..eb504b3 --- /dev/null +++ b/docs/examples/databases/update-point-attribute.md @@ -0,0 +1,19 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Databases databases = new Databases(client); + +AttributePoint result = await databases.UpdatePointAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md new file mode 100644 index 0000000..90cbac9 --- /dev/null +++ b/docs/examples/databases/update-polygon-attribute.md @@ -0,0 +1,19 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Databases databases = new Databases(client); + +AttributePolygon result = await databases.UpdatePolygonAttribute( + databaseId: "", + collectionId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md new file mode 100644 index 0000000..ee9640b --- /dev/null +++ b/docs/examples/tablesdb/create-line-column.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +ColumnLine result = await tablesDB.CreateLineColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md new file mode 100644 index 0000000..ea1c524 --- /dev/null +++ b/docs/examples/tablesdb/create-point-column.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +ColumnPoint result = await tablesDB.CreatePointColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md new file mode 100644 index 0000000..a514dd4 --- /dev/null +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +ColumnPolygon result = await tablesDB.CreatePolygonColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]] // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index ec6255a..01a21b0 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -13,6 +13,12 @@ Row result = await tablesDB.CreateRow( databaseId: "", tableId: "", rowId: "", - data: [object], + data: new { + username = "walter.obrien", + email = "walter.obrien@example.com", + fullName = "Walter O'Brien", + age = 30, + isAdmin = false + }, permissions: ["read("any")"] // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md new file mode 100644 index 0000000..b33213b --- /dev/null +++ b/docs/examples/tablesdb/update-line-column.md @@ -0,0 +1,19 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +ColumnLine result = await tablesDB.UpdateLineColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md new file mode 100644 index 0000000..db02716 --- /dev/null +++ b/docs/examples/tablesdb/update-point-column.md @@ -0,0 +1,19 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +ColumnPoint result = await tablesDB.UpdatePointColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md new file mode 100644 index 0000000..374033e --- /dev/null +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -0,0 +1,19 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +TablesDB tablesDB = new TablesDB(client); + +ColumnPolygon result = await tablesDB.UpdatePolygonColumn( + databaseId: "", + tableId: "", + key: "", + required: false, + default: [[1,2], [3, 4]], // optional + newKey: "" // optional +); \ No newline at end of file