-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: repositoty and remote data sources for the uploading thumbnail
- Loading branch information
Showing
11 changed files
with
199 additions
and
26 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
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,111 @@ | ||
import 'package:evently/services/third_party_services/quick_node.dart'; | ||
|
||
class StorageResponseModel { | ||
bool? ok; | ||
Value? value; | ||
|
||
StorageResponseModel({this.ok, this.value}); | ||
|
||
StorageResponseModel.fromJson(Map<String, dynamic> json) { | ||
ok = json['ok'] as bool?; | ||
value = json['value'] != null ? Value.fromJson(json['value'] as Map<String, dynamic>) : null; | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final map = <String, dynamic>{}; | ||
map['ok'] = ok; | ||
if (value != null) { | ||
map['value'] = value?.toJson(); | ||
} | ||
return map; | ||
} | ||
|
||
factory StorageResponseModel.initial() { | ||
return StorageResponseModel(); | ||
} | ||
|
||
factory StorageResponseModel.fromQuickNode({required UploadIPFSOutput uploadIPFSOutput}) { | ||
return StorageResponseModel( | ||
ok: true, | ||
value: Value( | ||
cid: uploadIPFSOutput.pin?.cid, | ||
created: uploadIPFSOutput.created, | ||
size: int.parse( | ||
uploadIPFSOutput.info?.size ?? '0', | ||
), | ||
pin: Pin( | ||
cid: uploadIPFSOutput.pin?.cid, | ||
created: uploadIPFSOutput.created, | ||
size: int.parse( | ||
uploadIPFSOutput.info?.size ?? '0', | ||
), | ||
status: uploadIPFSOutput.status, | ||
)), | ||
); | ||
} | ||
} | ||
|
||
class Value { | ||
String? cid; | ||
String? created; | ||
String? type; | ||
String? scope; | ||
int? size; | ||
Pin? pin; | ||
|
||
Value({ | ||
this.cid, | ||
this.created, | ||
this.type, | ||
this.scope, | ||
this.size, | ||
this.pin, | ||
}); | ||
|
||
Value.fromJson(Map<String, dynamic> json) { | ||
cid = json['cid'] as String?; | ||
created = json['created'] as String?; | ||
type = json['type'] as String?; | ||
scope = json['scope'] as String?; | ||
size = json['size'] as int?; | ||
pin = json['pin'] != null ? Pin.fromJson(json['pin'] as Map<String, dynamic>) : null; | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final map = <String, dynamic>{}; | ||
map['cid'] = cid; | ||
map['created'] = created; | ||
map['type'] = type; | ||
map['scope'] = scope; | ||
map['size'] = size; | ||
if (pin != null) { | ||
map['pin'] = pin?.toJson(); | ||
} | ||
return map; | ||
} | ||
} | ||
|
||
class Pin { | ||
String? cid; | ||
String? created; | ||
int? size; | ||
String? status; | ||
|
||
Pin({this.cid, this.created, this.size, this.status}); | ||
|
||
Pin.fromJson(Map<String, dynamic> json) { | ||
cid = json['cid'] as String?; | ||
created = json['created'] as String?; | ||
size = json['size'] as int?; | ||
status = json['status'] as String?; | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final map = <String, dynamic>{}; | ||
map['cid'] = cid; | ||
map['created'] = created; | ||
map['size'] = size; | ||
map['status'] = status; | ||
return map; | ||
} | ||
} |
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,23 @@ | ||
import 'package:evently/models/storage_response_model.dart'; | ||
import 'package:evently/services/third_party_services/quick_node.dart'; | ||
import 'package:injectable/injectable.dart'; | ||
|
||
abstract class RemoteDataSource { | ||
/// This method is used uploading provided file to the server using [QuickNode] | ||
/// Input : [UploadIPFSInput] which needs to be uploaded | ||
/// Output : [Future<ApiResponse<StorageResponseModel>>] the ApiResponse which can contain [success] or [error] response | ||
Future<StorageResponseModel> uploadFileUsingQuickNode({required UploadIPFSInput uploadIPFSInput, required OnUploadProgressCallback onUploadProgressCallback}); | ||
} | ||
|
||
@LazySingleton(as: RemoteDataSource) | ||
class RemoteDataSourceImpl extends RemoteDataSource { | ||
RemoteDataSourceImpl({required this.quickNode}); | ||
|
||
final QuickNode quickNode; | ||
|
||
@override | ||
Future<StorageResponseModel> uploadFileUsingQuickNode({required UploadIPFSInput uploadIPFSInput, required OnUploadProgressCallback onUploadProgressCallback}) async { | ||
final response = await quickNode.uploadNewObjectToIPFS(uploadIPFSInput: uploadIPFSInput, onUploadProgressCallback: onUploadProgressCallback); | ||
return response; | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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