-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workflow): handle the creation of workflow
- Loading branch information
1 parent
18a059a
commit 459bf8f
Showing
11 changed files
with
191 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:client_mobile/data/action.dart'; | ||
import 'package:flutter/gestures.dart'; | ||
|
||
class WorkflowEvent | ||
{ | ||
final WorkflowActionReaction action; | ||
final String type; | ||
|
||
WorkflowEvent({ | ||
required this.action, | ||
required this.type | ||
}); | ||
} | ||
|
||
|
||
class Workflow { | ||
final String name; | ||
final String description; | ||
final List<int> servicesId; | ||
final List<WorkflowEvent> events; | ||
|
||
Workflow({ | ||
required this.name, | ||
required this.description, | ||
required this.servicesId, | ||
required this.events, | ||
}); | ||
|
||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'name': name, | ||
'description': description, | ||
'services': servicesId, | ||
'events': events.map((a) => a.action.toJson(a.type)).toList(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'dart:convert'; | ||
import 'package:client_mobile/data/workflow.dart'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
class CreateWorkflowService { | ||
static const FlutterSecureStorage secureStorage = FlutterSecureStorage(); | ||
|
||
static String baseUrl = | ||
dotenv.env["BACKEND_BASE_URL"] ?? "http://127.0.0.1:8080"; | ||
|
||
static Future<bool> createWorkflow(Workflow workflow) async { | ||
final String? token = await secureStorage.read(key: 'bearer_token'); | ||
|
||
print("bearer token : $token"); | ||
final response = await http.post(Uri.parse('$baseUrl/workflow/create'), | ||
headers: { | ||
'Authorization': 'Bearer $token', | ||
'Content-Type': 'application/json' | ||
}, | ||
body: jsonEncode(workflow.toJson())); | ||
|
||
return (response.statusCode == 200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters