diff --git a/lib/api/api_repository.dart b/lib/api/api_repository.dart index edf527599..5c231f20c 100644 --- a/lib/api/api_repository.dart +++ b/lib/api/api_repository.dart @@ -15,60 +15,6 @@ abstract class ApiRepository { /// Closes the connection to the api. This must be called when logging out. void close(); - /// Get the [Event] with the `pk`. - Future getEventByPk({required int pk}); - - Future getEventBySlug({required String slug}); - - /// Get a list of [Event]s. - /// - /// Use `limit` and `offset` for pagination. [ListResponse.count] is the - /// total number of [Events] that can be returned. - /// Use `search` to filter on name, `ordering` to order with values in - /// {'start', 'end', '-start', '-end'}, and `start` and/or `end` to filter on - /// a time range. - Future> getEvents({ - String? search, - int? limit, - int? offset, - String? ordering, - DateTime? start, - DateTime? end, - }); - - /// Get a list of [PartnerEvent]s. - /// - /// Use `limit` and `offset` for pagination. [ListResponse.count] is the - /// total number of [PartnerEvents] that can be returned. - /// Use `search` to filter on name, `ordering` to order with values in - /// {'start', 'end', '-start', '-end'}, and `start` and/or `end` to filter on - /// a time range. - Future> getPartnerEvents({ - String? search, - int? limit, - int? offset, - String? ordering, - DateTime? start, - DateTime? end, - }); - - /// Get the [EventRegistration]s for the [Event] with the `pk`. - /// - /// Use `limit` and `offset` for pagination. [ListResponse.count] is the - /// total number of [EventRegistration]s that can be returned. - /// - /// These [EventRegistration]s are not cancelled. It's the publicly visible - /// list. The admin of an event can use [getAdminEventRegistrations()] to - /// include cancelled or queued registrations. - Future> getEventRegistrations({ - required int pk, - int? limit, - int? offset, - }); - - /// Register for the [Event] with the `pk`. - Future registerForEvent(int pk); - /// Cancel the [EventRegistration] with `registrationPk` /// for the [Event] with `eventPk`. Future cancelRegistration({ @@ -76,184 +22,25 @@ abstract class ApiRepository { required int registrationPk, }); - /// Get the [RegistrationField]s of [EventRegistration] `registrationPk` - /// for [Event] `eventPk`. - /// - /// Returns a [Map] of identifiers and corresponding [RegistrationFields]. - Future> getRegistrationFields({ - required int eventPk, - required int registrationPk, - }); - - /// Update the [RegistrationField]s of EventRegistration] `registrationPk` - /// for [Event] `eventPk` to the values in `fields`. - /// - /// `fields` must contain every [RegistrationField] returned by - /// [this.getRegistrationFields()], possibly with null values. - Future updateRegistrationFields({ - required int eventPk, - required int registrationPk, - required Map fields, - }); - - /// Get the [AdminEvent] with the `pk`. - Future getAdminEvent({required int pk}); - - /// Get the [AdminEventRegistration]s of the [Event] with the `pk`. - /// - /// Use `limit` and `offset` for pagination. [ListResponse.count] is the - /// total number of registrations that can be returned. - /// Use `search` to filter on name, `ordering` to order with values in - /// {'date', 'date_cancelled', 'queue_position', '-date', '-date_cancelled', - /// '-queue_position'}, `cancelled` to filter on cancelled registrations, and `queued` to filter on queued registrations. - Future> getAdminEventRegistrations({ - required int pk, - int? limit, - int? offset, - String? search, - String? ordering, - bool? cancelled, - bool? queued, - }); - /// Mark the user's registration for [Event] `pk` as present, using `token`. Future markPresentEventRegistration({ required int eventPk, required String token, }); - /// Mark registration `registrationPk` for [Event] `eventPk` as `present`. - Future markPresentAdminEventRegistration({ - required int eventPk, - required int registrationPk, - required bool present, - }); - - /// Mark registration `registrationPk` as paid with `paymentType`. - Future markPaidAdminEventRegistration({ - required int registrationPk, - required PaymentType paymentType, - }); - /// Delete the payment for registration `registrationPk`. Future markNotPaidAdminEventRegistration({ required int registrationPk, }); - /// Get the [AdminFoodOrder]s of the [FoodEvent] with the `pk`. - /// - /// Use `limit` and `offset` for pagination. [ListResponse.count] is the - /// total number of orders that can be returned. - Future> getAdminFoodOrders({ - required int pk, - int? limit, - int? offset, - String? search, - }); - - /// Mark food order `orderPk` as paid with `paymentType`. - Future markPaidAdminFoodOrder({ - required int orderPk, - required PaymentType paymentType, - }); - /// Delete the payment for food order `orderPk`. Future markNotPaidAdminFoodOrder({ required int orderPk, }); - /// Get the [FoodEvent] with the `pk`. - Future getFoodEvent(int pk); - - /// Get a list of [FoodEvent]s. - /// - /// Use `limit` and `offset` for pagination. [ListResponse.count] is the - /// total number of [FoodEvents] that can be returned. - /// Use `search` to filter on name, `ordering` to order with values in - /// {'start', 'end', '-start', '-end'}, and `start` and/or `end` to filter - /// on a time range. - Future> getFoodEvents({ - int? limit, - int? offset, - String? ordering, - DateTime? start, - DateTime? end, - }); - - /// Get the [FoodEvent] that is currently going on. - Future getCurrentFoodEvent(); - - /// Get the [FoodOrder] for the [FoodEvent] with the `pk`. - Future getFoodOrder(int pk); - /// Cancel your [FoodOrder] for the [FoodEvent] with the `pk`. Future cancelFoodOrder(int pk); - /// Place an order [Product] `productPk` on [FoodEvent] `eventPk`. - Future placeFoodOrder({ - required int eventPk, - required int productPk, - }); - - /// Change your order to [Product] `productPk` on [FoodEvent] `eventPk`. - Future changeFoodOrder({ - required int eventPk, - required int productPk, - }); - - /// Get a list of [Product]s for the [FoodEvent] with the `pk`. - /// - /// Use `limit` and `offset` for pagination. [ListResponse.count] is the - /// total number of [Product]s that can be returned. - /// Use `search` to filter on name. - Future> getFoodEventProducts( - int pk, { - int? limit, - int? offset, - String? search, - }); - - /// Get the [PaymentUser] of the currently logged in member. - Future getPaymentUser(); - - /// Get the [Payable] for the [FoodOrder] with the `foodOrderPk`. - Future getFoodOrderPayable({required int foodOrderPk}); - - /// Pay for the [FoodOrder] with the `foodOrderPk` with Thalia Pay. - Future thaliaPayFoodOrder({required int foodOrderPk}); - - /// Get the [Payable] for the [EventRegistration] with the `registrationPk`. - Future getEventRegistrationPayable({required int registrationPk}); - - /// Pay for the [EventRegistration] with the `registrationPk` with Thalia Pay. - Future thaliaPayRegistration({required int registrationPk}); - - /// get the [Payable] for the sales order with the `salesOrderPk`. - Future getSalesOrderPayable({required String salesOrderPk}); - - /// Pay for the sales order with the `salesOrderPk` with Thalia Pay. - Future thaliaPaySalesOrder({required String salesOrderPk}); - - /// Get the [Member] with the `pk`. - Future getMember({required int pk}); - - /// Get a list of [ListMember]s. - /// - /// Use `limit` and `offset` for pagination. [ListResponse.count] is the - /// total number of [ListMember]s that can be returned. - /// Use `search` to filter on name, `ordering` to order with values in - /// {'last_name', 'first_name', 'username', '-last_name', '-first_name', - /// '-username'}, - Future> getMembers({ - String? search, - int? limit, - int? offset, - String? ordering, - }); - - /// Get the logged in [FullMember]. - Future getMe(); - /// Update the avatar of the logged in member. /// /// `filePath` should be the path of a jpg image. @@ -279,15 +66,6 @@ abstract class ApiRepository { int? offset, }); - /// Get a list of [Slide]s. - /// - /// Use `limit` and `offset` for pagination. [ListResponse.count] is the - /// total number of [Slide]s that can be returned. - Future> getSlides({ - int? limit, - int? offset, - }); - /// Get a list of [FrontpageArticle]s. /// /// Use `limit` and `offset` for pagination. [ListResponse.count] is the @@ -297,73 +75,8 @@ abstract class ApiRepository { int? offset, }); - /// Create a new [Device] for receiving push notifications. - /// - /// This is used to let the backend know where to send notifications. The - /// `type` should be one of {'android', 'ios'}. This method creates a new - /// device. When the token changes, do not create a new device, but use - /// [updateDeviceToken]. - Future registerDevice({ - required String token, - required String type, - bool active = true, - }); - - /// Get the [Device] with the `pk`. - Future getDevice({required int pk}); - - /// Set `active` to `false` for the [Device] with the `pk`. - Future disableDevice({required int pk}); - - /// Update the `token` of the [Device] with the `pk`. - Future updateDeviceToken({required int pk, required String token}); - - /// Update the `receiveCategory` of the [Device] with the `pk`. - Future updateDeviceReceiveCategory({ - required int pk, - required List receiveCategory, - }); - - /// Get the list of all [PushNotificationCategory]s. - Future> getCategories(); - - /// Claim and get the [SalesOrder] with the `pk`. - Future claimSalesOrder({required String pk}); - - /// Get a list of [ListGroup]s. - /// - /// Use `limit` and `offset` for pagination, and `type`, `start`, `end` and - /// `search` for filtering. [ListResponse.count] is the total number of - /// [ListGroup]s that can be returned. - Future> getGroups({ - int? limit, - int? offset, - MemberGroupType? type, - DateTime? start, - DateTime? end, - String? search, - }); - - /// Get the [Group] with the `pk`. - Future getGroup({required int pk}); - - /// Get the [Group] of a certain [MemberGroupType] with the `slug`. - Future getGroupBySlug( - {required MemberGroupType type, required String slug}); - Future> getLikedPhotos({ int? limit, int? offset, }); - - /// Get a list of [Payment]'s of the current user. - Future> getPayments({ - int? limit, - int? offset, - String? ordering, - DateTime? start, - DateTime? end, - List? type, - bool? settled, - }); } diff --git a/lib/api/concrexit_api_repository.dart b/lib/api/concrexit_api_repository.dart index f870da001..3f48943b7 100644 --- a/lib/api/concrexit_api_repository.dart +++ b/lib/api/concrexit_api_repository.dart @@ -195,161 +195,6 @@ class ConcrexitApiRepository implements ApiRepository { } } - @override - Future getEventByPk({required int pk}) { - return sandbox(() async { - final uri = _uri(path: '/events/$pk/'); - final response = await _handleExceptions(() => _client.get(uri)); - - final event = Event.fromJson(_jsonDecode(response)); - if (event.isRegistered) { - try { - await getEventRegistrationPayable( - registrationPk: event.registration!.pk, - ); - event.registration!.tpayAllowed = true; - } on ApiException catch (exception) { - if (exception != ApiException.notAllowed) rethrow; - } - } - return event; - }); - } - - @override - Future getEventBySlug({required String slug}) { - return sandbox(() async { - final uri = _uri(path: '/events/$slug/'); - final response = await _handleExceptions(() => _client.get(uri)); - final event = Event.fromJson(_jsonDecode(response)); - if (event.isRegistered) { - try { - await getEventRegistrationPayable( - registrationPk: event.registration!.pk, - ); - event.registration!.tpayAllowed = true; - } on ApiException catch (exception) { - if (exception != ApiException.notAllowed) rethrow; - } - } - return event; - }); - } - - @override - Future> getEvents({ - String? search, - int? limit, - int? offset, - String? ordering, - DateTime? start, - DateTime? end, - }) { - assert( - ordering == null || ['start', 'end', '-start', '-end'].contains(ordering), - 'Invalid ordering parameter: $ordering', - ); - return sandbox(() async { - final uri = _uri( - path: '/events/', - query: { - if (search != null) 'search': search, - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - if (ordering != null) 'ordering': ordering, - if (start != null) 'start': start.toLocal().toIso8601String(), - if (end != null) 'end': end.toLocal().toIso8601String(), - }, - ); - - final response = await _handleExceptions(() => _client.get(uri)); - return await compute(_parseEvents, response); - }); - } - - static ListResponse _parseEvents(Response response) { - return ListResponse.fromJson( - _jsonDecode(response), - (json) => Event.fromJson(json as Map), - ); - } - - @override - Future> getPartnerEvents({ - String? search, - int? limit, - int? offset, - String? ordering, - DateTime? start, - DateTime? end, - }) { - assert( - ordering == null || ['start', 'end', '-start', '-end'].contains(ordering), - 'Invalid ordering parameter: $ordering', - ); - return sandbox(() async { - final uri = _uri( - path: '/events/external/', - query: { - if (search != null) 'search': search, - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - if (ordering != null) 'ordering': ordering, - if (start != null) 'start': start.toLocal().toIso8601String(), - if (end != null) 'end': end.toLocal().toIso8601String(), - }, - ); - - final response = await _handleExceptions(() => _client.get(uri)); - return await compute(_parsePartnerEvents, response); - }); - } - - static ListResponse _parsePartnerEvents(Response response) { - return ListResponse.fromJson( - _jsonDecode(response), - (json) => PartnerEvent.fromJson(json as Map), - ); - } - - @override - Future> getEventRegistrations({ - required int pk, - int? limit, - int? offset, - }) async { - return sandbox(() async { - final uri = _uri( - path: '/events/$pk/registrations/', - query: { - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - }, - ); - - final response = await _handleExceptions(() => _client.get(uri)); - return await compute(_parseEventRegistrations, response); - }); - } - - static ListResponse _parseEventRegistrations( - Response response, - ) { - return ListResponse.fromJson( - _jsonDecode(response), - (json) => EventRegistration.fromJson(json as Map), - ); - } - - @override - Future registerForEvent(int pk) async { - return sandbox(() async { - final uri = _uri(path: '/events/$pk/registrations/'); - final response = await _handleExceptions(() => _client.post(uri)); - return EventRegistration.fromJson(_jsonDecode(response)); - }); - } - @override Future cancelRegistration({ required int eventPk, @@ -361,120 +206,6 @@ class ConcrexitApiRepository implements ApiRepository { }); } - @override - Future> getRegistrationFields({ - required int eventPk, - required int registrationPk, - }) async { - return sandbox(() async { - final uri = _uri( - path: '/events/$eventPk/registrations/$registrationPk/fields/', - ); - final response = await _handleExceptions(() => _client.get(uri)); - var json = _jsonDecode(response); - return json.map( - (key, jsonField) => MapEntry( - key, - RegistrationField.fromJson(jsonField as Map), - ), - ); - }); - } - - @override - Future updateRegistrationFields({ - required int eventPk, - required int registrationPk, - required Map fields, - }) async { - return sandbox(() async { - final uri = _uri( - path: '/events/$eventPk/registrations/$registrationPk/fields/', - ); - final body = jsonEncode( - fields.map((key, field) => MapEntry(key, field.value)), - ); - await _handleExceptions( - () => _client.put(uri, body: body, headers: _jsonHeader), - ); - }); - } - - @override - Future getAdminEvent({required int pk}) { - return sandbox(() async { - final uri = _uri(path: '/admin/events/$pk/'); - final response = await _handleExceptions(() => _client.get(uri)); - return AdminEvent.fromJson(_jsonDecode(response)); - }); - } - - @override - Future> getAdminEventRegistrations({ - required int pk, - int? limit, - int? offset, - String? search, - String? ordering, - bool? cancelled, - bool? queued, - }) async { - assert( - ordering == null || - [ - 'date', - 'date_cancelled', - 'queue_position', - '-date', - '-date_cancelled', - '-queue_position', - ].contains(ordering), - 'Invalid ordering parameter: $ordering', - ); - return sandbox(() async { - final uri = _uri( - path: '/admin/events/$pk/registrations/', - query: { - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - if (ordering != null) 'ordering': ordering, - if (search != null) 'search': search, - if (cancelled != null) 'cancelled': cancelled.toString(), - if (queued != null) 'queued': queued.toString(), - }, - ); - final response = await _handleExceptions(() => _client.get(uri)); - return await compute(_parseAdminEventRegistrations, response); - }); - } - - static ListResponse _parseAdminEventRegistrations( - Response response, - ) { - return ListResponse.fromJson( - _jsonDecode(response), - (json) => AdminEventRegistration.fromJson(json as Map), - ); - } - - @override - Future markPresentAdminEventRegistration({ - required int eventPk, - required int registrationPk, - required bool present, - }) async { - return sandbox(() async { - final uri = _uri( - path: '/admin/events/$eventPk/registrations/$registrationPk/', - ); - final body = jsonEncode({'present': present}); - final response = await _handleExceptions( - () => _client.patch(uri, body: body, headers: _jsonHeader), - ); - return AdminEventRegistration.fromJson(_jsonDecode(response)); - }); - } - @override Future markPresentEventRegistration({ required int eventPk, @@ -492,41 +223,6 @@ class ConcrexitApiRepository implements ApiRepository { }); } - @override - Future markPaidAdminEventRegistration({ - required int registrationPk, - required PaymentType paymentType, - }) async { - assert(paymentType != PaymentType.tpayPayment); - return sandbox(() async { - final uri = _uri( - path: - '/admin/payments/payables/events/eventregistration/$registrationPk/', - ); - late String typeString; - switch (paymentType) { - case PaymentType.cardPayment: - typeString = 'card_payment'; - break; - case PaymentType.cashPayment: - typeString = 'cash_payment'; - break; - case PaymentType.wirePayment: - typeString = 'wire_payment'; - break; - case PaymentType.tpayPayment: - // This case should never occur. - typeString = 'tpay_payment'; - break; - } - final body = jsonEncode({'payment_type': typeString}); - final response = await _handleExceptions( - () => _client.patch(uri, body: body, headers: _jsonHeader), - ); - return Payable.fromJson(_jsonDecode(response)); - }); - } - @override Future markNotPaidAdminEventRegistration({ required int registrationPk, @@ -540,68 +236,6 @@ class ConcrexitApiRepository implements ApiRepository { }); } - @override - Future> getAdminFoodOrders({ - required int pk, - int? limit, - int? offset, - String? search, - }) async { - return sandbox(() async { - final uri = _uri( - path: '/admin/food/events/$pk/orders/', - query: { - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - if (search != null) 'search': search, - }, - ); - final response = await _handleExceptions(() => _client.get(uri)); - return await compute(_parseAdminFoodOrders, response); - }); - } - - static ListResponse _parseAdminFoodOrders(Response response) { - return ListResponse.fromJson( - _jsonDecode(response), - (json) => AdminFoodOrder.fromJson(json as Map), - ); - } - - @override - Future markPaidAdminFoodOrder({ - required int orderPk, - required PaymentType paymentType, - }) async { - assert(paymentType != PaymentType.tpayPayment); - return sandbox(() async { - final uri = _uri( - path: '/admin/payments/payables/pizzas/foodorder/$orderPk/', - ); - late String typeString; - switch (paymentType) { - case PaymentType.cardPayment: - typeString = 'card_payment'; - break; - case PaymentType.cashPayment: - typeString = 'cash_payment'; - break; - case PaymentType.wirePayment: - typeString = 'wire_payment'; - break; - case PaymentType.tpayPayment: - // This case should never occur. - typeString = 'tpay_payment'; - break; - } - final body = jsonEncode({'payment_type': typeString}); - final response = await _handleExceptions( - () => _client.patch(uri, body: body, headers: _jsonHeader), - ); - return Payable.fromJson(_jsonDecode(response)); - }); - } - @override Future markNotPaidAdminFoodOrder({ required int orderPk, @@ -614,125 +248,6 @@ class ConcrexitApiRepository implements ApiRepository { }); } - @override - Future getFoodEvent(int pk) async { - return sandbox(() async { - final uri = _uri(path: '/food/events/$pk/'); - final response = await _handleExceptions(() => _client.get(uri)); - final foodEvent = FoodEvent.fromJson(_jsonDecode(response)); - if (foodEvent.hasOrder) { - try { - await getFoodOrderPayable(foodOrderPk: foodEvent.order!.pk); - foodEvent.order!.tpayAllowed = true; - } on ApiException catch (exception) { - if (exception != ApiException.notAllowed) rethrow; - } - } - return foodEvent; - }); - } - - @override - Future> getFoodEvents({ - int? limit, - int? offset, - String? ordering, - DateTime? start, - DateTime? end, - }) async { - assert( - ordering == null || ['start', 'end', '-start', '-end'].contains(ordering), - 'Invalid ordering parameter: $ordering', - ); - return sandbox(() async { - final uri = _uri( - path: '/food/events/', - query: { - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - if (ordering != null) 'ordering': ordering, - if (start != null) 'start': start.toLocal().toIso8601String(), - if (end != null) 'end': end.toLocal().toIso8601String(), - }, - ); - - final response = await _handleExceptions(() => _client.get(uri)); - return await compute(_parseFoodEvents, response); - }); - } - - static ListResponse _parseFoodEvents(Response response) { - return ListResponse.fromJson( - _jsonDecode(response), - (json) => FoodEvent.fromJson(json as Map), - ); - } - - @override - Future getCurrentFoodEvent() async { - return sandbox(() async { - final now = DateTime.now().toLocal(); - final uri = _uri( - path: '/food/events/', - query: { - 'ordering': 'start', - 'start': now.subtract(const Duration(hours: 8)).toIso8601String(), - 'end': now.add(const Duration(hours: 8)).toIso8601String(), - }, - ); - final response = await _handleExceptions(() => _client.get(uri)); - final events = ListResponse.fromJson( - _jsonDecode(response), - (json) => FoodEvent.fromJson(json as Map), - ).results; - - if (events.isEmpty) { - throw ApiException.notFound; - } else if (events.length == 1) { - final foodEvent = events.first; - if (foodEvent.hasOrder) { - try { - await getFoodOrderPayable(foodOrderPk: foodEvent.order!.pk); - foodEvent.order!.tpayAllowed = true; - } on ApiException catch (exception) { - if (exception != ApiException.notAllowed) rethrow; - } - } - return foodEvent; - } else { - final foodEvent = events.firstWhere( - (event) => event.end.isAfter(now), - orElse: () => events.first, - ); - if (foodEvent.hasOrder) { - try { - await getFoodOrderPayable(foodOrderPk: foodEvent.order!.pk); - foodEvent.order!.tpayAllowed = true; - } on ApiException catch (exception) { - if (exception != ApiException.notAllowed) rethrow; - } - } - return foodEvent; - } - }); - } - - @override - Future getFoodOrder(int pk) async { - return sandbox(() async { - final uri = _uri(path: '/food/events/$pk/order/'); - final response = await _handleExceptions(() => _client.get(uri)); - final foodOrder = FoodOrder.fromJson(_jsonDecode(response)); - try { - await getFoodOrderPayable(foodOrderPk: foodOrder.pk); - foodOrder.tpayAllowed = true; - } on ApiException catch (exception) { - if (exception != ApiException.notAllowed) rethrow; - } - return foodOrder; - }); - } - @override Future cancelFoodOrder(int pk) async { return sandbox(() async { @@ -741,226 +256,6 @@ class ConcrexitApiRepository implements ApiRepository { }); } - @override - Future placeFoodOrder({ - required int eventPk, - required int productPk, - }) async { - return sandbox(() async { - final uri = _uri(path: '/food/events/$eventPk/order/'); - final body = jsonEncode({'product': productPk}); - final response = await _handleExceptions( - () => _client.post(uri, body: body, headers: _jsonHeader), - ); - final foodOrder = FoodOrder.fromJson(_jsonDecode(response)); - try { - await getFoodOrderPayable(foodOrderPk: foodOrder.pk); - foodOrder.tpayAllowed = true; - } on ApiException catch (exception) { - if (exception != ApiException.notAllowed) rethrow; - } - return foodOrder; - }); - } - - @override - Future changeFoodOrder({ - required int eventPk, - required int productPk, - }) async { - return sandbox(() async { - final uri = _uri(path: '/food/events/$eventPk/order/'); - final body = jsonEncode({'product': productPk}); - final response = await _handleExceptions( - () => _client.put(uri, body: body, headers: _jsonHeader), - ); - final foodOrder = FoodOrder.fromJson(_jsonDecode(response)); - try { - await getFoodOrderPayable(foodOrderPk: foodOrder.pk); - foodOrder.tpayAllowed = true; - } on ApiException catch (exception) { - if (exception != ApiException.notAllowed) rethrow; - } - return foodOrder; - }); - } - - @override - Future> getFoodEventProducts( - int pk, { - int? limit, - int? offset, - String? search, - }) async { - return sandbox(() async { - final uri = _uri( - path: '/food/events/$pk/products/', - query: { - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - }, - ); - - final response = await _handleExceptions(() => _client.get(uri)); - return await compute(_parseFoodEventProducts, response); - }); - } - - static ListResponse _parseFoodEventProducts(Response response) { - return ListResponse.fromJson( - _jsonDecode(response), - (json) => Product.fromJson(json as Map), - ); - } - - Future _getPayable({ - required String appLabel, - required String modelName, - required String payablePk, - }) async { - return sandbox(() async { - final uri = _uri( - path: '/payments/payables/$appLabel/$modelName/$payablePk/', - ); - - final response = await _handleExceptions(() => _client.get(uri)); - return Payable.fromJson(_jsonDecode(response)); - }); - } - - Future _makeThaliaPayPayment({ - required String appLabel, - required String modelName, - required String payablePk, - }) async { - return sandbox(() async { - final uri = _uri( - path: '/payments/payables/$appLabel/' - '$modelName/${Uri.encodeComponent(payablePk)}/', - ); - - final response = await _handleExceptions(() => _client.patch(uri)); - return Payable.fromJson(_jsonDecode(response)); - }); - } - - @override - Future getPaymentUser() async { - return sandbox(() async { - final uri = _uri(path: '/payments/users/me/'); - final response = await _handleExceptions(() => _client.get(uri)); - return PaymentUser.fromJson(_jsonDecode(response)); - }); - } - - @override - Future getFoodOrderPayable({required int foodOrderPk}) => - _getPayable( - appLabel: 'pizzas', - modelName: 'foodorder', - payablePk: foodOrderPk.toString(), - ); - - @override - Future thaliaPayFoodOrder({required int foodOrderPk}) => - _makeThaliaPayPayment( - appLabel: 'pizzas', - modelName: 'foodorder', - payablePk: foodOrderPk.toString(), - ); - - @override - Future getEventRegistrationPayable({required int registrationPk}) => - _getPayable( - appLabel: 'events', - modelName: 'eventregistration', - payablePk: registrationPk.toString(), - ); - - @override - Future thaliaPayRegistration({required int registrationPk}) => - _makeThaliaPayPayment( - appLabel: 'events', - modelName: 'eventregistration', - payablePk: registrationPk.toString(), - ); - - @override - Future getSalesOrderPayable({required String salesOrderPk}) => - _getPayable( - appLabel: 'sales', - modelName: 'order', - payablePk: salesOrderPk, - ); - - @override - Future thaliaPaySalesOrder({required String salesOrderPk}) => - _makeThaliaPayPayment( - appLabel: 'sales', - modelName: 'order', - payablePk: salesOrderPk, - ); - - @override - Future getMember({required int pk}) async { - return sandbox(() async { - final uri = _uri(path: '/members/$pk/'); - final response = await _handleExceptions(() => _client.get(uri)); - return Member.fromJson(_jsonDecode(response)); - }); - } - - @override - Future> getMembers({ - String? search, - int? limit, - int? offset, - String? ordering, - }) async { - assert( - ordering == null || - [ - 'last_name', - 'first_name', - 'username', - '-last_name', - '-first_name', - '-username' - ].contains(ordering), - 'Invalid ordering parameter: $ordering', - ); - return sandbox(() async { - final uri = _uri( - path: '/members/', - query: { - if (search != null) 'search': search, - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - if (ordering != null) 'ordering': ordering, - }, - ); - - final response = await _handleExceptions(() => _client.get(uri)); - return await compute(_parseMembers, response); - }); - } - - static ListResponse _parseMembers(Response response) { - return ListResponse.fromJson( - _jsonDecode(response), - (json) => ListMember.fromJson(json as Map), - ); - } - - @override - Future getMe() async { - return sandbox(() async { - final uri = _uri(path: '/members/me/'); - final response = await _handleExceptions(() => _client.get(uri)); - return FullMember.fromJson(_jsonDecode(response)); - }); - } - @override Future updateAvatar(String filePath) async { return sandbox(() async { @@ -1043,32 +338,6 @@ class ConcrexitApiRepository implements ApiRepository { ); } - @override - Future> getSlides({ - int? limit, - int? offset, - }) async { - return sandbox(() async { - final uri = _uri( - path: '/announcements/slides/', - query: { - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - }, - ); - - final response = await _handleExceptions(() => _client.get(uri)); - return await compute(_parseSlides, response); - }); - } - - static ListResponse _parseSlides(Response response) { - return ListResponse.fromJson( - _jsonDecode(response), - (json) => Slide.fromJson(json as Map), - ); - } - @override Future> getFrontpageArticles({ int? limit, @@ -1097,179 +366,6 @@ class ConcrexitApiRepository implements ApiRepository { ); } - @override - Future registerDevice({ - required String token, - required String type, - bool active = true, - }) async { - return sandbox(() async { - final uri = _uri(path: '/pushnotifications/devices/'); - final body = jsonEncode({ - 'registration_id': token, - 'active': active, - 'type': type, - }); - final response = await _handleExceptions( - () => _client.post(uri, body: body, headers: _jsonHeader), - ); - return Device.fromJson(_jsonDecode(response)); - }); - } - - @override - Future getDevice({required int pk}) async { - return sandbox(() async { - final uri = _uri(path: '/pushnotifications/devices/$pk/'); - final response = await _handleExceptions(() => _client.get(uri)); - return Device.fromJson(_jsonDecode(response)); - }); - } - - @override - Future disableDevice({required int pk}) async { - return sandbox(() async { - final uri = _uri(path: '/pushnotifications/devices/$pk/'); - final body = jsonEncode({'active': false}); - final response = await _handleExceptions( - () => _client.patch(uri, body: body, headers: _jsonHeader), - ); - return Device.fromJson(_jsonDecode(response)); - }); - } - - @override - Future updateDeviceToken({ - required int pk, - required String token, - }) async { - return sandbox(() async { - final uri = _uri(path: '/pushnotifications/devices/$pk/'); - final body = jsonEncode({'registration_id': token}); - final response = await _handleExceptions( - () => _client.patch(uri, body: body, headers: _jsonHeader), - ); - return Device.fromJson(_jsonDecode(response)); - }); - } - - @override - Future updateDeviceReceiveCategory({ - required int pk, - required List receiveCategory, - }) async { - return sandbox(() async { - final uri = _uri(path: '/pushnotifications/devices/$pk/'); - final body = jsonEncode({'receive_category': receiveCategory}); - final response = await _handleExceptions( - () => _client.patch(uri, body: body, headers: _jsonHeader), - ); - return Device.fromJson(_jsonDecode(response)); - }); - } - - @override - Future> getCategories() async { - return sandbox(() async { - final uri = _uri(path: '/pushnotifications/categories/'); - final response = await _handleExceptions(() => _client.get(uri)); - return await compute(_parseCategories, response); - }); - } - - static ListResponse _parseCategories( - Response response, - ) { - return ListResponse.fromJson( - _jsonDecode(response), - (json) => PushNotificationCategory.fromJson( - json as Map, - ), - ); - } - - @override - Future claimSalesOrder({required String pk}) async { - return sandbox(() async { - final uri = _uri(path: '/sales/order/$pk/claim/'); - final response = await _handleExceptions( - () => _client.patch(uri), - allowedStatusCodes: [200, 201, 204, 403], - ); - if (response.statusCode == 403) { - final String reason = _jsonDecode(response)['detail'] as String; - throw ApiException.message(reason); - } else { - final order = SalesOrder.fromJson(_jsonDecode(response)); - try { - await getSalesOrderPayable(salesOrderPk: pk); - order.tpayAllowed = true; - } on ApiException catch (exception) { - if (exception != ApiException.notAllowed) rethrow; - } - return order; - } - }); - } - - @override - Future> getGroups({ - int? limit, - int? offset, - MemberGroupType? type, - DateTime? start, - DateTime? end, - String? search, - }) async { - const memberGroupTypeMap = { - MemberGroupType.committee: 'committee', - MemberGroupType.society: 'society', - MemberGroupType.board: 'board', - }; - - final uri = _baseUri.replace( - path: '$_basePath/activemembers/groups/', - queryParameters: { - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - if (type != null) 'type': memberGroupTypeMap[type], - if (start != null) 'start': start.toIso8601String(), - if (end != null) 'end': end.toIso8601String(), - if (search != null) 'search': search - }, - ); - - final response = await _handleExceptions(() => _client.get(uri)); - return ListResponse.fromJson( - _jsonDecode(response), - (json) => ListGroup.fromJson(json as Map), - ); - } - - @override - Future getGroup({required int pk}) async { - final uri = _baseUri.replace(path: '$_basePath/activemembers/groups/$pk/'); - final response = await _handleExceptions(() => _client.get(uri)); - return Group.fromJson(_jsonDecode(response)); - } - - @override - Future getGroupBySlug( - {required MemberGroupType type, required String slug}) async { - // Only boards have slug support right now - assert(type == MemberGroupType.board); - - if (type == MemberGroupType.board) { - final uri = - _baseUri.replace(path: '$_basePath/activemembers/boards/$slug/'); - final response = await _handleExceptions(() => _client.get(uri)); - return Group.fromJson(_jsonDecode(response)); - } else { - throw ApiException.message( - 'Slugs are unsupported for groups of this type.'); - } - } - @override Future> getLikedPhotos({ int? limit, @@ -1289,38 +385,4 @@ class ConcrexitApiRepository implements ApiRepository { (json) => AlbumPhoto.fromJson(json as Map), ); } - - @override - Future> getPayments( - {int? limit, - int? offset, - String? ordering, - DateTime? start, - DateTime? end, - List? type, - bool? settled}) { - return sandbox(() async { - const paymentTypeMap = { - PaymentType.tpayPayment: 'tpay_payment', - }; - - final uri = _baseUri.replace( - path: '$_basePath/payments/', - queryParameters: { - if (limit != null) 'limit': limit.toString(), - if (offset != null) 'offset': offset.toString(), - if (type != null) - 'type': type.map((t) => paymentTypeMap[t]).join(','), - if (start != null) 'start': start.toIso8601String(), - if (end != null) 'end': end.toIso8601String(), - if (ordering != null) 'ordering': ordering, - if (settled != null) 'settled': settled.toString(), - }, - ); - - final response = await _handleExceptions(() => _client.get(uri)); - return ListResponse.fromJson(_jsonDecode(response), - (json) => Payment.fromJson(json as Map)); - }); - } } diff --git a/lib/blocs/auth_cubit.dart b/lib/blocs/auth_cubit.dart index e28408f06..9d543800f 100644 --- a/lib/blocs/auth_cubit.dart +++ b/lib/blocs/auth_cubit.dart @@ -281,7 +281,6 @@ class AuthCubit extends Cubit { Future logOut() async { final state = this.state; if (state is LoggedInAuthState) { - await _cleanUpPushNotifications(state.apiRepository); state.apiRepository.close(); } @@ -335,101 +334,9 @@ class AuthCubit extends Cubit { sound: true, ); - final token = await FirebaseMessaging.instance.getToken(); - final prefs = await SharedPreferences.getInstance(); - final devicePk = prefs.getInt(_devicePkPreferenceKey); - - if (devicePk == null) { - // There is no device in the backend yet. - try { - await _registerNewDevice(prefs: prefs, api: api, token: token); - } on ApiException { - return false; - } - } else { - // There already is a device in the backend. - try { - // Update the existing device. - final device = await api.updateDeviceToken( - pk: devicePk, - token: token!, - ); - - // Handle refreshing of tokens. - _fmTokenSubscription = - FirebaseMessaging.instance.onTokenRefresh.listen( - (token) => api.updateDeviceToken(pk: device.pk, token: token), - ); - } on ApiException catch (exception) { - if (exception == ApiException.notFound) { - // The device was deleted from the backend. - // Delete the device from the local storage. - prefs.remove(_devicePkPreferenceKey); - - try { - await _registerNewDevice(prefs: prefs, api: api, token: token); - } on ApiException { - return false; - } - } - } - } - return true; } catch (_) { return false; } } - - /// Register a new [Device] in the backend. May throw an [ApiException]. - Future _registerNewDevice({ - required SharedPreferences prefs, - required ApiRepository api, - required String? token, - }) async { - final device = await api.registerDevice( - type: Platform.isIOS ? 'ios' : 'android', - token: token!, - ); - - // Store the pk of the new device. - prefs.setInt(_devicePkPreferenceKey, device.pk); - - // Handle refreshing of tokens. - _fmTokenSubscription = FirebaseMessaging.instance.onTokenRefresh.listen( - (token) => api.updateDeviceToken(pk: device.pk, token: token), - ); - } - - /// Clean up the setup of push notifications. - /// - /// Removes the subscription that listens to token changes, disables - /// the current token, and inactivates the device in the backend. - /// - /// Returns whether the device on the backend was successfully disabled. - Future _cleanUpPushNotifications(ApiRepository api) async { - // Stop notifying the backend of token changes. - _fmTokenSubscription?.cancel(); - - // Disable the existing token. This makes sure that the backend can no - // longer send push notifications to this phone even if deleting the - // device from the backend fails. - FirebaseMessaging.instance.deleteToken(); - - // Delete the device from the backend. - final prefs = await SharedPreferences.getInstance(); - final devicePk = prefs.getInt(_devicePkPreferenceKey); - if (devicePk != null) { - // Remove the device pk from storage. - prefs.remove(_devicePkPreferenceKey); - - try { - await api.disableDevice(pk: devicePk); - } on ApiException { - return false; - } - } - - return true; - } } diff --git a/lib/models.dart b/lib/models.dart index 21bed2af9..1aea8b650 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -1,20 +1,4 @@ export 'models/album.dart'; -export 'models/device.dart'; -export 'models/document.dart'; -export 'models/event_registration.dart'; -export 'models/event.dart'; -export 'models/food_event.dart'; -export 'models/food_order.dart'; export 'models/frontpage_article.dart'; -export 'models/group.dart'; export 'models/list_response.dart'; -export 'models/member.dart'; -export 'models/payable.dart'; -export 'models/payment_user.dart'; -export 'models/payment.dart'; export 'models/photo.dart'; -export 'models/product.dart'; -export 'models/push_notification_category.dart'; -export 'models/registration_field.dart'; -export 'models/sales_order.dart'; -export 'models/slide.dart'; diff --git a/lib/models/device.dart b/lib/models/device.dart deleted file mode 100644 index 5f8ac9cd8..000000000 --- a/lib/models/device.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'device.g.dart'; - -/// Object used by the server to provide push notifications. -@JsonSerializable(fieldRename: FieldRename.snake) -class Device { - final int pk; - final bool active; - final String dateCreated; - final String type; - - /// A list of categories of notifications - /// that should be received on the device. - final List receiveCategory; - - /// A unique identifier for a device to which - /// the backend can send push notifications. - @JsonKey(name: 'registration_id') - final String token; - - factory Device.fromJson(Map json) => _$DeviceFromJson(json); - - Map toJson() => _$DeviceToJson(this); - - const Device(this.pk, this.token, this.active, this.dateCreated, this.type, - this.receiveCategory); - - Device copyWithReceiveCategory(List newReceiveCategory) => - Device(pk, token, active, dateCreated, type, newReceiveCategory); -} diff --git a/lib/models/device.g.dart b/lib/models/device.g.dart deleted file mode 100644 index ea1b7a5bf..000000000 --- a/lib/models/device.g.dart +++ /dev/null @@ -1,27 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'device.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Device _$DeviceFromJson(Map json) => Device( - json['pk'] as int, - json['registration_id'] as String, - json['active'] as bool, - json['date_created'] as String, - json['type'] as String, - (json['receive_category'] as List) - .map((e) => e as String) - .toList(), - ); - -Map _$DeviceToJson(Device instance) => { - 'pk': instance.pk, - 'active': instance.active, - 'date_created': instance.dateCreated, - 'type': instance.type, - 'receive_category': instance.receiveCategory, - 'registration_id': instance.token, - }; diff --git a/lib/models/document.dart b/lib/models/document.dart deleted file mode 100644 index aecfe6a74..000000000 --- a/lib/models/document.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'document.g.dart'; - -enum DocumentCategory { annual, association, event, minutes, misc } - -@JsonSerializable(fieldRename: FieldRename.snake, explicitToJson: true) -class Document { - final int pk; - final String name; - final String url; - final DocumentCategory category; - - Uri getURL() => Uri.parse(url); - - factory Document.fromJson(Map json) => - _$DocumentFromJson(json); - Map toJson() => _$DocumentToJson(this); - - const Document( - this.pk, - this.name, - this.url, - this.category, - ); -} diff --git a/lib/models/document.g.dart b/lib/models/document.g.dart deleted file mode 100644 index 883dd50fd..000000000 --- a/lib/models/document.g.dart +++ /dev/null @@ -1,29 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'document.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Document _$DocumentFromJson(Map json) => Document( - json['pk'] as int, - json['name'] as String, - json['url'] as String, - $enumDecode(_$DocumentCategoryEnumMap, json['category']), - ); - -Map _$DocumentToJson(Document instance) => { - 'pk': instance.pk, - 'name': instance.name, - 'url': instance.url, - 'category': _$DocumentCategoryEnumMap[instance.category]!, - }; - -const _$DocumentCategoryEnumMap = { - DocumentCategory.annual: 'annual', - DocumentCategory.association: 'association', - DocumentCategory.event: 'event', - DocumentCategory.minutes: 'minutes', - DocumentCategory.misc: 'misc', -}; diff --git a/lib/models/event.dart b/lib/models/event.dart deleted file mode 100644 index d99cb4946..000000000 --- a/lib/models/event.dart +++ /dev/null @@ -1,255 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'package:reaxit/models.dart'; - -part 'event.g.dart'; - -enum EventCategory { alumni, education, career, leisure, association, other } - -enum RegistrationStatus { - notRegistered, - registered, - inQueue, - cancelled, - lateCancelled -} - -abstract class BaseEvent { - abstract final int pk; - abstract final String title; - abstract final String caption; - abstract final DateTime start; - abstract final DateTime end; - abstract final String location; -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class Event implements BaseEvent { - @override - final int pk; - @override - final String title; - @override - final String caption; - @override - final DateTime start; - @override - final DateTime end; - @override - final String location; - - final String description; - - final String url; - - final List organisers; - - final EventCategory category; - - final bool hasFields; - - final bool optionalRegistrations; - - final DateTime? registrationStart; - final DateTime? registrationEnd; - final DateTime? cancelDeadline; - - final String price; - final String fine; - - final int numParticipants; - final int? maxParticipants; - - final String cancelTooLateMessage; - final String? noRegistrationMessage; - final int? foodEvent; - final String mapsUrl; - final EventPermissions userPermissions; - @JsonKey(name: 'user_registration') - final UserEventRegistration? registration; - - final List documents; - - bool get hasFoodEvent => foodEvent != null; - - bool get isRegistered => registration?.isRegistered ?? false; - bool get isInQueue => registration?.isInQueue ?? false; - bool get isInvited => registration?.isInvited ?? false; - - bool get registrationIsRequired => - registrationStart != null || registrationEnd != null; - - bool get registrationIsOptional => - optionalRegistrations && !registrationIsRequired; - - bool get paymentIsRequired => double.tryParse(price) != 0; - - bool get reachedMaxParticipants => - maxParticipants != null && numParticipants >= maxParticipants!; - - bool cancelDeadlinePassed() => - cancelDeadline?.isBefore(DateTime.now()) ?? false; - bool registrationStarted() => - registrationStart?.isBefore(DateTime.now()) ?? false; - bool registrationClosed() => - registrationEnd?.isBefore(DateTime.now()) ?? false; - bool registrationIsOpen() => registrationStarted() && !registrationClosed(); - - bool hasStarted() => start.isBefore(DateTime.now()); - bool hasEnded() => end.isBefore(DateTime.now()); - - bool get canCreateRegistration => userPermissions.createRegistration; - bool get canUpdateRegistration => userPermissions.updateRegistration; - bool get canCancelRegistration => userPermissions.cancelRegistration; - bool get canManageEvent => userPermissions.manageEvent; - - factory Event.fromJson(Map json) => _$EventFromJson(json); - - const Event( - this.pk, - this.title, - this.url, - this.caption, - this.description, - this.start, - this.end, - this.category, - this.registrationStart, - this.registrationEnd, - this.cancelDeadline, - this.location, - this.price, - this.fine, - this.numParticipants, - this.maxParticipants, - this.noRegistrationMessage, - this.hasFields, - this.foodEvent, - this.mapsUrl, - this.userPermissions, - this.registration, - this.organisers, - this.cancelTooLateMessage, - this.optionalRegistrations, - this.documents, - ); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class EventPermissions { - final bool createRegistration; - final bool cancelRegistration; - final bool updateRegistration; - final bool manageEvent; - - const EventPermissions( - this.createRegistration, - this.cancelRegistration, - this.updateRegistration, - this.manageEvent, - ); - - factory EventPermissions.fromJson(Map json) => - _$EventPermissionsFromJson(json); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class PartnerEvent implements BaseEvent { - @override - final int pk; - @override - final String title; - @override - @JsonKey(name: 'description') - final String caption; - @override - final DateTime start; - @override - final DateTime end; - @override - final String location; - - final Uri url; - - factory PartnerEvent.fromJson(Map json) => - _$PartnerEventFromJson(json); - - const PartnerEvent( - this.pk, - this.title, - this.caption, - this.start, - this.end, - this.location, - this.url, - ); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class AdminEvent implements BaseEvent { - @override - @JsonKey(name: 'id') - final int pk; - @override - final String title; - @override - final String caption; - @override - final DateTime start; - @override - final DateTime end; - @override - final String location; - - final String description; - final EventCategory category; - final bool optionalRegistrations; - final DateTime? registrationStart; - final DateTime? registrationEnd; - final DateTime? cancelDeadline; - - final String price; - final String fine; - - // final Uri markPresentUrl; - final String markPresentUrlToken; - - bool get registrationIsRequired => - registrationStart != null || registrationEnd != null; - - bool get registrationIsOptional => - optionalRegistrations && !registrationIsRequired; - - bool get paymentIsRequired => double.tryParse(price) != 0; - - bool cancelDeadlinePassed() => - cancelDeadline?.isBefore(DateTime.now()) ?? false; - bool registrationStarted() => - registrationStart?.isBefore(DateTime.now()) ?? false; - bool registrationClosed() => - registrationEnd?.isBefore(DateTime.now()) ?? false; - bool registrationIsOpen() => registrationStarted() && !registrationClosed(); - - bool hasStarted() => start.isBefore(DateTime.now()); - bool hasEnded() => end.isBefore(DateTime.now()); - - factory AdminEvent.fromJson(Map json) => - _$AdminEventFromJson(json); - - AdminEvent( - this.pk, - this.title, - this.caption, - this.start, - this.end, - this.location, - this.description, - this.category, - this.optionalRegistrations, - this.registrationStart, - this.registrationEnd, - this.cancelDeadline, - this.price, - this.fine, - this.markPresentUrlToken, - ); -} diff --git a/lib/models/event.g.dart b/lib/models/event.g.dart deleted file mode 100644 index 74664f0ef..000000000 --- a/lib/models/event.g.dart +++ /dev/null @@ -1,168 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'event.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Event _$EventFromJson(Map json) => Event( - json['pk'] as int, - json['title'] as String, - json['url'] as String, - json['caption'] as String, - json['description'] as String, - DateTime.parse(json['start'] as String), - DateTime.parse(json['end'] as String), - $enumDecode(_$EventCategoryEnumMap, json['category']), - json['registration_start'] == null - ? null - : DateTime.parse(json['registration_start'] as String), - json['registration_end'] == null - ? null - : DateTime.parse(json['registration_end'] as String), - json['cancel_deadline'] == null - ? null - : DateTime.parse(json['cancel_deadline'] as String), - json['location'] as String, - json['price'] as String, - json['fine'] as String, - json['num_participants'] as int, - json['max_participants'] as int?, - json['no_registration_message'] as String?, - json['has_fields'] as bool, - json['food_event'] as int?, - json['maps_url'] as String, - EventPermissions.fromJson( - json['user_permissions'] as Map), - json['user_registration'] == null - ? null - : UserEventRegistration.fromJson( - json['user_registration'] as Map), - (json['organisers'] as List) - .map((e) => SmallGroup.fromJson(e as Map)) - .toList(), - json['cancel_too_late_message'] as String, - json['optional_registrations'] as bool, - (json['documents'] as List) - .map((e) => Document.fromJson(e as Map)) - .toList(), - ); - -Map _$EventToJson(Event instance) => { - 'pk': instance.pk, - 'title': instance.title, - 'caption': instance.caption, - 'start': instance.start.toIso8601String(), - 'end': instance.end.toIso8601String(), - 'location': instance.location, - 'description': instance.description, - 'url': instance.url, - 'organisers': instance.organisers, - 'category': _$EventCategoryEnumMap[instance.category]!, - 'has_fields': instance.hasFields, - 'optional_registrations': instance.optionalRegistrations, - 'registration_start': instance.registrationStart?.toIso8601String(), - 'registration_end': instance.registrationEnd?.toIso8601String(), - 'cancel_deadline': instance.cancelDeadline?.toIso8601String(), - 'price': instance.price, - 'fine': instance.fine, - 'num_participants': instance.numParticipants, - 'max_participants': instance.maxParticipants, - 'cancel_too_late_message': instance.cancelTooLateMessage, - 'no_registration_message': instance.noRegistrationMessage, - 'food_event': instance.foodEvent, - 'maps_url': instance.mapsUrl, - 'user_permissions': instance.userPermissions, - 'user_registration': instance.registration, - 'documents': instance.documents, - }; - -const _$EventCategoryEnumMap = { - EventCategory.alumni: 'alumni', - EventCategory.education: 'education', - EventCategory.career: 'career', - EventCategory.leisure: 'leisure', - EventCategory.association: 'association', - EventCategory.other: 'other', -}; - -EventPermissions _$EventPermissionsFromJson(Map json) => - EventPermissions( - json['create_registration'] as bool, - json['cancel_registration'] as bool, - json['update_registration'] as bool, - json['manage_event'] as bool, - ); - -Map _$EventPermissionsToJson(EventPermissions instance) => - { - 'create_registration': instance.createRegistration, - 'cancel_registration': instance.cancelRegistration, - 'update_registration': instance.updateRegistration, - 'manage_event': instance.manageEvent, - }; - -PartnerEvent _$PartnerEventFromJson(Map json) => PartnerEvent( - json['pk'] as int, - json['title'] as String, - json['description'] as String, - DateTime.parse(json['start'] as String), - DateTime.parse(json['end'] as String), - json['location'] as String, - Uri.parse(json['url'] as String), - ); - -Map _$PartnerEventToJson(PartnerEvent instance) => - { - 'pk': instance.pk, - 'title': instance.title, - 'description': instance.caption, - 'start': instance.start.toIso8601String(), - 'end': instance.end.toIso8601String(), - 'location': instance.location, - 'url': instance.url.toString(), - }; - -AdminEvent _$AdminEventFromJson(Map json) => AdminEvent( - json['id'] as int, - json['title'] as String, - json['caption'] as String, - DateTime.parse(json['start'] as String), - DateTime.parse(json['end'] as String), - json['location'] as String, - json['description'] as String, - $enumDecode(_$EventCategoryEnumMap, json['category']), - json['optional_registrations'] as bool, - json['registration_start'] == null - ? null - : DateTime.parse(json['registration_start'] as String), - json['registration_end'] == null - ? null - : DateTime.parse(json['registration_end'] as String), - json['cancel_deadline'] == null - ? null - : DateTime.parse(json['cancel_deadline'] as String), - json['price'] as String, - json['fine'] as String, - json['mark_present_url_token'] as String, - ); - -Map _$AdminEventToJson(AdminEvent instance) => - { - 'id': instance.pk, - 'title': instance.title, - 'caption': instance.caption, - 'start': instance.start.toIso8601String(), - 'end': instance.end.toIso8601String(), - 'location': instance.location, - 'description': instance.description, - 'category': _$EventCategoryEnumMap[instance.category]!, - 'optional_registrations': instance.optionalRegistrations, - 'registration_start': instance.registrationStart?.toIso8601String(), - 'registration_end': instance.registrationEnd?.toIso8601String(), - 'cancel_deadline': instance.cancelDeadline?.toIso8601String(), - 'price': instance.price, - 'fine': instance.fine, - 'mark_present_url_token': instance.markPresentUrlToken, - }; diff --git a/lib/models/event_registration.dart b/lib/models/event_registration.dart deleted file mode 100644 index 31579d4bb..000000000 --- a/lib/models/event_registration.dart +++ /dev/null @@ -1,126 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'package:reaxit/models.dart'; - -part 'event_registration.g.dart'; - -@JsonSerializable(fieldRename: FieldRename.snake) -class EventRegistration { - final int pk; - final ListMember? member; - final String? name; - - factory EventRegistration.fromJson(Map json) => - _$EventRegistrationFromJson(json); - - const EventRegistration(this.pk, this.member, this.name) - : assert( - member != null || name != null, - 'Either a member or name must be given. $member, $name', - ); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class UserEventRegistration { - final int pk; - final bool? present; - final int? queuePosition; - final DateTime date; - final Payment? payment; - - final bool isCancelled; - - @JsonKey(defaultValue: false) - final bool isLateCancellation; - - bool get isRegistered => !isCancelled; - bool get isInQueue => !isCancelled && queuePosition != null; - bool get isInvited => !isCancelled && queuePosition == null; - - bool get isPaid => payment != null; - - @JsonKey(includeFromJson: false) - bool? _tpayAllowed; - - /// Whether this registration can be paid with Thalia Pay. - /// See https://github.com/svthalia/concrexit/issues/1784. - /// - /// Warning: this is only properly set on registrations - /// retrieved through [ApiRepository.getEvent]. - @JsonKey(includeFromJson: false) - bool get tpayAllowed => _tpayAllowed ?? false; - set tpayAllowed(bool value) => _tpayAllowed = value; - - factory UserEventRegistration.fromJson(Map json) => - _$UserEventRegistrationFromJson(json); - - UserEventRegistration( - this.pk, - this.present, - this.queuePosition, - this.date, - this.payment, - this.isCancelled, - this.isLateCancellation, - ); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class AdminEventRegistration implements EventRegistration { - @override - final int pk; - @override - final AdminListMember? member; - @override - final String? name; - - final bool present; - final int? queuePosition; - final DateTime date; - final DateTime? dateCancelled; - final Payment? payment; - - bool get isInQueue => queuePosition != null; - bool get isInvited => queuePosition == null; - bool get isPaid => payment != null; - - AdminEventRegistration( - this.pk, - this.member, - this.name, - this.present, - this.queuePosition, - this.date, - this.dateCancelled, - this.payment, - ) : assert( - member != null || name != null, - 'Either a member or name must be given.', - ); - - AdminEventRegistration copyWithPresent(bool newPresent) => - AdminEventRegistration( - pk, - member, - name, - newPresent, - queuePosition, - date, - dateCancelled, - payment, - ); - - AdminEventRegistration copyWithPayment(Payment? newPayment) => - AdminEventRegistration( - pk, - member, - name, - present, - queuePosition, - date, - dateCancelled, - newPayment, - ); - - factory AdminEventRegistration.fromJson(Map json) => - _$AdminEventRegistrationFromJson(json); -} diff --git a/lib/models/event_registration.g.dart b/lib/models/event_registration.g.dart deleted file mode 100644 index 65ff8cb8a..000000000 --- a/lib/models/event_registration.g.dart +++ /dev/null @@ -1,81 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'event_registration.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -EventRegistration _$EventRegistrationFromJson(Map json) => - EventRegistration( - json['pk'] as int, - json['member'] == null - ? null - : ListMember.fromJson(json['member'] as Map), - json['name'] as String?, - ); - -Map _$EventRegistrationToJson(EventRegistration instance) => - { - 'pk': instance.pk, - 'member': instance.member, - 'name': instance.name, - }; - -UserEventRegistration _$UserEventRegistrationFromJson( - Map json) => - UserEventRegistration( - json['pk'] as int, - json['present'] as bool?, - json['queue_position'] as int?, - DateTime.parse(json['date'] as String), - json['payment'] == null - ? null - : Payment.fromJson(json['payment'] as Map), - json['is_cancelled'] as bool, - json['is_late_cancellation'] as bool? ?? false, - ); - -Map _$UserEventRegistrationToJson( - UserEventRegistration instance) => - { - 'pk': instance.pk, - 'present': instance.present, - 'queue_position': instance.queuePosition, - 'date': instance.date.toIso8601String(), - 'payment': instance.payment, - 'is_cancelled': instance.isCancelled, - 'is_late_cancellation': instance.isLateCancellation, - }; - -AdminEventRegistration _$AdminEventRegistrationFromJson( - Map json) => - AdminEventRegistration( - json['pk'] as int, - json['member'] == null - ? null - : AdminListMember.fromJson(json['member'] as Map), - json['name'] as String?, - json['present'] as bool, - json['queue_position'] as int?, - DateTime.parse(json['date'] as String), - json['date_cancelled'] == null - ? null - : DateTime.parse(json['date_cancelled'] as String), - json['payment'] == null - ? null - : Payment.fromJson(json['payment'] as Map), - ); - -Map _$AdminEventRegistrationToJson( - AdminEventRegistration instance) => - { - 'pk': instance.pk, - 'member': instance.member, - 'name': instance.name, - 'present': instance.present, - 'queue_position': instance.queuePosition, - 'date': instance.date.toIso8601String(), - 'date_cancelled': instance.dateCancelled?.toIso8601String(), - 'payment': instance.payment, - }; diff --git a/lib/models/food_event.dart b/lib/models/food_event.dart deleted file mode 100644 index ad53440e0..000000000 --- a/lib/models/food_event.dart +++ /dev/null @@ -1,39 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'package:reaxit/models.dart'; - -part 'food_event.g.dart'; - -@JsonSerializable(fieldRename: FieldRename.snake) -class FoodEvent { - final int pk; - final String title; - final Event event; - final DateTime start; - final DateTime end; - final bool canManage; - final FoodOrder? order; - - bool get hasOrder => order != null; - - bool hasEnded() => DateTime.now().isAfter(end); - bool hasStarted() => DateTime.now().isAfter(start); - - bool canOrder() => hasStarted() && !hasEnded(); - bool canChangeOrder() => - hasOrder && - canOrder() && - (!order!.isPaid || order!.payment!.type == PaymentType.tpayPayment); - - factory FoodEvent.fromJson(Map json) => - _$FoodEventFromJson(json); - - const FoodEvent( - this.pk, - this.event, - this.start, - this.end, - this.canManage, - this.order, - this.title, - ); -} diff --git a/lib/models/food_event.g.dart b/lib/models/food_event.g.dart deleted file mode 100644 index 13cd9ec66..000000000 --- a/lib/models/food_event.g.dart +++ /dev/null @@ -1,29 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'food_event.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -FoodEvent _$FoodEventFromJson(Map json) => FoodEvent( - json['pk'] as int, - Event.fromJson(json['event'] as Map), - DateTime.parse(json['start'] as String), - DateTime.parse(json['end'] as String), - json['can_manage'] as bool, - json['order'] == null - ? null - : FoodOrder.fromJson(json['order'] as Map), - json['title'] as String, - ); - -Map _$FoodEventToJson(FoodEvent instance) => { - 'pk': instance.pk, - 'title': instance.title, - 'event': instance.event, - 'start': instance.start.toIso8601String(), - 'end': instance.end.toIso8601String(), - 'can_manage': instance.canManage, - 'order': instance.order, - }; diff --git a/lib/models/food_order.dart b/lib/models/food_order.dart deleted file mode 100644 index 6ac82414e..000000000 --- a/lib/models/food_order.dart +++ /dev/null @@ -1,95 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'package:reaxit/models.dart'; - -part 'food_order.g.dart'; - -@JsonSerializable(fieldRename: FieldRename.snake) -class FoodOrder { - final int pk; - final ListMember? member; - final String? name; - final Product product; - final Payment? payment; - - @JsonKey(includeFromJson: false) - bool? _tpayAllowed; - - /// Whether this order can be paid with Thalia Pay. - /// See https://github.com/svthalia/concrexit/issues/1784. - /// - /// Warning: this is not properly set on orders retrieved - /// through [ApiRepository.getFoodEvents]. - @JsonKey(includeFromJson: false) - bool get tpayAllowed => _tpayAllowed ?? false; - set tpayAllowed(bool value) => _tpayAllowed = value; - - bool get isPaid => payment != null; - - factory FoodOrder.fromJson(Map json) => - _$FoodOrderFromJson(json); - - FoodOrder( - this.pk, - this.member, - this.name, - this.product, - this.payment, - ) : assert( - member != null || name != null, - 'Either a member or name must be given. $member, $name', - ); - - FoodOrder copyWithPayment(Payment? newPayment) => - FoodOrder(pk, member, name, product, newPayment); -} - -/// Copy of [FoodOrder] where `member` is a [AdminListMember]. -@JsonSerializable(fieldRename: FieldRename.snake) -class AdminFoodOrder implements FoodOrder { - @override - final int pk; - @override - final AdminListMember? member; - @override - final String? name; - @override - final Product product; - @override - final Payment? payment; - - @override - @JsonKey(includeFromJson: false) - bool? _tpayAllowed; - - /// Whether this order can be paid with Thalia Pay. - /// See https://github.com/svthalia/concrexit/issues/1784. - /// - /// Warning: this is not properly set on orders retrieved - /// through [ApiRepository.getFoodEvents]. - @override - @JsonKey(includeFromJson: false) - bool get tpayAllowed => _tpayAllowed ?? false; - @override - set tpayAllowed(bool value) => _tpayAllowed = value; - - @override - bool get isPaid => payment != null; - - factory AdminFoodOrder.fromJson(Map json) => - _$AdminFoodOrderFromJson(json); - - AdminFoodOrder( - this.pk, - this.member, - this.name, - this.product, - this.payment, - ) : assert( - member != null || name != null, - 'Either a member or name must be given. $member, $name', - ); - - @override - AdminFoodOrder copyWithPayment(Payment? newPayment) => - AdminFoodOrder(pk, member, name, product, newPayment); -} diff --git a/lib/models/food_order.g.dart b/lib/models/food_order.g.dart deleted file mode 100644 index 2d52a0c69..000000000 --- a/lib/models/food_order.g.dart +++ /dev/null @@ -1,49 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'food_order.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -FoodOrder _$FoodOrderFromJson(Map json) => FoodOrder( - json['pk'] as int, - json['member'] == null - ? null - : ListMember.fromJson(json['member'] as Map), - json['name'] as String?, - Product.fromJson(json['product'] as Map), - json['payment'] == null - ? null - : Payment.fromJson(json['payment'] as Map), - ); - -Map _$FoodOrderToJson(FoodOrder instance) => { - 'pk': instance.pk, - 'member': instance.member, - 'name': instance.name, - 'product': instance.product, - 'payment': instance.payment, - }; - -AdminFoodOrder _$AdminFoodOrderFromJson(Map json) => - AdminFoodOrder( - json['pk'] as int, - json['member'] == null - ? null - : AdminListMember.fromJson(json['member'] as Map), - json['name'] as String?, - Product.fromJson(json['product'] as Map), - json['payment'] == null - ? null - : Payment.fromJson(json['payment'] as Map), - ); - -Map _$AdminFoodOrderToJson(AdminFoodOrder instance) => - { - 'pk': instance.pk, - 'member': instance.member, - 'name': instance.name, - 'product': instance.product, - 'payment': instance.payment, - }; diff --git a/lib/models/group.dart b/lib/models/group.dart deleted file mode 100644 index 87b330564..000000000 --- a/lib/models/group.dart +++ /dev/null @@ -1,88 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'package:reaxit/models.dart'; - -part 'group.g.dart'; - -enum MemberGroupType { committee, society, board } - -@JsonSerializable(fieldRename: FieldRename.snake, explicitToJson: true) -class SmallGroup { - final int pk; - final String name; - final MemberGroupType type; - final DateTime? since; - final DateTime? until; - final String contactAddress; - - const SmallGroup( - this.pk, - this.name, - this.type, - this.since, - this.until, - this.contactAddress, - ); - - factory SmallGroup.fromJson(Map json) => - _$SmallGroupFromJson(json); - Map toJson() => _$SmallGroupToJson(this); -} - -@JsonSerializable(fieldRename: FieldRename.snake, explicitToJson: true) -class ListGroup extends SmallGroup { - final String description; - final Photo photo; - - bool isActiveBoard() => - type == MemberGroupType.board && - (since?.isBefore(DateTime.now()) ?? false) && - !(until?.isBefore(DateTime.now()) ?? false); - - const ListGroup( - super.pk, - super.name, - super.type, - super.since, - super.until, - super.contactAddress, - this.description, - this.photo, - ); - - factory ListGroup.fromJson(Map json) => - _$ListGroupFromJson(json); - @override - Map toJson() => _$ListGroupToJson(this); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class Group extends ListGroup { - final List members; - - const Group( - int pk, - String name, - MemberGroupType type, - String description, - DateTime? since, - DateTime? until, - String contactAddress, - Photo photo, - this.members, - ) : super(pk, name, type, since, until, contactAddress, description, photo); - - factory Group.fromJson(Map json) => _$GroupFromJson(json); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class GroupMembership { - final ListMember member; - final bool chair; - final DateTime since; - final DateTime? until; - final String? role; - const GroupMembership( - this.member, this.chair, this.since, this.until, this.role); - factory GroupMembership.fromJson(Map json) => - _$GroupMembershipFromJson(json); -} diff --git a/lib/models/group.g.dart b/lib/models/group.g.dart deleted file mode 100644 index 587d1a3b4..000000000 --- a/lib/models/group.g.dart +++ /dev/null @@ -1,98 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'group.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -SmallGroup _$SmallGroupFromJson(Map json) => SmallGroup( - json['pk'] as int, - json['name'] as String, - $enumDecode(_$MemberGroupTypeEnumMap, json['type']), - json['since'] == null ? null : DateTime.parse(json['since'] as String), - json['until'] == null ? null : DateTime.parse(json['until'] as String), - json['contact_address'] as String, - ); - -Map _$SmallGroupToJson(SmallGroup instance) => - { - 'pk': instance.pk, - 'name': instance.name, - 'type': _$MemberGroupTypeEnumMap[instance.type]!, - 'since': instance.since?.toIso8601String(), - 'until': instance.until?.toIso8601String(), - 'contact_address': instance.contactAddress, - }; - -const _$MemberGroupTypeEnumMap = { - MemberGroupType.committee: 'committee', - MemberGroupType.society: 'society', - MemberGroupType.board: 'board', -}; - -ListGroup _$ListGroupFromJson(Map json) => ListGroup( - json['pk'] as int, - json['name'] as String, - $enumDecode(_$MemberGroupTypeEnumMap, json['type']), - json['since'] == null ? null : DateTime.parse(json['since'] as String), - json['until'] == null ? null : DateTime.parse(json['until'] as String), - json['contact_address'] as String, - json['description'] as String, - Photo.fromJson(json['photo'] as Map), - ); - -Map _$ListGroupToJson(ListGroup instance) => { - 'pk': instance.pk, - 'name': instance.name, - 'type': _$MemberGroupTypeEnumMap[instance.type]!, - 'since': instance.since?.toIso8601String(), - 'until': instance.until?.toIso8601String(), - 'contact_address': instance.contactAddress, - 'description': instance.description, - 'photo': instance.photo.toJson(), - }; - -Group _$GroupFromJson(Map json) => Group( - json['pk'] as int, - json['name'] as String, - $enumDecode(_$MemberGroupTypeEnumMap, json['type']), - json['description'] as String, - json['since'] == null ? null : DateTime.parse(json['since'] as String), - json['until'] == null ? null : DateTime.parse(json['until'] as String), - json['contact_address'] as String, - Photo.fromJson(json['photo'] as Map), - (json['members'] as List) - .map((e) => GroupMembership.fromJson(e as Map)) - .toList(), - ); - -Map _$GroupToJson(Group instance) => { - 'pk': instance.pk, - 'name': instance.name, - 'type': _$MemberGroupTypeEnumMap[instance.type]!, - 'since': instance.since?.toIso8601String(), - 'until': instance.until?.toIso8601String(), - 'contact_address': instance.contactAddress, - 'description': instance.description, - 'photo': instance.photo, - 'members': instance.members, - }; - -GroupMembership _$GroupMembershipFromJson(Map json) => - GroupMembership( - ListMember.fromJson(json['member'] as Map), - json['chair'] as bool, - DateTime.parse(json['since'] as String), - json['until'] == null ? null : DateTime.parse(json['until'] as String), - json['role'] as String?, - ); - -Map _$GroupMembershipToJson(GroupMembership instance) => - { - 'member': instance.member, - 'chair': instance.chair, - 'since': instance.since.toIso8601String(), - 'until': instance.until?.toIso8601String(), - 'role': instance.role, - }; diff --git a/lib/models/member.dart b/lib/models/member.dart deleted file mode 100644 index f7657f876..000000000 --- a/lib/models/member.dart +++ /dev/null @@ -1,207 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'package:reaxit/models.dart'; - -part 'member.g.dart'; - -enum Programme { computingscience, informationscience } - -enum MembershipType { member, benefactor, honorary } - -enum DisplayNamePreference { - full, - nickname, - firstname, - initials, - fullnick, - nicklast -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class ListMember { - final int pk; - final MembershipType? membershipType; - final Profile profile; - - String get displayName => profile.displayName; - String get shortDisplayName => profile.shortDisplayName; - DateTime? get birthday => profile.birthday; - Photo get photo => profile.photo; - Programme? get programme => profile.programme; - int? get startingYear => profile.startingYear; - Uri? get website => profile.website; - String? get profileDescription => profile.profileDescription; - - const ListMember( - this.pk, - this.membershipType, - this.profile, - ); - - factory ListMember.fromJson(Map json) => - _$ListMemberFromJson(json); - - Map toJson() => _$ListMemberToJson(this); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class AdminListMember extends ListMember { - final String firstName; - final String lastName; - - String get fullName => '$firstName $lastName'; - - const AdminListMember( - super.pk, - super.membershipType, - super.profile, - this.firstName, - this.lastName, - ); - - factory AdminListMember.fromJson(Map json) => - _$AdminListMemberFromJson(json); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class Member extends ListMember { - final List achievements; - final List societies; - - const Member( - super.pk, - super.membershipType, - super.profile, - this.achievements, - this.societies, - ); - - factory Member.fromJson(Map json) => _$MemberFromJson(json); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class FullMember extends Member { - @override - // ignore: overridden_fields - final FullProfile profile; - - const FullMember( - int pk, - MembershipType? membershipType, - this.profile, - List achievements, - List societies, - ) : super( - pk, - membershipType, - profile, - achievements, - societies, - ); - - factory FullMember.fromJson(Map json) => - _$FullMemberFromJson(json); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class Profile { - final String displayName; - final String shortDisplayName; - final DateTime? birthday; - final Photo photo; - final Programme? programme; - final int? startingYear; - @JsonKey(fromJson: _nonEmptyUriFromJson) - final Uri? website; - final String? profileDescription; - - const Profile( - this.displayName, - this.shortDisplayName, - this.birthday, - this.photo, - this.programme, - this.startingYear, - this.website, - this.profileDescription, - ); - - factory Profile.fromJson(Map json) => - _$ProfileFromJson(json); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class FullProfile extends Profile { - final String? addressStreet; - final String? addressStreet2; - final String? addressPostalCode; - final String? addressCity; - final String? addressCountry; - final String? phoneNumber; - final String? emergencyContact; - final String? emergencyContactPhoneNumber; - - final bool showBirthday; - - final String? initials; - final String? nickname; - final DisplayNamePreference displayNamePreference; - - const FullProfile( - super.displayName, - super.shortDisplayName, - super.birthday, - super.photo, - super.programme, - super.startingYear, - super.website, - super.profileDescription, - this.addressStreet, - this.addressStreet2, - this.addressPostalCode, - this.addressCity, - this.addressCountry, - this.phoneNumber, - this.emergencyContact, - this.emergencyContactPhoneNumber, - this.showBirthday, - this.initials, - this.nickname, - this.displayNamePreference, - ); - - factory FullProfile.fromJson(Map json) => - _$FullProfileFromJson(json); -} - -@JsonSerializable() -class Period { - final DateTime since; - final DateTime? until; - final bool chair; - final String? role; - const Period(this.since, this.until, this.chair, this.role); - factory Period.fromJson(Map json) => _$PeriodFromJson(json); -} - -@JsonSerializable() -class Achievement { - final String name; - final DateTime earliest; - - final bool? active; - final DateTime? latest; - final List? periods; - - final int? pk; - final Uri? url; - - const Achievement(this.name, this.periods, this.pk, this.active, this.url, - this.earliest, this.latest); - factory Achievement.fromJson(Map json) => - _$AchievementFromJson(json); -} - -Uri? _nonEmptyUriFromJson(String? json) { - if (json == null || json.isEmpty) return null; - return Uri.tryParse(json); -} diff --git a/lib/models/member.g.dart b/lib/models/member.g.dart deleted file mode 100644 index d9a0ba912..000000000 --- a/lib/models/member.g.dart +++ /dev/null @@ -1,211 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'member.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -ListMember _$ListMemberFromJson(Map json) => ListMember( - json['pk'] as int, - $enumDecodeNullable(_$MembershipTypeEnumMap, json['membership_type']), - Profile.fromJson(json['profile'] as Map), - ); - -Map _$ListMemberToJson(ListMember instance) => - { - 'pk': instance.pk, - 'membership_type': _$MembershipTypeEnumMap[instance.membershipType], - 'profile': instance.profile, - }; - -const _$MembershipTypeEnumMap = { - MembershipType.member: 'member', - MembershipType.benefactor: 'benefactor', - MembershipType.honorary: 'honorary', -}; - -AdminListMember _$AdminListMemberFromJson(Map json) => - AdminListMember( - json['pk'] as int, - $enumDecodeNullable(_$MembershipTypeEnumMap, json['membership_type']), - Profile.fromJson(json['profile'] as Map), - json['first_name'] as String, - json['last_name'] as String, - ); - -Map _$AdminListMemberToJson(AdminListMember instance) => - { - 'pk': instance.pk, - 'membership_type': _$MembershipTypeEnumMap[instance.membershipType], - 'profile': instance.profile, - 'first_name': instance.firstName, - 'last_name': instance.lastName, - }; - -Member _$MemberFromJson(Map json) => Member( - json['pk'] as int, - $enumDecodeNullable(_$MembershipTypeEnumMap, json['membership_type']), - Profile.fromJson(json['profile'] as Map), - (json['achievements'] as List) - .map((e) => Achievement.fromJson(e as Map)) - .toList(), - (json['societies'] as List) - .map((e) => Achievement.fromJson(e as Map)) - .toList(), - ); - -Map _$MemberToJson(Member instance) => { - 'pk': instance.pk, - 'membership_type': _$MembershipTypeEnumMap[instance.membershipType], - 'profile': instance.profile, - 'achievements': instance.achievements, - 'societies': instance.societies, - }; - -FullMember _$FullMemberFromJson(Map json) => FullMember( - json['pk'] as int, - $enumDecodeNullable(_$MembershipTypeEnumMap, json['membership_type']), - FullProfile.fromJson(json['profile'] as Map), - (json['achievements'] as List) - .map((e) => Achievement.fromJson(e as Map)) - .toList(), - (json['societies'] as List) - .map((e) => Achievement.fromJson(e as Map)) - .toList(), - ); - -Map _$FullMemberToJson(FullMember instance) => - { - 'pk': instance.pk, - 'membership_type': _$MembershipTypeEnumMap[instance.membershipType], - 'achievements': instance.achievements, - 'societies': instance.societies, - 'profile': instance.profile, - }; - -Profile _$ProfileFromJson(Map json) => Profile( - json['display_name'] as String, - json['short_display_name'] as String, - json['birthday'] == null - ? null - : DateTime.parse(json['birthday'] as String), - Photo.fromJson(json['photo'] as Map), - $enumDecodeNullable(_$ProgrammeEnumMap, json['programme']), - json['starting_year'] as int?, - _nonEmptyUriFromJson(json['website'] as String?), - json['profile_description'] as String?, - ); - -Map _$ProfileToJson(Profile instance) => { - 'display_name': instance.displayName, - 'short_display_name': instance.shortDisplayName, - 'birthday': instance.birthday?.toIso8601String(), - 'photo': instance.photo, - 'programme': _$ProgrammeEnumMap[instance.programme], - 'starting_year': instance.startingYear, - 'website': instance.website?.toString(), - 'profile_description': instance.profileDescription, - }; - -const _$ProgrammeEnumMap = { - Programme.computingscience: 'computingscience', - Programme.informationscience: 'informationscience', -}; - -FullProfile _$FullProfileFromJson(Map json) => FullProfile( - json['display_name'] as String, - json['short_display_name'] as String, - json['birthday'] == null - ? null - : DateTime.parse(json['birthday'] as String), - Photo.fromJson(json['photo'] as Map), - $enumDecodeNullable(_$ProgrammeEnumMap, json['programme']), - json['starting_year'] as int?, - _nonEmptyUriFromJson(json['website'] as String?), - json['profile_description'] as String?, - json['address_street'] as String?, - json['address_street2'] as String?, - json['address_postal_code'] as String?, - json['address_city'] as String?, - json['address_country'] as String?, - json['phone_number'] as String?, - json['emergency_contact'] as String?, - json['emergency_contact_phone_number'] as String?, - json['show_birthday'] as bool, - json['initials'] as String?, - json['nickname'] as String?, - $enumDecode( - _$DisplayNamePreferenceEnumMap, json['display_name_preference']), - ); - -Map _$FullProfileToJson(FullProfile instance) => - { - 'display_name': instance.displayName, - 'short_display_name': instance.shortDisplayName, - 'birthday': instance.birthday?.toIso8601String(), - 'photo': instance.photo, - 'programme': _$ProgrammeEnumMap[instance.programme], - 'starting_year': instance.startingYear, - 'website': instance.website?.toString(), - 'profile_description': instance.profileDescription, - 'address_street': instance.addressStreet, - 'address_street2': instance.addressStreet2, - 'address_postal_code': instance.addressPostalCode, - 'address_city': instance.addressCity, - 'address_country': instance.addressCountry, - 'phone_number': instance.phoneNumber, - 'emergency_contact': instance.emergencyContact, - 'emergency_contact_phone_number': instance.emergencyContactPhoneNumber, - 'show_birthday': instance.showBirthday, - 'initials': instance.initials, - 'nickname': instance.nickname, - 'display_name_preference': - _$DisplayNamePreferenceEnumMap[instance.displayNamePreference]!, - }; - -const _$DisplayNamePreferenceEnumMap = { - DisplayNamePreference.full: 'full', - DisplayNamePreference.nickname: 'nickname', - DisplayNamePreference.firstname: 'firstname', - DisplayNamePreference.initials: 'initials', - DisplayNamePreference.fullnick: 'fullnick', - DisplayNamePreference.nicklast: 'nicklast', -}; - -Period _$PeriodFromJson(Map json) => Period( - DateTime.parse(json['since'] as String), - json['until'] == null ? null : DateTime.parse(json['until'] as String), - json['chair'] as bool, - json['role'] as String?, - ); - -Map _$PeriodToJson(Period instance) => { - 'since': instance.since.toIso8601String(), - 'until': instance.until?.toIso8601String(), - 'chair': instance.chair, - 'role': instance.role, - }; - -Achievement _$AchievementFromJson(Map json) => Achievement( - json['name'] as String, - (json['periods'] as List?) - ?.map((e) => Period.fromJson(e as Map)) - .toList(), - json['pk'] as int?, - json['active'] as bool?, - json['url'] == null ? null : Uri.parse(json['url'] as String), - DateTime.parse(json['earliest'] as String), - json['latest'] == null ? null : DateTime.parse(json['latest'] as String), - ); - -Map _$AchievementToJson(Achievement instance) => - { - 'name': instance.name, - 'earliest': instance.earliest.toIso8601String(), - 'active': instance.active, - 'latest': instance.latest?.toIso8601String(), - 'periods': instance.periods, - 'pk': instance.pk, - 'url': instance.url?.toString(), - }; diff --git a/lib/models/payable.dart b/lib/models/payable.dart deleted file mode 100644 index 88ac77212..000000000 --- a/lib/models/payable.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'package:reaxit/models.dart'; - -part 'payable.g.dart'; - -@JsonSerializable(fieldRename: FieldRename.snake) -class Payable { - final String amount; - final String topic; - final String? notes; - final Payment? payment; - - bool get isPaid => payment != null; - - factory Payable.fromJson(Map json) => - _$PayableFromJson(json); - - const Payable( - this.amount, - this.topic, - this.notes, - this.payment, - ); -} diff --git a/lib/models/payable.g.dart b/lib/models/payable.g.dart deleted file mode 100644 index 9981e9c4b..000000000 --- a/lib/models/payable.g.dart +++ /dev/null @@ -1,23 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'payable.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Payable _$PayableFromJson(Map json) => Payable( - json['amount'] as String, - json['topic'] as String, - json['notes'] as String?, - json['payment'] == null - ? null - : Payment.fromJson(json['payment'] as Map), - ); - -Map _$PayableToJson(Payable instance) => { - 'amount': instance.amount, - 'topic': instance.topic, - 'notes': instance.notes, - 'payment': instance.payment, - }; diff --git a/lib/models/payment.dart b/lib/models/payment.dart deleted file mode 100644 index f49aa53aa..000000000 --- a/lib/models/payment.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'payment.g.dart'; - -enum PaymentType { - @JsonValue('cash_payment') - cashPayment, - @JsonValue('card_payment') - cardPayment, - @JsonValue('tpay_payment') - tpayPayment, - @JsonValue('wire_payment') - wirePayment; - - @override - String toString() { - switch (this) { - case PaymentType.cashPayment: - return 'Cash payment'; - case PaymentType.cardPayment: - return 'Card payment'; - case PaymentType.tpayPayment: - return 'Thalia Pay'; - case PaymentType.wirePayment: - return 'Wire payment'; - } - } -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class Payment { - final String pk; - final String topic; - final String? notes; - final PaymentType type; - final String amount; - final DateTime createdAt; - - factory Payment.fromJson(Map json) => - _$PaymentFromJson(json); - - const Payment( - this.pk, - this.topic, - this.notes, - this.type, - this.amount, - this.createdAt, - ); -} diff --git a/lib/models/payment.g.dart b/lib/models/payment.g.dart deleted file mode 100644 index 55bc98a39..000000000 --- a/lib/models/payment.g.dart +++ /dev/null @@ -1,32 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'payment.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Payment _$PaymentFromJson(Map json) => Payment( - json['pk'] as String, - json['topic'] as String, - json['notes'] as String?, - $enumDecode(_$PaymentTypeEnumMap, json['type']), - json['amount'] as String, - DateTime.parse(json['created_at'] as String), - ); - -Map _$PaymentToJson(Payment instance) => { - 'pk': instance.pk, - 'topic': instance.topic, - 'notes': instance.notes, - 'type': _$PaymentTypeEnumMap[instance.type]!, - 'amount': instance.amount, - 'created_at': instance.createdAt.toIso8601String(), - }; - -const _$PaymentTypeEnumMap = { - PaymentType.cashPayment: 'cash_payment', - PaymentType.cardPayment: 'card_payment', - PaymentType.tpayPayment: 'tpay_payment', - PaymentType.wirePayment: 'wire_payment', -}; diff --git a/lib/models/payment_user.dart b/lib/models/payment_user.dart deleted file mode 100644 index cceebea1a..000000000 --- a/lib/models/payment_user.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'payment_user.g.dart'; - -@JsonSerializable(fieldRename: FieldRename.snake) -class PaymentUser { - final String? tpayBalance; - final bool tpayAllowed; - final bool tpayEnabled; - - factory PaymentUser.fromJson(Map json) => - _$PaymentUserFromJson(json); - - const PaymentUser(this.tpayBalance, this.tpayAllowed, this.tpayEnabled); -} diff --git a/lib/models/payment_user.g.dart b/lib/models/payment_user.g.dart deleted file mode 100644 index aff23a346..000000000 --- a/lib/models/payment_user.g.dart +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'payment_user.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -PaymentUser _$PaymentUserFromJson(Map json) => PaymentUser( - json['tpay_balance'] as String?, - json['tpay_allowed'] as bool, - json['tpay_enabled'] as bool, - ); - -Map _$PaymentUserToJson(PaymentUser instance) => - { - 'tpay_balance': instance.tpayBalance, - 'tpay_allowed': instance.tpayAllowed, - 'tpay_enabled': instance.tpayEnabled, - }; diff --git a/lib/models/product.dart b/lib/models/product.dart deleted file mode 100644 index e61995547..000000000 --- a/lib/models/product.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'product.g.dart'; - -@JsonSerializable(fieldRename: FieldRename.snake) -class Product { - final int pk; - final String name; - final String description; - final String price; - - factory Product.fromJson(Map json) => - _$ProductFromJson(json); - - const Product( - this.pk, - this.name, - this.description, - this.price, - ); -} diff --git a/lib/models/product.g.dart b/lib/models/product.g.dart deleted file mode 100644 index a27e222d5..000000000 --- a/lib/models/product.g.dart +++ /dev/null @@ -1,21 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'product.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Product _$ProductFromJson(Map json) => Product( - json['pk'] as int, - json['name'] as String, - json['description'] as String, - json['price'] as String, - ); - -Map _$ProductToJson(Product instance) => { - 'pk': instance.pk, - 'name': instance.name, - 'description': instance.description, - 'price': instance.price, - }; diff --git a/lib/models/push_notification_category.dart b/lib/models/push_notification_category.dart deleted file mode 100644 index 190ea7174..000000000 --- a/lib/models/push_notification_category.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'push_notification_category.g.dart'; - -@JsonSerializable(fieldRename: FieldRename.snake) -class PushNotificationCategory { - final String key; - final String name; - final String description; - - factory PushNotificationCategory.fromJson(Map json) => - _$PushNotificationCategoryFromJson(json); - - const PushNotificationCategory(this.key, this.name, this.description); -} diff --git a/lib/models/push_notification_category.g.dart b/lib/models/push_notification_category.g.dart deleted file mode 100644 index 4ed209128..000000000 --- a/lib/models/push_notification_category.g.dart +++ /dev/null @@ -1,23 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'push_notification_category.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -PushNotificationCategory _$PushNotificationCategoryFromJson( - Map json) => - PushNotificationCategory( - json['key'] as String, - json['name'] as String, - json['description'] as String, - ); - -Map _$PushNotificationCategoryToJson( - PushNotificationCategory instance) => - { - 'key': instance.key, - 'name': instance.name, - 'description': instance.description, - }; diff --git a/lib/models/registration_field.dart b/lib/models/registration_field.dart deleted file mode 100644 index e82cfc75b..000000000 --- a/lib/models/registration_field.dart +++ /dev/null @@ -1,76 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'registration_field.g.dart'; - -sealed class RegistrationField { - final String label; - final String description; - // ignore: prefer_typing_uninitialized_variables - abstract final value; - - @JsonKey(name: 'required') - final bool isRequired; - - RegistrationField(this.label, this.description, this.isRequired); - - factory RegistrationField.fromJson(Map json) { - switch (json['type']) { - case 'boolean': - return CheckboxRegistrationField.fromJson(json); - case 'integer': - return IntegerRegistrationField.fromJson(json); - case 'text': - return TextRegistrationField.fromJson(json); - default: - throw Exception('Unknown Type'); - } - } -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class IntegerRegistrationField extends RegistrationField { - @override - int? value; - - IntegerRegistrationField( - super.label, - super.description, - super.isRequired, - this.value, - ); - - factory IntegerRegistrationField.fromJson(Map json) => - _$IntegerRegistrationFieldFromJson(json); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class TextRegistrationField extends RegistrationField { - @override - String? value; - - TextRegistrationField( - super.label, - super.description, - super.isRequired, - this.value, - ); - - factory TextRegistrationField.fromJson(Map json) => - _$TextRegistrationFieldFromJson(json); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class CheckboxRegistrationField extends RegistrationField { - @override - bool? value; - - CheckboxRegistrationField( - super.label, - super.description, - super.isRequired, - this.value, - ); - - factory CheckboxRegistrationField.fromJson(Map json) => - _$CheckboxRegistrationFieldFromJson(json); -} diff --git a/lib/models/registration_field.g.dart b/lib/models/registration_field.g.dart deleted file mode 100644 index 544eaf1f8..000000000 --- a/lib/models/registration_field.g.dart +++ /dev/null @@ -1,61 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'registration_field.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -IntegerRegistrationField _$IntegerRegistrationFieldFromJson( - Map json) => - IntegerRegistrationField( - json['label'] as String, - json['description'] as String, - json['required'] as bool, - json['value'] as int?, - ); - -Map _$IntegerRegistrationFieldToJson( - IntegerRegistrationField instance) => - { - 'label': instance.label, - 'description': instance.description, - 'required': instance.isRequired, - 'value': instance.value, - }; - -TextRegistrationField _$TextRegistrationFieldFromJson( - Map json) => - TextRegistrationField( - json['label'] as String, - json['description'] as String, - json['required'] as bool, - json['value'] as String?, - ); - -Map _$TextRegistrationFieldToJson( - TextRegistrationField instance) => - { - 'label': instance.label, - 'description': instance.description, - 'required': instance.isRequired, - 'value': instance.value, - }; - -CheckboxRegistrationField _$CheckboxRegistrationFieldFromJson( - Map json) => - CheckboxRegistrationField( - json['label'] as String, - json['description'] as String, - json['required'] as bool, - json['value'] as bool?, - ); - -Map _$CheckboxRegistrationFieldToJson( - CheckboxRegistrationField instance) => - { - 'label': instance.label, - 'description': instance.description, - 'required': instance.isRequired, - 'value': instance.value, - }; diff --git a/lib/models/sales_order.dart b/lib/models/sales_order.dart deleted file mode 100644 index e7c8881c2..000000000 --- a/lib/models/sales_order.dart +++ /dev/null @@ -1,82 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'package:reaxit/models.dart'; - -part 'sales_order.g.dart'; - -@JsonSerializable(fieldRename: FieldRename.snake) -class SalesOrder { - final String pk; - final int shift; - - final DateTime createdAt; - final List orderItems; - final String orderDescription; - final bool ageRestricted; - final String subtotal; - final String? discount; - final String totalAmount; - final int numItems; - - final ListMember? payer; - final Payment? payment; - - final Uri paymentUrl; - - @JsonKey(includeFromJson: false) - bool? _tpayAllowed; - - /// Whether this order can be paid with Thalia Pay. - /// See https://github.com/svthalia/concrexit/issues/1784. - @JsonKey(includeFromJson: false) - bool get tpayAllowed => _tpayAllowed ?? false; - set tpayAllowed(bool value) => _tpayAllowed = value; - - bool get isPaid => payment != null; - - factory SalesOrder.fromJson(Map json) => - _$SalesOrderFromJson(json); - - SalesOrder( - this.pk, - this.shift, - this.createdAt, - this.orderItems, - this.orderDescription, - this.ageRestricted, - this.subtotal, - this.discount, - this.totalAmount, - this.numItems, - this.payer, - this.payment, - this.paymentUrl, - ); - - SalesOrder copyWithPayment(Payment? newPayment) => SalesOrder( - pk, - shift, - createdAt, - orderItems, - orderDescription, - ageRestricted, - subtotal, - discount, - totalAmount, - numItems, - payer, - newPayment, - paymentUrl, - ); -} - -@JsonSerializable(fieldRename: FieldRename.snake) -class SalesOrderItem { - final String product; - final int amount; - final String total; - - SalesOrderItem(this.product, this.amount, this.total); - - factory SalesOrderItem.fromJson(Map json) => - _$SalesOrderItemFromJson(json); -} diff --git a/lib/models/sales_order.g.dart b/lib/models/sales_order.g.dart deleted file mode 100644 index b6d951eeb..000000000 --- a/lib/models/sales_order.g.dart +++ /dev/null @@ -1,60 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'sales_order.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -SalesOrder _$SalesOrderFromJson(Map json) => SalesOrder( - json['pk'] as String, - json['shift'] as int, - DateTime.parse(json['created_at'] as String), - (json['order_items'] as List) - .map((e) => SalesOrderItem.fromJson(e as Map)) - .toList(), - json['order_description'] as String, - json['age_restricted'] as bool, - json['subtotal'] as String, - json['discount'] as String?, - json['total_amount'] as String, - json['num_items'] as int, - json['payer'] == null - ? null - : ListMember.fromJson(json['payer'] as Map), - json['payment'] == null - ? null - : Payment.fromJson(json['payment'] as Map), - Uri.parse(json['payment_url'] as String), - ); - -Map _$SalesOrderToJson(SalesOrder instance) => - { - 'pk': instance.pk, - 'shift': instance.shift, - 'created_at': instance.createdAt.toIso8601String(), - 'order_items': instance.orderItems, - 'order_description': instance.orderDescription, - 'age_restricted': instance.ageRestricted, - 'subtotal': instance.subtotal, - 'discount': instance.discount, - 'total_amount': instance.totalAmount, - 'num_items': instance.numItems, - 'payer': instance.payer, - 'payment': instance.payment, - 'payment_url': instance.paymentUrl.toString(), - }; - -SalesOrderItem _$SalesOrderItemFromJson(Map json) => - SalesOrderItem( - json['product'] as String, - json['amount'] as int, - json['total'] as String, - ); - -Map _$SalesOrderItemToJson(SalesOrderItem instance) => - { - 'product': instance.product, - 'amount': instance.amount, - 'total': instance.total, - }; diff --git a/lib/models/slide.dart b/lib/models/slide.dart deleted file mode 100644 index 80019468a..000000000 --- a/lib/models/slide.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'package:reaxit/models.dart'; - -part 'slide.g.dart'; - -@JsonSerializable(fieldRename: FieldRename.snake) -class Slide { - final int pk; - final String title; - final Photo content; - final int order; - final Uri? url; - - const Slide(this.pk, this.title, this.content, this.order, this.url); - - factory Slide.fromJson(Map json) => _$SlideFromJson(json); -} diff --git a/lib/models/slide.g.dart b/lib/models/slide.g.dart deleted file mode 100644 index d8f4c754d..000000000 --- a/lib/models/slide.g.dart +++ /dev/null @@ -1,23 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'slide.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Slide _$SlideFromJson(Map json) => Slide( - json['pk'] as int, - json['title'] as String, - Photo.fromJson(json['content'] as Map), - json['order'] as int, - json['url'] == null ? null : Uri.parse(json['url'] as String), - ); - -Map _$SlideToJson(Slide instance) => { - 'pk': instance.pk, - 'title': instance.title, - 'content': instance.content, - 'order': instance.order, - 'url': instance.url?.toString(), - }; diff --git a/lib/routes.dart b/lib/routes.dart index 69c10f93a..63ccde11a 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:reaxit/models.dart'; -import 'package:reaxit/ui/screens.dart'; import 'package:reaxit/ui/screens/album_screen.dart'; final List routes = [ @@ -12,18 +11,12 @@ final List routes = [ redirect: (context, state) => '/albums/${state.pathParameters['albumSlug']}', ), - GoRoute( - // This redirect is above the members route because - // the members path is a prefix of this albums path. - path: '/members/photos', - redirect: (context, state) => '/albums', - ), GoRoute( path: '/albums', name: 'albums', pageBuilder: (context, state) => CustomTransitionPage( key: state.pageKey, - child: AlbumsScreen(), + child: Container(), transitionDuration: const Duration(milliseconds: 200), transitionsBuilder: (context, animation, secondaryAnimation, child) { return FadeTransition( diff --git a/lib/ui/screens.dart b/lib/ui/screens.dart deleted file mode 100644 index 44aa61186..000000000 --- a/lib/ui/screens.dart +++ /dev/null @@ -1 +0,0 @@ -export 'screens/albums_screen.dart'; diff --git a/lib/ui/screens/albums_screen.dart b/lib/ui/screens/albums_screen.dart deleted file mode 100644 index 0a77f8c34..000000000 --- a/lib/ui/screens/albums_screen.dart +++ /dev/null @@ -1,242 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:go_router/go_router.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:reaxit/blocs.dart'; -import 'package:reaxit/api/api_repository.dart'; -import 'package:reaxit/ui/widgets.dart'; - -class AlbumsScreen extends StatefulWidget { - @override - State createState() => _AlbumsScreenState(); -} - -class _AlbumsScreenState extends State { - late ScrollController _controller; - late AlbumListCubit _cubit; - - @override - void initState() { - _cubit = BlocProvider.of(context); - _controller = ScrollController()..addListener(_scrollListener); - super.initState(); - } - - void _scrollListener() { - if (_controller.position.pixels >= - _controller.position.maxScrollExtent - 300) { - // Only request loading more if that's not already happening. - if (!_cubit.state.isLoadingMore) { - _cubit.more(); - } - } - } - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: ThaliaAppBar( - title: const Text('ALBUMS'), - collapsingActions: [ - IconAppbarAction( - 'LIKED PHOTOS', - Icons.favorite_border, - () => context.pushNamed('liked-photos'), - ), - IconAppbarAction( - 'SEARCH', - Icons.search, - () async { - final searchCubit = AlbumListCubit( - RepositoryProvider.of(context), - ); - - await showSearch( - context: context, - delegate: AlbumsSearchDelegate(searchCubit), - ); - - searchCubit.close(); - }, - ), - ], - ), - drawer: MenuDrawer(), - body: RefreshIndicator( - onRefresh: () async { - await _cubit.load(); - }, - child: BlocBuilder( - builder: (context, listState) { - if (listState.hasException) { - return ErrorScrollView(listState.message!); - } else { - return AlbumListScrollView( - key: const PageStorageKey('albums'), - controller: _controller, - listState: listState, - ); - } - }, - ), - ), - ); - } -} - -class AlbumsSearchDelegate extends SearchDelegate { - late final ScrollController _controller; - final AlbumListCubit _cubit; - - AlbumsSearchDelegate(this._cubit) { - _controller = ScrollController()..addListener(_scrollListener); - } - - void _scrollListener() { - if (!_controller.hasClients) { - return; - } - if (_controller.position.pixels >= - _controller.position.maxScrollExtent - 300) { - // Only request loading more if that's not already happening. - if (!_cubit.state.isLoadingMore) { - _cubit.more(); - } - } - } - - @override - ThemeData appBarTheme(BuildContext context) { - final theme = super.appBarTheme(context); - return theme.copyWith( - textTheme: theme.textTheme.copyWith( - titleLarge: GoogleFonts.openSans( - textStyle: Theme.of(context).textTheme.titleLarge, - ), - ), - ); - } - - @override - List buildActions(BuildContext context) { - if (query.isNotEmpty) { - return [ - IconButton( - padding: const EdgeInsets.all(16), - tooltip: 'Clear search bar', - icon: const Icon(Icons.clear), - onPressed: () { - query = ''; - }, - ) - ]; - } else { - return []; - } - } - - @override - Widget buildLeading(BuildContext context) { - return BackButton( - onPressed: () => close(context, null), - ); - } - - @override - Widget buildResults(BuildContext context) { - return BlocBuilder( - bloc: _cubit..search(query), - builder: (context, listState) { - if (listState.hasException) { - return ErrorScrollView(listState.message!); - } else { - return AlbumListScrollView( - key: const PageStorageKey('albums-search'), - controller: _controller, - listState: listState, - ); - } - }, - ); - } - - @override - Widget buildSuggestions(BuildContext context) { - return BlocBuilder( - bloc: _cubit..search(query), - builder: (context, listState) { - if (listState.hasException) { - return ErrorScrollView(listState.message!); - } else { - return AlbumListScrollView( - key: const PageStorageKey('albums-search'), - controller: _controller, - listState: listState, - ); - } - }, - ); - } -} - -/// A ScrollView that shows a grid of [AlbumTile]s. -/// -/// This does not take care of communicating with a Bloc. The [controller] -/// should do that. The [listState] also must not have an exception. -class AlbumListScrollView extends StatelessWidget { - final ScrollController controller; - final AlbumListState listState; - - const AlbumListScrollView({ - super.key, - required this.controller, - required this.listState, - }); - - @override - Widget build(BuildContext context) { - return Scrollbar( - controller: controller, - child: CustomScrollView( - controller: controller, - physics: const RangeMaintainingScrollPhysics( - parent: AlwaysScrollableScrollPhysics(), - ), - slivers: [ - SliverPadding( - padding: const EdgeInsets.all(8), - sliver: SliverGrid( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, - mainAxisSpacing: 8, - crossAxisSpacing: 8, - ), - delegate: SliverChildBuilderDelegate( - (context, index) => AlbumTile( - album: listState.results[index], - ), - childCount: listState.results.length, - ), - ), - ), - if (listState.isLoadingMore) - const SliverPadding( - padding: EdgeInsets.all(8), - sliver: SliverList( - delegate: SliverChildListDelegate.fixed([ - Center( - child: CircularProgressIndicator(), - ) - ]), - ), - ), - ], - )); - } -} diff --git a/lib/ui/widgets.dart b/lib/ui/widgets.dart index 855017189..ec79dce3e 100644 --- a/lib/ui/widgets.dart +++ b/lib/ui/widgets.dart @@ -2,6 +2,5 @@ export 'widgets/album_tile.dart'; export 'widgets/app_bar.dart'; export 'widgets/error_center.dart'; export 'widgets/error_scroll_view.dart'; -export 'widgets/event_detail_card.dart'; export 'widgets/menu_drawer.dart'; export 'widgets/filter_popup.dart'; diff --git a/lib/ui/widgets/event_detail_card.dart b/lib/ui/widgets/event_detail_card.dart deleted file mode 100644 index 30c2ef927..000000000 --- a/lib/ui/widgets/event_detail_card.dart +++ /dev/null @@ -1,158 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; -import 'package:intl/intl.dart'; -import 'package:reaxit/models.dart'; -import 'package:url_launcher/url_launcher.dart'; -import 'package:reaxit/models/event.dart'; -import 'package:reaxit/ui/theme.dart'; - -class EventDetailCard extends StatelessWidget { - static final timeFormatter = DateFormat('HH:mm'); - final BaseEvent event; - final Color _indicatorColor; - final bool _hasFoodEvent; - final Color? _color; - final Color? _textColor; - - static Color _getIndicatorColor(Event event) { - if (event.isInvited) { - return magenta; - } else if (event.isInQueue) { - return Colors.yellow; - } else if (event.canCreateRegistration) { - return Colors.grey; - } - - return Colors.transparent; - } - - EventDetailCard({ - required this.event, - }) : _color = event is PartnerEvent ? Colors.black : null, - _textColor = event is PartnerEvent ? Colors.white : null, - _indicatorColor = - event is Event ? _getIndicatorColor(event) : Colors.transparent, - _hasFoodEvent = event is Event ? event.hasFoodEvent : false; - - void _onTap(BuildContext context) { - // TODO: because adminevent is also a BaseEvent we should implement it as well, and make it a switch expr - if (event is Event) { - context.pushNamed( - 'event', - pathParameters: {'eventPk': event.pk.toString()}, - extra: event, - ); - } else if (event is PartnerEvent) { - launchUrl( - (event as PartnerEvent).url, - mode: LaunchMode.externalApplication, - ); - } - } - - @override - Widget build(BuildContext context) { - final start = timeFormatter.format(event.start.toLocal()); - final end = timeFormatter.format(event.end.toLocal()); - - // Remove HTML tags. - final caption = event.caption.replaceAll(RegExp(r'<[^>]*>|&[^;]+;'), ''); - - final textTheme = Theme.of(context).textTheme; - return Card( - color: _color, - margin: const EdgeInsets.symmetric(vertical: 8), - child: InkWell( - onTap: () => _onTap(context), - // Prevent painting ink outside of the card. - borderRadius: const BorderRadius.all(Radius.circular(12)), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Padding( - padding: const EdgeInsets.only( - top: 16, - left: 16, - right: 16, - bottom: 8, - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - event.title.toUpperCase(), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: textTheme.titleMedium! - .copyWith(color: _textColor), - ), - const SizedBox(height: 4), - Text( - '$start - $end | ${event.location}', - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: - textTheme.bodySmall!.copyWith(color: _textColor), - ), - ], - ), - ), - Container( - width: 16, - height: 16, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: _indicatorColor, - ), - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Text( - caption, - maxLines: 3, - overflow: TextOverflow.ellipsis, - style: DefaultTextStyle.of(context) - .style - .copyWith(color: _textColor), - ), - ), - Padding( - padding: const EdgeInsets.only( - top: 8, - left: 16, - right: 16, - bottom: 8, - ), - child: Row( - children: [ - ElevatedButton( - onPressed: () => _onTap(context), - child: const Text('MORE INFO'), - ), - if (_hasFoodEvent) ...[ - const SizedBox(width: 16), - ElevatedButton.icon( - label: const Text('FOOD'), - icon: const Icon(Icons.local_pizza), - onPressed: () => context.pushNamed('food', extra: event), - ), - ] - ], - ), - ) - ], - ), - ), - ); - } -} diff --git a/lib/ui/widgets/pay_tile.dart b/lib/ui/widgets/pay_tile.dart deleted file mode 100644 index 18a11f60f..000000000 --- a/lib/ui/widgets/pay_tile.dart +++ /dev/null @@ -1,79 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; - -import 'package:reaxit/models/payment.dart'; - -class PayTile extends StatefulWidget { - final Payment payment; - - const PayTile({super.key, required this.payment}); - - @override - State createState() => _PayTileState(); -} - -class _PayTileState extends State { - static final timeFormatter = DateFormat('E d MMM y, HH:mm'); - - late bool _isExpanded; - - @override - void initState() { - _isExpanded = false; - super.initState(); - } - - void _onTap() { - setState(() { - _isExpanded = !_isExpanded; - }); - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - Card( - child: ListTile( - onTap: _onTap, - title: Text( - timeFormatter.format(widget.payment.createdAt.toLocal()), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: Theme.of(context) - .textTheme - .bodyMedium! - .copyWith(fontWeight: FontWeight.bold), - ), - subtitle: Text( - widget.payment.topic, - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), - trailing: Text( - '€ ${widget.payment.amount}', - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ), - ), - AnimatedSize( - duration: const Duration(milliseconds: 200), - child: _isExpanded && (widget.payment.notes?.isNotEmpty ?? false) - ? Card( - child: ListTile( - title: Text( - widget.payment.notes!, - style: Theme.of(context) - .textTheme - .bodyMedium! - .copyWith(fontWeight: FontWeight.bold), - ), - ), - ) - : const SizedBox(width: double.infinity), - ), - ], - ); - } -} diff --git a/pubspec.lock b/pubspec.lock index 24cafdc74..128756aaa 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1059,34 +1059,34 @@ packages: dependency: "direct main" description: name: shared_preferences - sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02" + sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180 url: "https://pub.dev" source: hosted - version: "2.2.2" + version: "2.2.3" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "8304d8a1f7d21a429f91dee552792249362b68a331ac5c3c1caf370f658873f6" + sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.2.2" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation - sha256: "0c1c16c56c9708aa9c361541a6f0e5cc6fc12a3232d866a687a7b7db30032b07" + sha256: "0a8a893bf4fd1152f93fec03a415d11c27c74454d96e2318a7ac38dd18683ab7" url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.4.0" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux - sha256: "9d387433ca65717bbf1be88f4d5bb18f10508917a8fa2fb02e0fd0d7479a9afa" + sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.3.2" shared_preferences_platform_interface: dependency: transitive description: @@ -1099,18 +1099,18 @@ packages: dependency: transitive description: name: shared_preferences_web - sha256: "74083203a8eae241e0de4a0d597dbedab3b8fef5563f33cf3c12d7e93c655ca5" + sha256: "7b15ffb9387ea3e237bb7a66b8a23d2147663d391cafc5c8f37b2e7b4bde5d21" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.2.2" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows - sha256: "5e588e2efef56916a3b229c3bfe81e6a525665a454519ca51dbcc4236a274173" + sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.3.2" shelf: dependency: transitive description: @@ -1438,5 +1438,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.2.0 <4.0.0" - flutter: ">=3.16.0" + dart: ">=3.2.3 <4.0.0" + flutter: ">=3.16.6" diff --git a/test/fakes.dart b/test/fakes.dart deleted file mode 100644 index a3182b91f..000000000 --- a/test/fakes.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:reaxit/models.dart'; - -class FakeEvent implements BaseEvent { - @override - final int pk; - @override - final String title; - @override - final String caption; - @override - final DateTime start; - @override - final DateTime end; - @override - final String location; - - FakeEvent({ - required this.pk, - required this.title, - required this.caption, - required this.start, - required this.end, - required this.location, - }); -} diff --git a/test/mocks.mocks.dart b/test/mocks.mocks.dart index 68e1a77b2..e334e15b0 100644 --- a/test/mocks.mocks.dart +++ b/test/mocks.mocks.dart @@ -43,16 +43,6 @@ class _FakeConfig_1 extends _i1.SmartFake implements _i3.Config { ); } -class _FakeEvent_2 extends _i1.SmartFake implements _i4.Event { - _FakeEvent_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - class _FakeListResponse_3 extends _i1.SmartFake implements _i4.ListResponse { _FakeListResponse_3( @@ -64,98 +54,6 @@ class _FakeListResponse_3 extends _i1.SmartFake ); } -class _FakeEventRegistration_4 extends _i1.SmartFake - implements _i4.EventRegistration { - _FakeEventRegistration_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeAdminEvent_5 extends _i1.SmartFake implements _i4.AdminEvent { - _FakeAdminEvent_5( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeAdminEventRegistration_6 extends _i1.SmartFake - implements _i4.AdminEventRegistration { - _FakeAdminEventRegistration_6( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakePayable_7 extends _i1.SmartFake implements _i4.Payable { - _FakePayable_7( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeFoodEvent_8 extends _i1.SmartFake implements _i4.FoodEvent { - _FakeFoodEvent_8( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeFoodOrder_9 extends _i1.SmartFake implements _i4.FoodOrder { - _FakeFoodOrder_9( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakePaymentUser_10 extends _i1.SmartFake implements _i4.PaymentUser { - _FakePaymentUser_10( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeMember_11 extends _i1.SmartFake implements _i4.Member { - _FakeMember_11( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeFullMember_12 extends _i1.SmartFake implements _i4.FullMember { - _FakeFullMember_12( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - class _FakeAlbum_13 extends _i1.SmartFake implements _i4.Album { _FakeAlbum_13( Object parent, @@ -166,36 +64,6 @@ class _FakeAlbum_13 extends _i1.SmartFake implements _i4.Album { ); } -class _FakeDevice_14 extends _i1.SmartFake implements _i4.Device { - _FakeDevice_14( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeSalesOrder_15 extends _i1.SmartFake implements _i4.SalesOrder { - _FakeSalesOrder_15( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -class _FakeGroup_16 extends _i1.SmartFake implements _i4.Group { - _FakeGroup_16( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - class _FakeApiRepository_17 extends _i1.SmartFake implements _i5.ApiRepository { _FakeApiRepository_17( Object parent, @@ -349,1167 +217,170 @@ class MockApiRepository extends _i1.Mock implements _i5.ApiRepository { returnValueForMissingStub: null, ); @override - _i8.Future<_i4.Event> getEventByPk({required int? pk}) => (super.noSuchMethod( + _i8.Future cancelRegistration({ + required int? eventPk, + required int? registrationPk, + }) => + (super.noSuchMethod( Invocation.method( - #getEventByPk, + #cancelRegistration, [], - {#pk: pk}, + { + #eventPk: eventPk, + #registrationPk: registrationPk, + }, ), - returnValue: _i8.Future<_i4.Event>.value(_FakeEvent_2( - this, - Invocation.method( - #getEventByPk, - [], - {#pk: pk}, - ), - )), - ) as _i8.Future<_i4.Event>); + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + + @override + _i8.Future markPresentEventRegistration({ + required int? eventPk, + required String? token, + }) => + (super.noSuchMethod( + Invocation.method( + #markPresentEventRegistration, + [], + { + #eventPk: eventPk, + #token: token, + }, + ), + returnValue: _i8.Future.value(''), + ) as _i8.Future); + + @override + _i8.Future updateAvatar(String? file) => (super.noSuchMethod( + Invocation.method( + #updateAvatar, + [file], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); + @override + _i8.Future updateDescription(String? description) => + (super.noSuchMethod( + Invocation.method( + #updateDescription, + [description], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i8.Future<_i4.Event> getEventBySlug({required String? slug}) => + _i8.Future<_i4.Album> getAlbum({required String? slug}) => (super.noSuchMethod( Invocation.method( - #getEventBySlug, + #getAlbum, [], {#slug: slug}, ), - returnValue: _i8.Future<_i4.Event>.value(_FakeEvent_2( + returnValue: _i8.Future<_i4.Album>.value(_FakeAlbum_13( this, Invocation.method( - #getEventBySlug, + #getAlbum, [], {#slug: slug}, ), )), - ) as _i8.Future<_i4.Event>); + ) as _i8.Future<_i4.Album>); + @override + _i8.Future updateLiked( + int? id, + bool? liked, + ) => + (super.noSuchMethod( + Invocation.method( + #updateLiked, + [ + id, + liked, + ], + ), + returnValue: _i8.Future.value(), + returnValueForMissingStub: _i8.Future.value(), + ) as _i8.Future); @override - _i8.Future<_i4.ListResponse<_i4.Event>> getEvents({ + _i8.Future<_i4.ListResponse<_i4.ListAlbum>> getAlbums({ String? search, int? limit, int? offset, - String? ordering, - DateTime? start, - DateTime? end, }) => (super.noSuchMethod( Invocation.method( - #getEvents, + #getAlbums, [], { #search: search, #limit: limit, #offset: offset, - #ordering: ordering, - #start: start, - #end: end, }, ), - returnValue: _i8.Future<_i4.ListResponse<_i4.Event>>.value( - _FakeListResponse_3<_i4.Event>( + returnValue: _i8.Future<_i4.ListResponse<_i4.ListAlbum>>.value( + _FakeListResponse_3<_i4.ListAlbum>( this, Invocation.method( - #getEvents, + #getAlbums, [], { #search: search, #limit: limit, #offset: offset, - #ordering: ordering, - #start: start, - #end: end, }, ), )), - ) as _i8.Future<_i4.ListResponse<_i4.Event>>); + ) as _i8.Future<_i4.ListResponse<_i4.ListAlbum>>); + @override - _i8.Future<_i4.ListResponse<_i4.PartnerEvent>> getPartnerEvents({ - String? search, + _i8.Future<_i4.ListResponse<_i4.FrontpageArticle>> getFrontpageArticles({ int? limit, int? offset, - String? ordering, - DateTime? start, - DateTime? end, }) => (super.noSuchMethod( Invocation.method( - #getPartnerEvents, + #getFrontpageArticles, [], { - #search: search, #limit: limit, #offset: offset, - #ordering: ordering, - #start: start, - #end: end, }, ), - returnValue: _i8.Future<_i4.ListResponse<_i4.PartnerEvent>>.value( - _FakeListResponse_3<_i4.PartnerEvent>( + returnValue: _i8.Future<_i4.ListResponse<_i4.FrontpageArticle>>.value( + _FakeListResponse_3<_i4.FrontpageArticle>( this, Invocation.method( - #getPartnerEvents, + #getFrontpageArticles, [], { - #search: search, #limit: limit, #offset: offset, - #ordering: ordering, - #start: start, - #end: end, }, ), )), - ) as _i8.Future<_i4.ListResponse<_i4.PartnerEvent>>); + ) as _i8.Future<_i4.ListResponse<_i4.FrontpageArticle>>); + @override - _i8.Future<_i4.ListResponse<_i4.EventRegistration>> getEventRegistrations({ - required int? pk, + _i8.Future<_i4.ListResponse<_i4.AlbumPhoto>> getLikedPhotos({ int? limit, int? offset, }) => (super.noSuchMethod( Invocation.method( - #getEventRegistrations, + #getLikedPhotos, [], { - #pk: pk, #limit: limit, #offset: offset, }, ), - returnValue: _i8.Future<_i4.ListResponse<_i4.EventRegistration>>.value( - _FakeListResponse_3<_i4.EventRegistration>( + returnValue: _i8.Future<_i4.ListResponse<_i4.AlbumPhoto>>.value( + _FakeListResponse_3<_i4.AlbumPhoto>( this, Invocation.method( - #getEventRegistrations, - [], - { - #pk: pk, - #limit: limit, - #offset: offset, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.EventRegistration>>); - @override - _i8.Future<_i4.EventRegistration> registerForEvent(int? pk) => - (super.noSuchMethod( - Invocation.method( - #registerForEvent, - [pk], - ), - returnValue: - _i8.Future<_i4.EventRegistration>.value(_FakeEventRegistration_4( - this, - Invocation.method( - #registerForEvent, - [pk], - ), - )), - ) as _i8.Future<_i4.EventRegistration>); - @override - _i8.Future cancelRegistration({ - required int? eventPk, - required int? registrationPk, - }) => - (super.noSuchMethod( - Invocation.method( - #cancelRegistration, - [], - { - #eventPk: eventPk, - #registrationPk: registrationPk, - }, - ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); - @override - _i8.Future> getRegistrationFields({ - required int? eventPk, - required int? registrationPk, - }) => - (super.noSuchMethod( - Invocation.method( - #getRegistrationFields, - [], - { - #eventPk: eventPk, - #registrationPk: registrationPk, - }, - ), - returnValue: _i8.Future>.value( - {}), - ) as _i8.Future>); - @override - _i8.Future updateRegistrationFields({ - required int? eventPk, - required int? registrationPk, - required Map? fields, - }) => - (super.noSuchMethod( - Invocation.method( - #updateRegistrationFields, - [], - { - #eventPk: eventPk, - #registrationPk: registrationPk, - #fields: fields, - }, - ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); - @override - _i8.Future<_i4.AdminEvent> getAdminEvent({required int? pk}) => - (super.noSuchMethod( - Invocation.method( - #getAdminEvent, - [], - {#pk: pk}, - ), - returnValue: _i8.Future<_i4.AdminEvent>.value(_FakeAdminEvent_5( - this, - Invocation.method( - #getAdminEvent, - [], - {#pk: pk}, - ), - )), - ) as _i8.Future<_i4.AdminEvent>); - @override - _i8.Future<_i4.ListResponse<_i4.AdminEventRegistration>> - getAdminEventRegistrations({ - required int? pk, - int? limit, - int? offset, - String? search, - String? ordering, - bool? cancelled, - bool? queued, - }) => - (super.noSuchMethod( - Invocation.method( - #getAdminEventRegistrations, - [], - { - #pk: pk, - #limit: limit, - #offset: offset, - #search: search, - #ordering: ordering, - #cancelled: cancelled, - #queued: queued, - }, - ), - returnValue: - _i8.Future<_i4.ListResponse<_i4.AdminEventRegistration>>.value( - _FakeListResponse_3<_i4.AdminEventRegistration>( - this, - Invocation.method( - #getAdminEventRegistrations, - [], - { - #pk: pk, - #limit: limit, - #offset: offset, - #search: search, - #ordering: ordering, - #cancelled: cancelled, - #queued: queued, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.AdminEventRegistration>>); - @override - _i8.Future markPresentEventRegistration({ - required int? eventPk, - required String? token, - }) => - (super.noSuchMethod( - Invocation.method( - #markPresentEventRegistration, - [], - { - #eventPk: eventPk, - #token: token, - }, - ), - returnValue: _i8.Future.value(''), - ) as _i8.Future); - @override - _i8.Future<_i4.AdminEventRegistration> markPresentAdminEventRegistration({ - required int? eventPk, - required int? registrationPk, - required bool? present, - }) => - (super.noSuchMethod( - Invocation.method( - #markPresentAdminEventRegistration, - [], - { - #eventPk: eventPk, - #registrationPk: registrationPk, - #present: present, - }, - ), - returnValue: _i8.Future<_i4.AdminEventRegistration>.value( - _FakeAdminEventRegistration_6( - this, - Invocation.method( - #markPresentAdminEventRegistration, - [], - { - #eventPk: eventPk, - #registrationPk: registrationPk, - #present: present, - }, - ), - )), - ) as _i8.Future<_i4.AdminEventRegistration>); - @override - _i8.Future<_i4.Payable> markPaidAdminEventRegistration({ - required int? registrationPk, - required _i4.PaymentType? paymentType, - }) => - (super.noSuchMethod( - Invocation.method( - #markPaidAdminEventRegistration, - [], - { - #registrationPk: registrationPk, - #paymentType: paymentType, - }, - ), - returnValue: _i8.Future<_i4.Payable>.value(_FakePayable_7( - this, - Invocation.method( - #markPaidAdminEventRegistration, - [], - { - #registrationPk: registrationPk, - #paymentType: paymentType, - }, - ), - )), - ) as _i8.Future<_i4.Payable>); - @override - _i8.Future markNotPaidAdminEventRegistration( - {required int? registrationPk}) => - (super.noSuchMethod( - Invocation.method( - #markNotPaidAdminEventRegistration, - [], - {#registrationPk: registrationPk}, - ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); - @override - _i8.Future<_i4.ListResponse<_i4.AdminFoodOrder>> getAdminFoodOrders({ - required int? pk, - int? limit, - int? offset, - String? search, - }) => - (super.noSuchMethod( - Invocation.method( - #getAdminFoodOrders, - [], - { - #pk: pk, - #limit: limit, - #offset: offset, - #search: search, - }, - ), - returnValue: _i8.Future<_i4.ListResponse<_i4.AdminFoodOrder>>.value( - _FakeListResponse_3<_i4.AdminFoodOrder>( - this, - Invocation.method( - #getAdminFoodOrders, - [], - { - #pk: pk, - #limit: limit, - #offset: offset, - #search: search, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.AdminFoodOrder>>); - @override - _i8.Future<_i4.Payable> markPaidAdminFoodOrder({ - required int? orderPk, - required _i4.PaymentType? paymentType, - }) => - (super.noSuchMethod( - Invocation.method( - #markPaidAdminFoodOrder, - [], - { - #orderPk: orderPk, - #paymentType: paymentType, - }, - ), - returnValue: _i8.Future<_i4.Payable>.value(_FakePayable_7( - this, - Invocation.method( - #markPaidAdminFoodOrder, - [], - { - #orderPk: orderPk, - #paymentType: paymentType, - }, - ), - )), - ) as _i8.Future<_i4.Payable>); - @override - _i8.Future markNotPaidAdminFoodOrder({required int? orderPk}) => - (super.noSuchMethod( - Invocation.method( - #markNotPaidAdminFoodOrder, - [], - {#orderPk: orderPk}, - ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); - @override - _i8.Future<_i4.FoodEvent> getFoodEvent(int? pk) => (super.noSuchMethod( - Invocation.method( - #getFoodEvent, - [pk], - ), - returnValue: _i8.Future<_i4.FoodEvent>.value(_FakeFoodEvent_8( - this, - Invocation.method( - #getFoodEvent, - [pk], - ), - )), - ) as _i8.Future<_i4.FoodEvent>); - @override - _i8.Future<_i4.ListResponse<_i4.FoodEvent>> getFoodEvents({ - int? limit, - int? offset, - String? ordering, - DateTime? start, - DateTime? end, - }) => - (super.noSuchMethod( - Invocation.method( - #getFoodEvents, - [], - { - #limit: limit, - #offset: offset, - #ordering: ordering, - #start: start, - #end: end, - }, - ), - returnValue: _i8.Future<_i4.ListResponse<_i4.FoodEvent>>.value( - _FakeListResponse_3<_i4.FoodEvent>( - this, - Invocation.method( - #getFoodEvents, - [], - { - #limit: limit, - #offset: offset, - #ordering: ordering, - #start: start, - #end: end, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.FoodEvent>>); - @override - _i8.Future<_i4.FoodEvent> getCurrentFoodEvent() => (super.noSuchMethod( - Invocation.method( - #getCurrentFoodEvent, - [], - ), - returnValue: _i8.Future<_i4.FoodEvent>.value(_FakeFoodEvent_8( - this, - Invocation.method( - #getCurrentFoodEvent, - [], - ), - )), - ) as _i8.Future<_i4.FoodEvent>); - @override - _i8.Future<_i4.FoodOrder> getFoodOrder(int? pk) => (super.noSuchMethod( - Invocation.method( - #getFoodOrder, - [pk], - ), - returnValue: _i8.Future<_i4.FoodOrder>.value(_FakeFoodOrder_9( - this, - Invocation.method( - #getFoodOrder, - [pk], - ), - )), - ) as _i8.Future<_i4.FoodOrder>); - @override - _i8.Future cancelFoodOrder(int? pk) => (super.noSuchMethod( - Invocation.method( - #cancelFoodOrder, - [pk], - ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); - @override - _i8.Future<_i4.FoodOrder> placeFoodOrder({ - required int? eventPk, - required int? productPk, - }) => - (super.noSuchMethod( - Invocation.method( - #placeFoodOrder, - [], - { - #eventPk: eventPk, - #productPk: productPk, - }, - ), - returnValue: _i8.Future<_i4.FoodOrder>.value(_FakeFoodOrder_9( - this, - Invocation.method( - #placeFoodOrder, - [], - { - #eventPk: eventPk, - #productPk: productPk, - }, - ), - )), - ) as _i8.Future<_i4.FoodOrder>); - @override - _i8.Future<_i4.FoodOrder> changeFoodOrder({ - required int? eventPk, - required int? productPk, - }) => - (super.noSuchMethod( - Invocation.method( - #changeFoodOrder, - [], - { - #eventPk: eventPk, - #productPk: productPk, - }, - ), - returnValue: _i8.Future<_i4.FoodOrder>.value(_FakeFoodOrder_9( - this, - Invocation.method( - #changeFoodOrder, - [], - { - #eventPk: eventPk, - #productPk: productPk, - }, - ), - )), - ) as _i8.Future<_i4.FoodOrder>); - @override - _i8.Future<_i4.ListResponse<_i4.Product>> getFoodEventProducts( - int? pk, { - int? limit, - int? offset, - String? search, - }) => - (super.noSuchMethod( - Invocation.method( - #getFoodEventProducts, - [pk], - { - #limit: limit, - #offset: offset, - #search: search, - }, - ), - returnValue: _i8.Future<_i4.ListResponse<_i4.Product>>.value( - _FakeListResponse_3<_i4.Product>( - this, - Invocation.method( - #getFoodEventProducts, - [pk], - { - #limit: limit, - #offset: offset, - #search: search, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.Product>>); - @override - _i8.Future<_i4.PaymentUser> getPaymentUser() => (super.noSuchMethod( - Invocation.method( - #getPaymentUser, - [], - ), - returnValue: _i8.Future<_i4.PaymentUser>.value(_FakePaymentUser_10( - this, - Invocation.method( - #getPaymentUser, - [], - ), - )), - ) as _i8.Future<_i4.PaymentUser>); - @override - _i8.Future<_i4.Payable> getFoodOrderPayable({required int? foodOrderPk}) => - (super.noSuchMethod( - Invocation.method( - #getFoodOrderPayable, - [], - {#foodOrderPk: foodOrderPk}, - ), - returnValue: _i8.Future<_i4.Payable>.value(_FakePayable_7( - this, - Invocation.method( - #getFoodOrderPayable, - [], - {#foodOrderPk: foodOrderPk}, - ), - )), - ) as _i8.Future<_i4.Payable>); - @override - _i8.Future<_i4.Payable> thaliaPayFoodOrder({required int? foodOrderPk}) => - (super.noSuchMethod( - Invocation.method( - #thaliaPayFoodOrder, - [], - {#foodOrderPk: foodOrderPk}, - ), - returnValue: _i8.Future<_i4.Payable>.value(_FakePayable_7( - this, - Invocation.method( - #thaliaPayFoodOrder, - [], - {#foodOrderPk: foodOrderPk}, - ), - )), - ) as _i8.Future<_i4.Payable>); - @override - _i8.Future<_i4.Payable> getEventRegistrationPayable( - {required int? registrationPk}) => - (super.noSuchMethod( - Invocation.method( - #getEventRegistrationPayable, - [], - {#registrationPk: registrationPk}, - ), - returnValue: _i8.Future<_i4.Payable>.value(_FakePayable_7( - this, - Invocation.method( - #getEventRegistrationPayable, - [], - {#registrationPk: registrationPk}, - ), - )), - ) as _i8.Future<_i4.Payable>); - @override - _i8.Future<_i4.Payable> thaliaPayRegistration( - {required int? registrationPk}) => - (super.noSuchMethod( - Invocation.method( - #thaliaPayRegistration, - [], - {#registrationPk: registrationPk}, - ), - returnValue: _i8.Future<_i4.Payable>.value(_FakePayable_7( - this, - Invocation.method( - #thaliaPayRegistration, - [], - {#registrationPk: registrationPk}, - ), - )), - ) as _i8.Future<_i4.Payable>); - @override - _i8.Future<_i4.Payable> getSalesOrderPayable( - {required String? salesOrderPk}) => - (super.noSuchMethod( - Invocation.method( - #getSalesOrderPayable, - [], - {#salesOrderPk: salesOrderPk}, - ), - returnValue: _i8.Future<_i4.Payable>.value(_FakePayable_7( - this, - Invocation.method( - #getSalesOrderPayable, - [], - {#salesOrderPk: salesOrderPk}, - ), - )), - ) as _i8.Future<_i4.Payable>); - @override - _i8.Future<_i4.Payable> thaliaPaySalesOrder( - {required String? salesOrderPk}) => - (super.noSuchMethod( - Invocation.method( - #thaliaPaySalesOrder, - [], - {#salesOrderPk: salesOrderPk}, - ), - returnValue: _i8.Future<_i4.Payable>.value(_FakePayable_7( - this, - Invocation.method( - #thaliaPaySalesOrder, - [], - {#salesOrderPk: salesOrderPk}, - ), - )), - ) as _i8.Future<_i4.Payable>); - @override - _i8.Future<_i4.Member> getMember({required int? pk}) => (super.noSuchMethod( - Invocation.method( - #getMember, - [], - {#pk: pk}, - ), - returnValue: _i8.Future<_i4.Member>.value(_FakeMember_11( - this, - Invocation.method( - #getMember, - [], - {#pk: pk}, - ), - )), - ) as _i8.Future<_i4.Member>); - @override - _i8.Future<_i4.ListResponse<_i4.ListMember>> getMembers({ - String? search, - int? limit, - int? offset, - String? ordering, - }) => - (super.noSuchMethod( - Invocation.method( - #getMembers, - [], - { - #search: search, - #limit: limit, - #offset: offset, - #ordering: ordering, - }, - ), - returnValue: _i8.Future<_i4.ListResponse<_i4.ListMember>>.value( - _FakeListResponse_3<_i4.ListMember>( - this, - Invocation.method( - #getMembers, - [], - { - #search: search, - #limit: limit, - #offset: offset, - #ordering: ordering, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.ListMember>>); - @override - _i8.Future<_i4.FullMember> getMe() => (super.noSuchMethod( - Invocation.method( - #getMe, - [], - ), - returnValue: _i8.Future<_i4.FullMember>.value(_FakeFullMember_12( - this, - Invocation.method( - #getMe, - [], - ), - )), - ) as _i8.Future<_i4.FullMember>); - @override - _i8.Future updateAvatar(String? file) => (super.noSuchMethod( - Invocation.method( - #updateAvatar, - [file], - ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); - @override - _i8.Future updateDescription(String? description) => - (super.noSuchMethod( - Invocation.method( - #updateDescription, - [description], - ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); - @override - _i8.Future<_i4.Album> getAlbum({required String? slug}) => - (super.noSuchMethod( - Invocation.method( - #getAlbum, - [], - {#slug: slug}, - ), - returnValue: _i8.Future<_i4.Album>.value(_FakeAlbum_13( - this, - Invocation.method( - #getAlbum, - [], - {#slug: slug}, - ), - )), - ) as _i8.Future<_i4.Album>); - @override - _i8.Future updateLiked( - int? id, - bool? liked, - ) => - (super.noSuchMethod( - Invocation.method( - #updateLiked, - [ - id, - liked, - ], - ), - returnValue: _i8.Future.value(), - returnValueForMissingStub: _i8.Future.value(), - ) as _i8.Future); - @override - _i8.Future<_i4.ListResponse<_i4.ListAlbum>> getAlbums({ - String? search, - int? limit, - int? offset, - }) => - (super.noSuchMethod( - Invocation.method( - #getAlbums, - [], - { - #search: search, - #limit: limit, - #offset: offset, - }, - ), - returnValue: _i8.Future<_i4.ListResponse<_i4.ListAlbum>>.value( - _FakeListResponse_3<_i4.ListAlbum>( - this, - Invocation.method( - #getAlbums, - [], - { - #search: search, - #limit: limit, - #offset: offset, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.ListAlbum>>); - @override - _i8.Future<_i4.ListResponse<_i4.Slide>> getSlides({ - int? limit, - int? offset, - }) => - (super.noSuchMethod( - Invocation.method( - #getSlides, - [], - { - #limit: limit, - #offset: offset, - }, - ), - returnValue: _i8.Future<_i4.ListResponse<_i4.Slide>>.value( - _FakeListResponse_3<_i4.Slide>( - this, - Invocation.method( - #getSlides, - [], - { - #limit: limit, - #offset: offset, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.Slide>>); - @override - _i8.Future<_i4.ListResponse<_i4.FrontpageArticle>> getFrontpageArticles({ - int? limit, - int? offset, - }) => - (super.noSuchMethod( - Invocation.method( - #getFrontpageArticles, - [], - { - #limit: limit, - #offset: offset, - }, - ), - returnValue: _i8.Future<_i4.ListResponse<_i4.FrontpageArticle>>.value( - _FakeListResponse_3<_i4.FrontpageArticle>( - this, - Invocation.method( - #getFrontpageArticles, - [], - { - #limit: limit, - #offset: offset, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.FrontpageArticle>>); - @override - _i8.Future<_i4.Device> registerDevice({ - required String? token, - required String? type, - bool? active = true, - }) => - (super.noSuchMethod( - Invocation.method( - #registerDevice, - [], - { - #token: token, - #type: type, - #active: active, - }, - ), - returnValue: _i8.Future<_i4.Device>.value(_FakeDevice_14( - this, - Invocation.method( - #registerDevice, - [], - { - #token: token, - #type: type, - #active: active, - }, - ), - )), - ) as _i8.Future<_i4.Device>); - @override - _i8.Future<_i4.Device> getDevice({required int? pk}) => (super.noSuchMethod( - Invocation.method( - #getDevice, - [], - {#pk: pk}, - ), - returnValue: _i8.Future<_i4.Device>.value(_FakeDevice_14( - this, - Invocation.method( - #getDevice, - [], - {#pk: pk}, - ), - )), - ) as _i8.Future<_i4.Device>); - @override - _i8.Future<_i4.Device> disableDevice({required int? pk}) => - (super.noSuchMethod( - Invocation.method( - #disableDevice, - [], - {#pk: pk}, - ), - returnValue: _i8.Future<_i4.Device>.value(_FakeDevice_14( - this, - Invocation.method( - #disableDevice, - [], - {#pk: pk}, - ), - )), - ) as _i8.Future<_i4.Device>); - @override - _i8.Future<_i4.Device> updateDeviceToken({ - required int? pk, - required String? token, - }) => - (super.noSuchMethod( - Invocation.method( - #updateDeviceToken, - [], - { - #pk: pk, - #token: token, - }, - ), - returnValue: _i8.Future<_i4.Device>.value(_FakeDevice_14( - this, - Invocation.method( - #updateDeviceToken, - [], - { - #pk: pk, - #token: token, - }, - ), - )), - ) as _i8.Future<_i4.Device>); - @override - _i8.Future<_i4.Device> updateDeviceReceiveCategory({ - required int? pk, - required List? receiveCategory, - }) => - (super.noSuchMethod( - Invocation.method( - #updateDeviceReceiveCategory, - [], - { - #pk: pk, - #receiveCategory: receiveCategory, - }, - ), - returnValue: _i8.Future<_i4.Device>.value(_FakeDevice_14( - this, - Invocation.method( - #updateDeviceReceiveCategory, - [], - { - #pk: pk, - #receiveCategory: receiveCategory, - }, - ), - )), - ) as _i8.Future<_i4.Device>); - @override - _i8.Future<_i4.ListResponse<_i4.PushNotificationCategory>> getCategories() => - (super.noSuchMethod( - Invocation.method( - #getCategories, - [], - ), - returnValue: - _i8.Future<_i4.ListResponse<_i4.PushNotificationCategory>>.value( - _FakeListResponse_3<_i4.PushNotificationCategory>( - this, - Invocation.method( - #getCategories, - [], - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.PushNotificationCategory>>); - @override - _i8.Future<_i4.SalesOrder> claimSalesOrder({required String? pk}) => - (super.noSuchMethod( - Invocation.method( - #claimSalesOrder, - [], - {#pk: pk}, - ), - returnValue: _i8.Future<_i4.SalesOrder>.value(_FakeSalesOrder_15( - this, - Invocation.method( - #claimSalesOrder, - [], - {#pk: pk}, - ), - )), - ) as _i8.Future<_i4.SalesOrder>); - @override - _i8.Future<_i4.ListResponse<_i4.ListGroup>> getGroups({ - int? limit, - int? offset, - _i4.MemberGroupType? type, - DateTime? start, - DateTime? end, - String? search, - }) => - (super.noSuchMethod( - Invocation.method( - #getGroups, - [], - { - #limit: limit, - #offset: offset, - #type: type, - #start: start, - #end: end, - #search: search, - }, - ), - returnValue: _i8.Future<_i4.ListResponse<_i4.ListGroup>>.value( - _FakeListResponse_3<_i4.ListGroup>( - this, - Invocation.method( - #getGroups, - [], - { - #limit: limit, - #offset: offset, - #type: type, - #start: start, - #end: end, - #search: search, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.ListGroup>>); - @override - _i8.Future<_i4.Group> getGroup({required int? pk}) => (super.noSuchMethod( - Invocation.method( - #getGroup, - [], - {#pk: pk}, - ), - returnValue: _i8.Future<_i4.Group>.value(_FakeGroup_16( - this, - Invocation.method( - #getGroup, - [], - {#pk: pk}, - ), - )), - ) as _i8.Future<_i4.Group>); - @override - _i8.Future<_i4.Group> getGroupBySlug({ - required _i4.MemberGroupType? type, - required String? slug, - }) => - (super.noSuchMethod( - Invocation.method( - #getGroupBySlug, - [], - { - #type: type, - #slug: slug, - }, - ), - returnValue: _i8.Future<_i4.Group>.value(_FakeGroup_16( - this, - Invocation.method( - #getGroupBySlug, - [], - { - #type: type, - #slug: slug, - }, - ), - )), - ) as _i8.Future<_i4.Group>); - @override - _i8.Future<_i4.ListResponse<_i4.AlbumPhoto>> getLikedPhotos({ - int? limit, - int? offset, - }) => - (super.noSuchMethod( - Invocation.method( - #getLikedPhotos, - [], - { - #limit: limit, - #offset: offset, - }, - ), - returnValue: _i8.Future<_i4.ListResponse<_i4.AlbumPhoto>>.value( - _FakeListResponse_3<_i4.AlbumPhoto>( - this, - Invocation.method( - #getLikedPhotos, + #getLikedPhotos, [], { #limit: limit, @@ -1518,46 +389,4 @@ class MockApiRepository extends _i1.Mock implements _i5.ApiRepository { ), )), ) as _i8.Future<_i4.ListResponse<_i4.AlbumPhoto>>); - @override - _i8.Future<_i4.ListResponse<_i4.Payment>> getPayments({ - int? limit, - int? offset, - String? ordering, - DateTime? start, - DateTime? end, - List<_i4.PaymentType>? type, - bool? settled, - }) => - (super.noSuchMethod( - Invocation.method( - #getPayments, - [], - { - #limit: limit, - #offset: offset, - #ordering: ordering, - #start: start, - #end: end, - #type: type, - #settled: settled, - }, - ), - returnValue: _i8.Future<_i4.ListResponse<_i4.Payment>>.value( - _FakeListResponse_3<_i4.Payment>( - this, - Invocation.method( - #getPayments, - [], - { - #limit: limit, - #offset: offset, - #ordering: ordering, - #start: start, - #end: end, - #type: type, - #settled: settled, - }, - ), - )), - ) as _i8.Future<_i4.ListResponse<_i4.Payment>>); }