Skip to content

Commit

Permalink
Merge pull request #3 from DonnC/extra_features
Browse files Browse the repository at this point in the history
End User Balance
  • Loading branch information
iamngoni authored Mar 16, 2021
2 parents f7ac411 + 3361849 commit 9edf83e
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 75 deletions.
12 changes: 7 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class _MyHomePageState extends State<MyHomePage> {
}

void showSnackbar(String message, Color color) {
scaffoldKey.currentState.showSnackBar(
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: color,
content: Text(message),
Expand Down Expand Up @@ -139,11 +139,13 @@ class _MyHomePageState extends State<MyHomePage> {
SizedBox(height: 30),
loading
? CircularProgressIndicator()
: FlatButton(
: Container(
color: Colors.blue,
onPressed: () async => await rechargeNumber(),
child: Text(
'Recharge',
child: TextButton(
onPressed: () async => await rechargeNumber(),
child: Text(
'Recharge',
),
),
),
],
Expand Down
51 changes: 22 additions & 29 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,49 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.1"
version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.3"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "1.15.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
version: "3.0.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -70,7 +63,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -115,28 +108,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.1"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
version: "1.8.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.2"
version: "1.11.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -148,63 +141,63 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.2"
version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.2"
version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.2"
version: "3.0.1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0"
sdks:
dart: ">=2.10.0-110 <2.11.0"
dart: ">=2.12.0-0.0 <3.0.0"
flutter: ">=1.17.0"
7 changes: 7 additions & 0 deletions lib/src/hot_recharge.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/foundation.dart';
import 'package:hot_recharge/hot_recharge.dart';

import 'models/index.dart';
import 'services/api.dart';
Expand Down Expand Up @@ -161,4 +162,10 @@ class HotRecharge {

return queryZesa;
}

/// Query airtime balance for a specific user using their mobile number
Future<ApiResponse> _endUserBalance(String mobileNumber) async {
final userBalance = _api.endUserBalance(mobileNumber);
return userBalance;
}
}
3 changes: 2 additions & 1 deletion lib/src/models/api_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ class ApiResponse {
});

@override
String toString() => 'ApiResponse(rechargeResponse: $rechargeResponse, apiResponse: $apiResponse, message: $message)';
String toString() =>
'ApiResponse(rechargeResponse: $rechargeResponse, apiResponse: $apiResponse, message: $message)';
}
46 changes: 46 additions & 0 deletions lib/src/models/end_user_balance.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'dart:convert';

class EndUserBalance {
final int replyCode;
final String replyMsg;
final double mobileBalance;
final String windowPeriod;
final String agentReference;
EndUserBalance({
this.replyCode,
this.replyMsg,
this.mobileBalance,
this.windowPeriod,
this.agentReference,
});

Map<String, dynamic> toMap() {
return {
'ReplyCode': replyCode,
'ReplyMsg': replyMsg,
'MobileBalance': mobileBalance,
'WindowPeriod': windowPeriod,
'AgentReference': agentReference,
};
}

factory EndUserBalance.fromMap(Map<String, dynamic> map) {
return EndUserBalance(
replyCode: map['ReplyCode']?.toInt(),
replyMsg: map['ReplyMsg'],
mobileBalance: map['MobileBalance']?.toDouble(),
windowPeriod: map['WindowPeriod'],
agentReference: map['AgentReference'],
);
}

String toJson() => json.encode(toMap());

factory EndUserBalance.fromJson(String source) =>
EndUserBalance.fromMap(json.decode(source));

@override
String toString() {
return 'EndUserBalance(ReplyCode: $replyCode, ReplyMsg: $replyMsg, MobileBalance: $mobileBalance, WindowPeriod: $windowPeriod, AgentReference: $agentReference)';
}
}
1 change: 1 addition & 0 deletions lib/src/models/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export 'zesa_customer_detail.dart';
export 'zesa_recharge.dart';
export 'zesa_token.dart';
export 'zesa_wallet_balance.dart';
export 'end_user_balance.dart';
Loading

0 comments on commit 9edf83e

Please sign in to comment.