LCOV - code coverage report
Current view: top level - lib\data\remote\requests\chatwoot_action_data.dart - chatwoot_action_data.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 6 15 40.0 %
Date: Thu Jul 15 17:16:16 2021 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:json_annotation/json_annotation.dart';
       2             : 
       3             : part 'chatwoot_action_data.g.dart';
       4             : 
       5             : @JsonSerializable(explicitToJson: true)
       6             : class ChatwootActionData {
       7             :   @JsonKey(toJson: actionTypeToJson, fromJson: actionTypeFromJson)
       8             :   final ChatwootActionType action;
       9             : 
      10           1 :   ChatwootActionData({required this.action});
      11             : 
      12           0 :   factory ChatwootActionData.fromJson(Map<String, dynamic> json) =>
      13           0 :       _$ChatwootActionDataFromJson(json);
      14             : 
      15           2 :   Map<String, dynamic> toJson() => _$ChatwootActionDataToJson(this);
      16             : }
      17             : 
      18          15 : enum ChatwootActionType {
      19             :   subscribe,
      20             :   update_presence,
      21             :   conversation_typing_on,
      22             :   conversation_typing_off
      23             : }
      24             : 
      25           1 : String actionTypeToJson(ChatwootActionType actionType) {
      26             :   switch (actionType) {
      27           1 :     case ChatwootActionType.conversation_typing_off:
      28             :       return "conversation.typing_off";
      29           1 :     case ChatwootActionType.conversation_typing_on:
      30             :       return "conversation.typing_on";
      31           0 :     case ChatwootActionType.update_presence:
      32             :       return "update_presence";
      33           0 :     case ChatwootActionType.subscribe:
      34             :       return "subscribe";
      35             :   }
      36             : }
      37             : 
      38           0 : ChatwootActionType actionTypeFromJson(String? value) {
      39             :   switch (value) {
      40           0 :     case "conversation.typing_on":
      41             :       return ChatwootActionType.conversation_typing_on;
      42           0 :     case "conversation.typing_off":
      43             :       return ChatwootActionType.conversation_typing_on;
      44           0 :     case "update_presence":
      45             :       return ChatwootActionType.update_presence;
      46           0 :     case "subscribe":
      47             :       return ChatwootActionType.subscribe;
      48             :     default:
      49             :       return ChatwootActionType.update_presence;
      50             :   }
      51             : }

Generated by: LCOV version 1.15.alpha0w