-
Notifications
You must be signed in to change notification settings - Fork 100
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 #1829 from kwgong/upgrade/occuspace-api
Upgrade/occuspace api
- Loading branch information
Showing
11 changed files
with
345 additions
and
172 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,129 @@ | ||
// To parse this JSON data, do | ||
// | ||
// final availabilityStatus = availabilityStatusFromJson(jsonString); | ||
|
||
import 'dart:convert'; | ||
|
||
List<AvailabilityModel> availabilityModelFromJson(String str) { | ||
var jsonStr = json.decode(str)['data']['children']; | ||
return List<AvailabilityModel>.from( | ||
jsonStr.map((x) => AvailabilityModel.fromJson(x))); | ||
AvailabilityStatus availabilityStatusFromJson(String str) => | ||
AvailabilityStatus.fromJson(json.decode(str)); | ||
|
||
String availabilityStatusToJson(AvailabilityStatus data) => | ||
json.encode(data.toJson()); | ||
|
||
class AvailabilityStatus { | ||
AvailabilityStatus({ | ||
this.status, | ||
this.data, | ||
this.timestamp, | ||
}); | ||
|
||
String? status; | ||
List<AvailabilityModel>? data; | ||
DateTime? timestamp; | ||
|
||
factory AvailabilityStatus.fromJson(Map<String, dynamic> json) => | ||
AvailabilityStatus( | ||
status: json["status"] == null ? null : json["status"], | ||
data: json["data"] == null | ||
? null | ||
: List<AvailabilityModel>.from( | ||
json["data"].map((x) => AvailabilityModel.fromJson(x))), | ||
timestamp: json["timestamp"] == null | ||
? null | ||
: DateTime.parse(json["timestamp"]), | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"status": status == null ? null : status, | ||
"data": data == null | ||
? null | ||
: List<dynamic>.from(data!.map((x) => x.toJson())), | ||
"timestamp": timestamp == null ? null : timestamp!.toIso8601String(), | ||
}; | ||
} | ||
|
||
class AvailabilityModel { | ||
int? locationId; | ||
bool? isOpen; | ||
bool? isError; | ||
double? percent; | ||
String? locationName; | ||
List<AvailabilityModel>? subLocations; | ||
|
||
AvailabilityModel( | ||
{this.locationId, | ||
this.isOpen, | ||
this.isError, | ||
this.percent, | ||
this.locationName, | ||
this.subLocations}); | ||
AvailabilityModel({ | ||
this.id, | ||
this.name, | ||
this.subLocations, | ||
}); | ||
|
||
int? id; | ||
String? name; | ||
List<SubLocations>? subLocations; | ||
|
||
factory AvailabilityModel.fromJson(Map<String, dynamic> json) => | ||
AvailabilityModel( | ||
locationId: json["id"] == null ? null : json["id"], | ||
isOpen: json["isOpen"] == null ? null : json["isOpen"], | ||
isError: json["isError"] == null ? null : json["isError"], | ||
locationName: json["name"] == null ? null : json["name"], | ||
percent: json["percent"] == null ? null : json["percent"].toDouble(), | ||
subLocations: json["children"] == null | ||
id: json["id"] == null ? null : json["id"], | ||
name: json["name"] == null ? null : json["name"], | ||
subLocations: json["childCounts"] == null | ||
? null | ||
: List<AvailabilityModel>.from( | ||
json["children"].map((x) => AvailabilityModel.fromJson(x))), | ||
: List<SubLocations>.from( | ||
json["childCounts"].map((x) => SubLocations.fromJson(x))), | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"locationId": locationId == null ? null : locationId, | ||
"locationName": locationName == null ? null : locationName, | ||
"isOpen": isOpen == null ? null : isOpen, | ||
"isError": isError == null ? null : isError, | ||
"percent": percent == null ? null : percent.toString(), | ||
"children": subLocations == null | ||
"id": id == null ? null : id, | ||
"name": name == null ? null : name, | ||
"childCounts": subLocations == null | ||
? null | ||
: List<dynamic>.from(subLocations!.map((x) => x.toJson())), | ||
}; | ||
} | ||
|
||
class SubLocations { | ||
SubLocations( | ||
{this.id, this.name, this.percentage, this.isActive, this.floors}); | ||
|
||
int? id; | ||
String? name; | ||
double? percentage; | ||
bool? isActive; | ||
List<Floor>? floors; | ||
|
||
factory SubLocations.fromJson(Map<String, dynamic> json) => SubLocations( | ||
id: json["id"] == null ? null : json["id"], | ||
name: json["name"] == null ? null : json["name"], | ||
percentage: | ||
json["percentage"] == null ? null : json["percentage"].toDouble(), | ||
isActive: json["isActive"] == null ? null : json["isActive"], | ||
floors: json["childCounts"] == null | ||
? null | ||
: List<Floor>.from( | ||
json["childCounts"].map((x) => Floor.fromJson(x)))); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"id": id == null ? null : id, | ||
"name": name == null ? null : name, | ||
"percentage": percentage == null ? null : percentage, | ||
"isActive": isActive == null ? null : isActive, | ||
"floors": floors == null ? null : floors | ||
}; | ||
} | ||
|
||
class Floor { | ||
Floor({this.id, this.name, this.count, this.percentage, this.isActive}); | ||
|
||
int? id; | ||
String? name; | ||
int? count; | ||
double? percentage; | ||
bool? isActive; | ||
|
||
factory Floor.fromJson(Map<String, dynamic> json) => Floor( | ||
id: json["id"] == null ? null : json["id"], | ||
name: json["name"] == null ? null : json["name"], | ||
count: json["count"] == null ? null : json["count"], | ||
percentage: | ||
json["percentage"] == null ? null : json["percentage"].toDouble(), | ||
isActive: json["isActive"] == null ? null : json["isActive"], | ||
); | ||
|
||
Map<String, dynamic> toJson() => { | ||
"id": id == null ? null : id, | ||
"name": name == null ? null : name, | ||
"percentage": percentage == null ? null : percentage, | ||
"isActive": isActive == null ? null : isActive, | ||
}; | ||
} |
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
Oops, something went wrong.