diff --git a/docs/examples/account/create-key.md b/docs/examples/account/create-key.md deleted file mode 100644 index 212bf43..0000000 --- a/docs/examples/account/create-key.md +++ /dev/null @@ -1,16 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; -import 'package:appwrite/enums.dart' as enums; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -Key result = await account.createKey( - name: '', - scopes: [enums.Scopes.account], - expire: '', // optional -); -``` diff --git a/docs/examples/account/create-payment-method.md b/docs/examples/account/create-payment-method.md deleted file mode 100644 index 02e35b1..0000000 --- a/docs/examples/account/create-payment-method.md +++ /dev/null @@ -1,11 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -PaymentMethod result = await account.createPaymentMethod(); -``` diff --git a/docs/examples/account/delete-key.md b/docs/examples/account/delete-key.md deleted file mode 100644 index c1b7922..0000000 --- a/docs/examples/account/delete-key.md +++ /dev/null @@ -1,13 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -await account.deleteKey( - keyId: '', -); -``` diff --git a/docs/examples/account/delete-payment-method.md b/docs/examples/account/delete-payment-method.md deleted file mode 100644 index ceb4e6c..0000000 --- a/docs/examples/account/delete-payment-method.md +++ /dev/null @@ -1,13 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -await account.deletePaymentMethod( - paymentMethodId: '', -); -``` diff --git a/docs/examples/account/get-key.md b/docs/examples/account/get-key.md deleted file mode 100644 index edbdf4c..0000000 --- a/docs/examples/account/get-key.md +++ /dev/null @@ -1,13 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -Key result = await account.getKey( - keyId: '', -); -``` diff --git a/docs/examples/account/get-payment-method.md b/docs/examples/account/get-payment-method.md deleted file mode 100644 index d951659..0000000 --- a/docs/examples/account/get-payment-method.md +++ /dev/null @@ -1,13 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -PaymentMethod result = await account.getPaymentMethod( - paymentMethodId: '', -); -``` diff --git a/docs/examples/account/list-keys.md b/docs/examples/account/list-keys.md deleted file mode 100644 index 716f71c..0000000 --- a/docs/examples/account/list-keys.md +++ /dev/null @@ -1,13 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -KeyList result = await account.listKeys( - total: false, // optional -); -``` diff --git a/docs/examples/account/list-payment-methods.md b/docs/examples/account/list-payment-methods.md deleted file mode 100644 index 2afe564..0000000 --- a/docs/examples/account/list-payment-methods.md +++ /dev/null @@ -1,13 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -PaymentMethodList result = await account.listPaymentMethods( - queries: [], // optional -); -``` diff --git a/docs/examples/account/update-key.md b/docs/examples/account/update-key.md deleted file mode 100644 index b3e03b8..0000000 --- a/docs/examples/account/update-key.md +++ /dev/null @@ -1,17 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; -import 'package:appwrite/enums.dart' as enums; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -Key result = await account.updateKey( - keyId: '', - name: '', - scopes: [enums.Scopes.account], - expire: '', // optional -); -``` diff --git a/docs/examples/account/update-payment-method-mandate-options.md b/docs/examples/account/update-payment-method-mandate-options.md deleted file mode 100644 index 3e5d07c..0000000 --- a/docs/examples/account/update-payment-method-mandate-options.md +++ /dev/null @@ -1,13 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -PaymentMethod result = await account.updatePaymentMethodMandateOptions( - paymentMethodId: '', -); -``` diff --git a/docs/examples/account/update-payment-method-provider.md b/docs/examples/account/update-payment-method-provider.md deleted file mode 100644 index 0aae172..0000000 --- a/docs/examples/account/update-payment-method-provider.md +++ /dev/null @@ -1,16 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -PaymentMethod result = await account.updatePaymentMethodProvider( - paymentMethodId: '', - providerMethodId: '', - name: '', - state: '', // optional -); -``` diff --git a/docs/examples/account/update-payment-method.md b/docs/examples/account/update-payment-method.md deleted file mode 100644 index 5390939..0000000 --- a/docs/examples/account/update-payment-method.md +++ /dev/null @@ -1,16 +0,0 @@ -```dart -import 'package:appwrite/appwrite.dart'; - -Client client = Client() - .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - .setProject(''); // Your project ID - -Account account = Account(client); - -PaymentMethod result = await account.updatePaymentMethod( - paymentMethodId: '', - expiryMonth: 1, - expiryYear: 2026, - state: '', // optional -); -``` diff --git a/lib/enums.dart b/lib/enums.dart index f4b466f..0063dff 100644 --- a/lib/enums.dart +++ b/lib/enums.dart @@ -1,7 +1,6 @@ /// Appwrite Enums library appwrite.enums; -part 'src/enums/scopes.dart'; part 'src/enums/authenticator_type.dart'; part 'src/enums/authentication_factor.dart'; part 'src/enums/o_auth_provider.dart'; diff --git a/lib/models.dart b/lib/models.dart index 872d6d1..ca9bccc 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -13,7 +13,6 @@ part 'src/models/file_list.dart'; part 'src/models/team_list.dart'; part 'src/models/membership_list.dart'; part 'src/models/execution_list.dart'; -part 'src/models/key_list.dart'; part 'src/models/country_list.dart'; part 'src/models/continent_list.dart'; part 'src/models/language_list.dart'; @@ -43,7 +42,6 @@ part 'src/models/file.dart'; part 'src/models/team.dart'; part 'src/models/membership.dart'; part 'src/models/execution.dart'; -part 'src/models/key.dart'; part 'src/models/country.dart'; part 'src/models/continent.dart'; part 'src/models/language.dart'; @@ -57,5 +55,3 @@ part 'src/models/mfa_factors.dart'; part 'src/models/transaction.dart'; part 'src/models/subscriber.dart'; part 'src/models/target.dart'; -part 'src/models/payment_method.dart'; -part 'src/models/payment_method_list.dart'; diff --git a/lib/services/account.dart b/lib/services/account.dart index 2830514..f4dda77 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -134,102 +134,6 @@ class Account extends Service { return models.Jwt.fromMap(res.data); } - /// Get a list of all API keys from the current account. - Future listKeys({bool? total}) async { - const String apiPath = '/account/keys'; - - final Map apiParams = { - if (total != null) 'total': total, - }; - - final Map apiHeaders = {}; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.KeyList.fromMap(res.data); - } - - /// Create a new account API key. - Future createKey( - {required String name, - required List scopes, - String? expire}) async { - const String apiPath = '/account/keys'; - - final Map apiParams = { - 'name': name, - 'scopes': scopes.map((e) => e.value).toList(), - 'expire': expire, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Key.fromMap(res.data); - } - - /// Get a key by its unique ID. This endpoint returns details about a specific - /// API key in your account including it's scopes. - Future getKey({required String keyId}) async { - final String apiPath = '/account/keys/{keyId}'.replaceAll('{keyId}', keyId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Key.fromMap(res.data); - } - - /// Update a key by its unique ID. Use this endpoint to update the name, - /// scopes, or expiration time of an API key. - Future updateKey( - {required String keyId, - required String name, - required List scopes, - String? expire}) async { - final String apiPath = '/account/keys/{keyId}'.replaceAll('{keyId}', keyId); - - final Map apiParams = { - 'name': name, - 'scopes': scopes.map((e) => e.value).toList(), - 'expire': expire, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.put, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Key.fromMap(res.data); - } - - /// Delete a key by its unique ID. Once deleted, the key can no longer be used - /// to authenticate API calls. - Future deleteKey({required String keyId}) async { - final String apiPath = '/account/keys/{keyId}'.replaceAll('{keyId}', keyId); - - final Map apiParams = {}; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, - path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - } - /// Get the list of latest security activity logs for the currently logged in /// user. Each log returns user IP address, location and date and time of log. Future listLogs({List? queries, bool? total}) async { @@ -674,140 +578,6 @@ class Account extends Service { return models.User.fromMap(res.data); } - /// List payment methods for this account. - Future listPaymentMethods( - {List? queries}) async { - const String apiPath = '/account/payment-methods'; - - final Map apiParams = { - if (queries != null) 'queries': queries, - }; - - final Map apiHeaders = {}; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.PaymentMethodList.fromMap(res.data); - } - - /// Create a new payment method for the current user account. - Future createPaymentMethod() async { - const String apiPath = '/account/payment-methods'; - - final Map apiParams = {}; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.PaymentMethod.fromMap(res.data); - } - - /// Get a specific payment method for the user. - Future getPaymentMethod( - {required String paymentMethodId}) async { - final String apiPath = '/account/payment-methods/{paymentMethodId}' - .replaceAll('{paymentMethodId}', paymentMethodId); - - final Map apiParams = {}; - - final Map apiHeaders = {}; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.PaymentMethod.fromMap(res.data); - } - - /// Update a new payment method for the current user account. - Future updatePaymentMethod( - {required String paymentMethodId, - required int expiryMonth, - required int expiryYear, - String? state}) async { - final String apiPath = '/account/payment-methods/{paymentMethodId}' - .replaceAll('{paymentMethodId}', paymentMethodId); - - final Map apiParams = { - 'expiryMonth': expiryMonth, - 'expiryYear': expiryYear, - if (state != null) 'state': state, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.PaymentMethod.fromMap(res.data); - } - - /// Delete a specific payment method from a user's account. - Future deletePaymentMethod({required String paymentMethodId}) async { - final String apiPath = '/account/payment-methods/{paymentMethodId}' - .replaceAll('{paymentMethodId}', paymentMethodId); - - final Map apiParams = {}; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.delete, - path: apiPath, params: apiParams, headers: apiHeaders); - - return res.data; - } - - /// Update payment method provider. - Future updatePaymentMethodProvider( - {required String paymentMethodId, - required String providerMethodId, - required String name, - String? state}) async { - final String apiPath = '/account/payment-methods/{paymentMethodId}/provider' - .replaceAll('{paymentMethodId}', paymentMethodId); - - final Map apiParams = { - 'providerMethodId': providerMethodId, - 'name': name, - 'state': state, - }; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.PaymentMethod.fromMap(res.data); - } - - /// Update payment method mandate options. - Future updatePaymentMethodMandateOptions( - {required String paymentMethodId}) async { - final String apiPath = '/account/payment-methods/{paymentMethodId}/setup' - .replaceAll('{paymentMethodId}', paymentMethodId); - - final Map apiParams = {}; - - final Map apiHeaders = { - 'content-type': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.PaymentMethod.fromMap(res.data); - } - /// Update the currently logged in user's phone number. After updating the /// phone number, the phone verification status will be reset. A confirmation /// SMS is not sent automatically, however you can use the [POST diff --git a/lib/src/enums/scopes.dart b/lib/src/enums/scopes.dart deleted file mode 100644 index 7d68f07..0000000 --- a/lib/src/enums/scopes.dart +++ /dev/null @@ -1,13 +0,0 @@ -part of '../../enums.dart'; - -enum Scopes { - account(value: 'account'), - teamsRead(value: 'teams.read'), - teamsWrite(value: 'teams.write'); - - const Scopes({required this.value}); - - final String value; - - String toJson() => value; -} diff --git a/lib/src/models/key.dart b/lib/src/models/key.dart deleted file mode 100644 index 1594609..0000000 --- a/lib/src/models/key.dart +++ /dev/null @@ -1,72 +0,0 @@ -part of '../../models.dart'; - -/// Key -class Key implements Model { - /// Key ID. - final String $id; - - /// Key creation date in ISO 8601 format. - final String $createdAt; - - /// Key update date in ISO 8601 format. - final String $updatedAt; - - /// Key name. - final String name; - - /// Key expiration date in ISO 8601 format. - final String expire; - - /// Allowed permission scopes. - final List scopes; - - /// Secret key. - final String secret; - - /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. - final String accessedAt; - - /// List of SDK user agents that used this key. - final List sdks; - - Key({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.name, - required this.expire, - required this.scopes, - required this.secret, - required this.accessedAt, - required this.sdks, - }); - - factory Key.fromMap(Map map) { - return Key( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - name: map['name'].toString(), - expire: map['expire'].toString(), - scopes: List.from(map['scopes'] ?? []), - secret: map['secret'].toString(), - accessedAt: map['accessedAt'].toString(), - sdks: List.from(map['sdks'] ?? []), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "expire": expire, - "scopes": scopes, - "secret": secret, - "accessedAt": accessedAt, - "sdks": sdks, - }; - } -} diff --git a/lib/src/models/key_list.dart b/lib/src/models/key_list.dart deleted file mode 100644 index 127a6cd..0000000 --- a/lib/src/models/key_list.dart +++ /dev/null @@ -1,30 +0,0 @@ -part of '../../models.dart'; - -/// API Keys List -class KeyList implements Model { - /// Total number of keys that matched your query. - final int total; - - /// List of keys. - final List keys; - - KeyList({ - required this.total, - required this.keys, - }); - - factory KeyList.fromMap(Map map) { - return KeyList( - total: map['total'], - keys: List.from(map['keys'].map((p) => Key.fromMap(p))), - ); - } - - @override - Map toMap() { - return { - "total": total, - "keys": keys.map((p) => p.toMap()).toList(), - }; - } -} diff --git a/lib/src/models/payment_method.dart b/lib/src/models/payment_method.dart deleted file mode 100644 index 0e18ac2..0000000 --- a/lib/src/models/payment_method.dart +++ /dev/null @@ -1,138 +0,0 @@ -part of '../../models.dart'; - -/// paymentMethod -class PaymentMethod implements Model { - /// Payment Method ID. - final String $id; - - /// Payment method creation time in ISO 8601 format. - final String $createdAt; - - /// Payment method update date in ISO 8601 format. - final String $updatedAt; - - /// Payment method permissions. [Learn more about permissions](/docs/permissions). - final List $permissions; - - /// Payment method ID from the payment provider - final String providerMethodId; - - /// Client secret hash for payment setup - final String clientSecret; - - /// User ID from the payment provider. - final String providerUserId; - - /// ID of the Team. - final String userId; - - /// Expiry month of the payment method. - final int expiryMonth; - - /// Expiry year of the payment method. - final int expiryYear; - - /// Last 4 digit of the payment method - final String last4; - - /// Payment method brand - final String brand; - - /// Name of the owner - final String name; - - /// Mandate ID of the payment method - final String mandateId; - - /// Country of the payment method - final String country; - - /// State of the payment method - final String state; - - /// Last payment error associated with the payment method. - final String lastError; - - /// True when it's the default payment method. - final bool xdefault; - - /// True when payment method has expired. - final bool expired; - - /// True when payment method has failed to process multiple times. - final bool failed; - - PaymentMethod({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.providerMethodId, - required this.clientSecret, - required this.providerUserId, - required this.userId, - required this.expiryMonth, - required this.expiryYear, - required this.last4, - required this.brand, - required this.name, - required this.mandateId, - required this.country, - required this.state, - required this.lastError, - required this.xdefault, - required this.expired, - required this.failed, - }); - - factory PaymentMethod.fromMap(Map map) { - return PaymentMethod( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - providerMethodId: map['providerMethodId'].toString(), - clientSecret: map['clientSecret'].toString(), - providerUserId: map['providerUserId'].toString(), - userId: map['userId'].toString(), - expiryMonth: map['expiryMonth'], - expiryYear: map['expiryYear'], - last4: map['last4'].toString(), - brand: map['brand'].toString(), - name: map['name'].toString(), - mandateId: map['mandateId'].toString(), - country: map['country'].toString(), - state: map['state'].toString(), - lastError: map['lastError'].toString(), - xdefault: map['default'], - expired: map['expired'], - failed: map['failed'], - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "providerMethodId": providerMethodId, - "clientSecret": clientSecret, - "providerUserId": providerUserId, - "userId": userId, - "expiryMonth": expiryMonth, - "expiryYear": expiryYear, - "last4": last4, - "brand": brand, - "name": name, - "mandateId": mandateId, - "country": country, - "state": state, - "lastError": lastError, - "default": xdefault, - "expired": expired, - "failed": failed, - }; - } -} diff --git a/lib/src/models/payment_method_list.dart b/lib/src/models/payment_method_list.dart deleted file mode 100644 index 830a81b..0000000 --- a/lib/src/models/payment_method_list.dart +++ /dev/null @@ -1,31 +0,0 @@ -part of '../../models.dart'; - -/// Payment methods list -class PaymentMethodList implements Model { - /// Total number of paymentMethods that matched your query. - final int total; - - /// List of paymentMethods. - final List paymentMethods; - - PaymentMethodList({ - required this.total, - required this.paymentMethods, - }); - - factory PaymentMethodList.fromMap(Map map) { - return PaymentMethodList( - total: map['total'], - paymentMethods: List.from( - map['paymentMethods'].map((p) => PaymentMethod.fromMap(p))), - ); - } - - @override - Map toMap() { - return { - "total": total, - "paymentMethods": paymentMethods.map((p) => p.toMap()).toList(), - }; - } -} diff --git a/test/services/account_test.dart b/test/services/account_test.dart index 1937a38..c91bab8 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -188,104 +188,6 @@ void main() { expect(response, isA()); }); - test('test method listKeys()', () async { - final Map data = { - 'total': 5, - 'keys': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.listKeys(); - expect(response, isA()); - }); - - test('test method createKey()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'My API Key', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'scopes': [], - 'secret': '919c2d18fb5d4...a2ae413da83346ad2', - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - 'sdks': [], - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createKey( - name: '', - scopes: [enums.Scopes.account], - ); - expect(response, isA()); - }); - - test('test method getKey()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'My API Key', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'scopes': [], - 'secret': '919c2d18fb5d4...a2ae413da83346ad2', - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - 'sdks': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.getKey( - keyId: '', - ); - expect(response, isA()); - }); - - test('test method updateKey()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'My API Key', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'scopes': [], - 'secret': '919c2d18fb5d4...a2ae413da83346ad2', - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - 'sdks': [], - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateKey( - keyId: '', - name: '', - scopes: [enums.Scopes.account], - ); - expect(response, isA()); - }); - - test('test method deleteKey()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.deleteKey( - keyId: '', - ); - }); - test('test method listLogs()', () async { final Map data = { 'total': 5, @@ -742,204 +644,6 @@ void main() { expect(response, isA()); }); - test('test method listPaymentMethods()', () async { - final Map data = { - 'total': 5, - 'paymentMethods': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.listPaymentMethods(); - expect(response, isA()); - }); - - test('test method createPaymentMethod()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'providerMethodId': 'abdk3ed3sdkfj', - 'clientSecret': 'seti_ddfe', - 'providerUserId': 'abdk3ed3sdkfj', - 'userId': '5e5ea5c16897e', - 'expiryMonth': 2, - 'expiryYear': 2024, - 'last4': '4242', - 'brand': 'visa', - 'name': 'John Doe', - 'mandateId': 'yxc', - 'country': 'de', - 'state': '', - 'lastError': 'Your card has insufficient funds.', - 'default': true, - 'expired': true, - 'failed': true, - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPaymentMethod(); - expect(response, isA()); - }); - - test('test method getPaymentMethod()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'providerMethodId': 'abdk3ed3sdkfj', - 'clientSecret': 'seti_ddfe', - 'providerUserId': 'abdk3ed3sdkfj', - 'userId': '5e5ea5c16897e', - 'expiryMonth': 2, - 'expiryYear': 2024, - 'last4': '4242', - 'brand': 'visa', - 'name': 'John Doe', - 'mandateId': 'yxc', - 'country': 'de', - 'state': '', - 'lastError': 'Your card has insufficient funds.', - 'default': true, - 'expired': true, - 'failed': true, - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.getPaymentMethod( - paymentMethodId: '', - ); - expect(response, isA()); - }); - - test('test method updatePaymentMethod()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'providerMethodId': 'abdk3ed3sdkfj', - 'clientSecret': 'seti_ddfe', - 'providerUserId': 'abdk3ed3sdkfj', - 'userId': '5e5ea5c16897e', - 'expiryMonth': 2, - 'expiryYear': 2024, - 'last4': '4242', - 'brand': 'visa', - 'name': 'John Doe', - 'mandateId': 'yxc', - 'country': 'de', - 'state': '', - 'lastError': 'Your card has insufficient funds.', - 'default': true, - 'expired': true, - 'failed': true, - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePaymentMethod( - paymentMethodId: '', - expiryMonth: 1, - expiryYear: 1, - ); - expect(response, isA()); - }); - - test('test method deletePaymentMethod()', () async { - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.deletePaymentMethod( - paymentMethodId: '', - ); - }); - - test('test method updatePaymentMethodProvider()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'providerMethodId': 'abdk3ed3sdkfj', - 'clientSecret': 'seti_ddfe', - 'providerUserId': 'abdk3ed3sdkfj', - 'userId': '5e5ea5c16897e', - 'expiryMonth': 2, - 'expiryYear': 2024, - 'last4': '4242', - 'brand': 'visa', - 'name': 'John Doe', - 'mandateId': 'yxc', - 'country': 'de', - 'state': '', - 'lastError': 'Your card has insufficient funds.', - 'default': true, - 'expired': true, - 'failed': true, - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePaymentMethodProvider( - paymentMethodId: '', - providerMethodId: '', - name: '', - ); - expect(response, isA()); - }); - - test('test method updatePaymentMethodMandateOptions()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'providerMethodId': 'abdk3ed3sdkfj', - 'clientSecret': 'seti_ddfe', - 'providerUserId': 'abdk3ed3sdkfj', - 'userId': '5e5ea5c16897e', - 'expiryMonth': 2, - 'expiryYear': 2024, - 'last4': '4242', - 'brand': 'visa', - 'name': 'John Doe', - 'mandateId': 'yxc', - 'country': 'de', - 'state': '', - 'lastError': 'Your card has insufficient funds.', - 'default': true, - 'expired': true, - 'failed': true, - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePaymentMethodMandateOptions( - paymentMethodId: '', - ); - expect(response, isA()); - }); - test('test method updatePhone()', () async { final Map data = { '\$id': '5e5ea5c16897e', diff --git a/test/src/models/key_list_test.dart b/test/src/models/key_list_test.dart deleted file mode 100644 index ab109f8..0000000 --- a/test/src/models/key_list_test.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('KeyList', () { - test('model', () { - final model = KeyList( - total: 5, - keys: [], - ); - - final map = model.toMap(); - final result = KeyList.fromMap(map); - - expect(result.total, 5); - expect(result.keys, []); - }); - }); -} diff --git a/test/src/models/key_test.dart b/test/src/models/key_test.dart deleted file mode 100644 index 6afa084..0000000 --- a/test/src/models/key_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('Key', () { - test('model', () { - final model = Key( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'My API Key', - expire: '2020-10-15T06:38:00.000+00:00', - scopes: [], - secret: '919c2d18fb5d4...a2ae413da83346ad2', - accessedAt: '2020-10-15T06:38:00.000+00:00', - sdks: [], - ); - - final map = model.toMap(); - final result = Key.fromMap(map); - - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'My API Key'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.scopes, []); - expect(result.secret, '919c2d18fb5d4...a2ae413da83346ad2'); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.sdks, []); - }); - }); -} diff --git a/test/src/models/payment_method_list_test.dart b/test/src/models/payment_method_list_test.dart deleted file mode 100644 index ed42e02..0000000 --- a/test/src/models/payment_method_list_test.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('PaymentMethodList', () { - test('model', () { - final model = PaymentMethodList( - total: 5, - paymentMethods: [], - ); - - final map = model.toMap(); - final result = PaymentMethodList.fromMap(map); - - expect(result.total, 5); - expect(result.paymentMethods, []); - }); - }); -} diff --git a/test/src/models/payment_method_test.dart b/test/src/models/payment_method_test.dart deleted file mode 100644 index 7e52d8f..0000000 --- a/test/src/models/payment_method_test.dart +++ /dev/null @@ -1,55 +0,0 @@ -import 'package:appwrite/models.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - group('PaymentMethod', () { - test('model', () { - final model = PaymentMethod( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - $permissions: [], - providerMethodId: 'abdk3ed3sdkfj', - clientSecret: 'seti_ddfe', - providerUserId: 'abdk3ed3sdkfj', - userId: '5e5ea5c16897e', - expiryMonth: 2, - expiryYear: 2024, - last4: '4242', - brand: 'visa', - name: 'John Doe', - mandateId: 'yxc', - country: 'de', - state: '', - lastError: 'Your card has insufficient funds.', - xdefault: true, - expired: true, - failed: true, - ); - - final map = model.toMap(); - final result = PaymentMethod.fromMap(map); - - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.providerMethodId, 'abdk3ed3sdkfj'); - expect(result.clientSecret, 'seti_ddfe'); - expect(result.providerUserId, 'abdk3ed3sdkfj'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.expiryMonth, 2); - expect(result.expiryYear, 2024); - expect(result.last4, '4242'); - expect(result.brand, 'visa'); - expect(result.name, 'John Doe'); - expect(result.mandateId, 'yxc'); - expect(result.country, 'de'); - expect(result.state, ''); - expect(result.lastError, 'Your card has insufficient funds.'); - expect(result.xdefault, true); - expect(result.expired, true); - expect(result.failed, true); - }); - }); -}