-
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.
Merge pull request #5 from ecency/nt/polls-support
Nt/polls support
- Loading branch information
Showing
27 changed files
with
1,644 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
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
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,45 @@ | ||
|
||
|
||
import 'package:http/http.dart' as http; | ||
import 'package:waves/core/models/action_response.dart'; | ||
import 'package:waves/core/services/poll_service/poll_model.dart'; | ||
import 'package:waves/core/utilities/enum.dart'; | ||
|
||
|
||
/// | ||
/// swapper importable api url | ||
/// https://polls-beta.hivehub.dev/ | ||
/// | ||
/// hive polls docs reference: | ||
/// https://gitlab.com/peakd/hive-open-polls | ||
/// | ||
Future<ActionSingleDataResponse<PollModel>> fetchPoll( | ||
String author, | ||
String permlink | ||
) async { | ||
try { | ||
var url = Uri.parse( | ||
"https://polls.hivehub.dev/rpc/poll?author=eq.$author&permlink=eq.$permlink"); | ||
|
||
|
||
|
||
http.Response response = await http.get( | ||
url, | ||
); | ||
|
||
if (response.statusCode == 200) { | ||
return ActionSingleDataResponse<PollModel>( | ||
data: PollModel.fromJsonString(response.body).first, | ||
status: ResponseStatus.success, | ||
isSuccess: true, | ||
errorMessage: ""); | ||
} else { | ||
return ActionSingleDataResponse( | ||
status: ResponseStatus.failed, errorMessage: "Server Error"); | ||
} | ||
} catch (e) { | ||
return ActionSingleDataResponse( | ||
status: ResponseStatus.failed, errorMessage: e.toString()); | ||
} | ||
} |
Oops, something went wrong.