-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added google geocoding to get city/state/country #83
Open
oianmol
wants to merge
12
commits into
designs_v1.1
Choose a base branch
from
DEV-211
base: designs_v1.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
07e7398
added google geocoding to get city/state/country
anmolvermamm 9209333
Airtable API Integration, Also adds DotEnv for API Keys
tsjamm 8bbbfb1
fixes a decoding issue
tsjamm 511762b
Fixes Handling Airtable Response Data
tsjamm 28da6d6
remove location from user api and check for location gate in location…
anmolvermamm c0eb2a2
Changes API to return true or false for a location string
tsjamm 6b600c1
add location to user API
anmolvermamm a3edc8a
Fixes a bug in query
tsjamm 6599478
Merge branch 'DEV-211' into airtable-integration
anmolvermamm fb34a77
Merge pull request #84 from Corona-Trace/airtable-integration
oianmol 960f8ba
check with city if location gate available
anmolvermamm 1237d3d
disable minification because build failing
anmolvermamm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
.buildlog/ | ||
.history | ||
.svn/ | ||
.env* | ||
|
||
# IntelliJ related | ||
*.iml | ||
|
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,30 @@ | ||
import 'package:corona_trace/network/airtable/airtable_record_fields.dart'; | ||
|
||
class AirtableRecord { | ||
String _id; | ||
AirtableRecordFields _fields; | ||
String _createdTime; | ||
|
||
String get id => _id; | ||
|
||
AirtableRecordFields get fields => _fields; | ||
|
||
String get createdTime => _createdTime; | ||
|
||
AirtableRecord( | ||
this._id, this._fields, this._createdTime); | ||
|
||
AirtableRecord.map(dynamic obj) { | ||
_id = obj["id"]; | ||
_fields = AirtableRecordFields.map(obj["fields"]); | ||
_createdTime = obj["createdTime"]; | ||
} | ||
|
||
Map<String, dynamic> toMap() { | ||
var map = <String, dynamic>{}; | ||
map["Id"] = _id; | ||
map["fields"] = _fields; | ||
map["createdTime"] = _createdTime; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
class AirtableRecordFields { | ||
String _name; | ||
|
||
String get name => _name; | ||
|
||
AirtableRecordFields( | ||
this._name); | ||
|
||
AirtableRecordFields.map(dynamic obj) { | ||
_name = obj["Name"]; | ||
} | ||
|
||
Map<String, dynamic> toMap() { | ||
var map = <String, dynamic>{}; | ||
map["Name"] = _name; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import 'dart:convert' as JSON; | ||
|
||
import 'package:corona_trace/analytics/CTAnalyticsManager.dart'; | ||
import 'package:corona_trace/app_constants.dart'; | ||
import 'package:corona_trace/network/airtable/airtable_response.dart'; | ||
import 'package:corona_trace/network/notification/response_notification.dart'; | ||
import 'package:dio/dio.dart'; | ||
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
import 'package:http/http.dart' as http; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
class AirtableRepository { | ||
static final AirtableRepository _instance = AirtableRepository._internal(); | ||
|
||
factory AirtableRepository() => _instance; | ||
|
||
static AirtableRepository get instance => _instance; | ||
|
||
AirtableRepository._internal(); | ||
|
||
static BaseOptions dioOptions = | ||
new BaseOptions( | ||
connectTimeout: 15000, | ||
receiveTimeout: 30000, | ||
headers: { | ||
"Authorization":"Bearer ${DotEnv().env['AIRTABLE_API_KEY']}" | ||
}); | ||
static Dio _dio = Dio(dioOptions); | ||
|
||
static const AIRTABLE_API_BASE_URL = "https://api.airtable.com/v0/appeeTR6FdXwMaHYo"; | ||
static const STATES_URL = "$AIRTABLE_API_BASE_URL/States"; | ||
static const COUNTRIES_URL = "$AIRTABLE_API_BASE_URL/Countries"; | ||
static const CITIES_URL = "$AIRTABLE_API_BASE_URL/Cities"; | ||
|
||
static String getAirtableQueryURL(String url, String name) { | ||
return "$url?fields%5B%5D=Name&filterByFormula=AND(%7BAvailability%7D%2C%7BName%7D%3D%22$name%22)"; | ||
} | ||
|
||
static Future<bool> checkIfAvailableInStatesList(String state) async { | ||
try { | ||
var url = getAirtableQueryURL(STATES_URL, state); | ||
Response response = await _dio.get(url); | ||
var statusCode = response.statusCode; | ||
debugPrint("$statusCode - $url"); | ||
var records = AirtableResponse.map(response.data).records; | ||
return records.isNotEmpty; | ||
} catch (ex) { | ||
debugPrint('checkIfAvailableInStatesList Failed: $ex'); | ||
throw ex; | ||
} | ||
} | ||
|
||
static Future<bool> checkIfAvailableInCountriesList(String country) async { | ||
try { | ||
var url = getAirtableQueryURL(COUNTRIES_URL, country); | ||
Response response = await _dio.get(url); | ||
var statusCode = response.statusCode; | ||
debugPrint("$statusCode - $url"); | ||
var records = AirtableResponse.map(response.data).records; | ||
return records.isNotEmpty; | ||
} catch (ex) { | ||
debugPrint('checkIfAvailableInCountriesList Failed: $ex'); | ||
throw ex; | ||
} | ||
} | ||
|
||
static Future<bool> checkIfAvailableInCitiesList(String city) async { | ||
try { | ||
var url = getAirtableQueryURL(CITIES_URL, city); | ||
Response response = await _dio.get(url); | ||
var statusCode = response.statusCode; | ||
debugPrint("$statusCode - $url"); | ||
var records = AirtableResponse.map(response.data).records; | ||
return records.isNotEmpty; | ||
} catch (ex) { | ||
debugPrint('checkIfAvailableInCitiesList Failed: $ex'); | ||
throw ex; | ||
} | ||
} | ||
} |
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,27 @@ | ||
import 'package:corona_trace/network/airtable/airtable_record.dart'; | ||
|
||
class AirtableResponse { | ||
List<AirtableRecord> _records; | ||
String _offset; | ||
|
||
List<AirtableRecord> get records => _records; | ||
|
||
String get offset => _offset; | ||
|
||
AirtableResponse(this._records, this._offset); | ||
|
||
AirtableResponse.map(dynamic obj) { | ||
_records = obj["records"] == null | ||
? null | ||
: new List<AirtableRecord>.from( | ||
obj["records"].map((x) => AirtableRecord.map(x))); | ||
_offset = obj["offset"] ?? ""; | ||
} | ||
|
||
Map<String, dynamic> toMap() { | ||
var map = <String, dynamic>{}; | ||
map["records"] = _records; | ||
map["offset"] = _offset; | ||
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice name 😅 How about LocationGateTriple