Function bodies 338 total
allow function · javascript · L12-L21 (10 LOC)app/firebase/custom_cloud_functions/create_checkout_session.js
function allow(req, res) {
res.set("Access-Control-Allow-Origin", "*");
res.set("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
res.set("Access-Control-Allow-Headers", "Content-Type, Authorization");
if (req.method === "OPTIONS") {
res.status(204).send("");
return true;
}
return false;
}allow function · javascript · L12-L21 (10 LOC)app/firebase/custom_cloud_functions/create_customer.js
function allow(req, res) {
res.set("Access-Control-Allow-Origin", "*");
res.set("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
res.set("Access-Control-Allow-Headers", "Content-Type, Authorization");
if (req.method === "OPTIONS") {
res.status(204).send("");
return true;
}
return false;
}createStripeAPIsGroup function · javascript · L6-L18 (13 LOC)app/firebase/functions/api_manager.js
function createStripeAPIsGroup() {
const stripeKey = process.env.STRIPE_SECRET_KEY;
if (!stripeKey) {
throw new Error('STRIPE_SECRET_KEY environment variable is required');
}
return {
baseUrl: `https://api.stripe.com/v1`,
headers: {
Authorization: `Bearer ${stripeKey}`,
"Content-Type": `application/x-www-form-urlencoded`,
},
};
}_listAllProductsCall function · javascript · L20-L43 (24 LOC)app/firebase/functions/api_manager.js
async function _listAllProductsCall(context, ffVariables) {
if (!context.auth) {
return _unauthenticatedResponse;
}
const stripeAPIsGroup = createStripeAPIsGroup();
var url = `${stripeAPIsGroup.baseUrl}/products`;
var headers = {
Authorization: stripeAPIsGroup.headers.Authorization,
"Content-Type": `application/x-www-form-urlencoded`,
};
var params = {};
var ffApiRequestBody = undefined;
return makeApiRequest({
method: "get",
url,
headers,
params,
returnBody: true,
isStreamingApi: false,
});
}_getPriceCall function · javascript · L45-L68 (24 LOC)app/firebase/functions/api_manager.js
async function _getPriceCall(context, ffVariables) {
if (!context.auth) {
return _unauthenticatedResponse;
}
var priceId = ffVariables["priceId"];
const stripeAPIsGroup = createStripeAPIsGroup();
var url = `${stripeAPIsGroup.baseUrl}/prices/${priceId}`;
var headers = {
Authorization: stripeAPIsGroup.headers.Authorization,
"Content-Type": `application/x-www-form-urlencoded`,
};
var params = {};
var ffApiRequestBody = undefined;
return makeApiRequest({
method: "post",
url,
headers,
params,
returnBody: true,
isStreamingApi: false,
});
}_createCheckoutSessionCall function · javascript · L70-L109 (40 LOC)app/firebase/functions/api_manager.js
async function _createCheckoutSessionCall(context, ffVariables) {
if (!context.auth) {
return _unauthenticatedResponse;
}
var successUrl = ffVariables["successUrl"];
var lineItems0PriceId = ffVariables["lineItems0PriceId"];
var lineItems0Quantity = ffVariables["lineItems0Quantity"];
var customer = ffVariables["customer"];
var token = ffVariables["token"];
const stripeAPIsGroup = createStripeAPIsGroup();
var url = `${stripeAPIsGroup.baseUrl}/checkout/sessions`;
var headers = {
Authorization: stripeAPIsGroup.headers.Authorization,
"Content-Type": `application/x-www-form-urlencoded`,
};
var params = {
success_url: successUrl,
"line_items[0][price]": lineItems0PriceId,
"line_items[0][quantity]": lineItems0Quantity,
mode: `payment`,
customer: customer,
"metadata[token]": token,
};
var ffApiRequestBody = undefined;
return makeApiRequest({
method: "post",
url,
headers,
body: createBody({
headers,
p_getCheckoutSessionCall function · javascript · L111-L134 (24 LOC)app/firebase/functions/api_manager.js
async function _getCheckoutSessionCall(context, ffVariables) {
if (!context.auth) {
return _unauthenticatedResponse;
}
const stripeAPIsGroup = createStripeAPIsGroup();
var url = `${stripeAPIsGroup.baseUrl}/checkout/sessions`;
var headers = {
Authorization: stripeAPIsGroup.headers.Authorization,
"Content-Type": `application/x-www-form-urlencoded`,
};
var params = {};
var ffApiRequestBody = undefined;
return makeApiRequest({
method: "get",
url,
headers,
params,
returnBody: true,
isStreamingApi: false,
});
}Repobility — the code-quality scanner for AI-generated software · https://repobility.com
_createCustomerCall function · javascript · L136-L164 (29 LOC)app/firebase/functions/api_manager.js
async function _createCustomerCall(context, ffVariables) {
if (!context.auth) {
return _unauthenticatedResponse;
}
var email = ffVariables["email"];
const stripeAPIsGroup = createStripeAPIsGroup();
var url = `${stripeAPIsGroup.baseUrl}/customers`;
var headers = {
Authorization: stripeAPIsGroup.headers.Authorization,
"Content-Type": `application/x-www-form-urlencoded`,
};
var params = { email: email };
var ffApiRequestBody = undefined;
return makeApiRequest({
method: "post",
url,
headers,
body: createBody({
headers,
params,
body: ffApiRequestBody,
bodyType: "X_WWW_FORM_URL_ENCODED",
}),
returnBody: true,
isStreamingApi: false,
});
}makeApiCall function · javascript · L170-L192 (23 LOC)app/firebase/functions/api_manager.js
async function makeApiCall(context, data) {
var callName = data["callName"] || "";
var variables = data["variables"] || {};
const callMap = {
ListAllProductsCall: _listAllProductsCall,
GetPriceCall: _getPriceCall,
CreateCheckoutSessionCall: _createCheckoutSessionCall,
GetCheckoutSessionCall: _getCheckoutSessionCall,
CreateCustomerCall: _createCustomerCall,
};
if (!(callName in callMap)) {
return {
statusCode: 400,
error: `API Call "${callName}" not defined as private API.`,
};
}
var apiCall = callMap[callName];
var response = await apiCall(context, variables);
return response;
}makeApiRequest function · javascript · L194-L228 (35 LOC)app/firebase/functions/api_manager.js
async function makeApiRequest({
method,
url,
headers,
params,
body,
returnBody,
isStreamingApi,
}) {
return axios
.request({
method: method,
url: url,
headers: headers,
params: params,
responseType: isStreamingApi ? "stream" : "json",
...(body && { data: body }),
})
.then((response) => {
return {
statusCode: response.status,
headers: response.headers,
...(returnBody && { body: response.data }),
isStreamingApi: isStreamingApi,
};
})
.catch(function (error) {
return {
statusCode: error.response.status,
headers: error.response.headers,
...(returnBody && { body: error.response.data }),
error: error.message,
};
});
}createBody function · javascript · L236-L248 (13 LOC)app/firebase/functions/api_manager.js
function createBody({ headers, params, body, bodyType }) {
switch (bodyType) {
case "JSON":
headers["Content-Type"] = "application/json";
return body;
case "TEXT":
headers["Content-Type"] = "text/plain";
return body;
case "X_WWW_FORM_URL_ENCODED":
headers["Content-Type"] = "application/x-www-form-urlencoded";
return qs.stringify(params);
}
}escapeStringForJson function · javascript · L249-L258 (10 LOC)app/firebase/functions/api_manager.js
function escapeStringForJson(val) {
if (typeof val !== "string") {
return val;
}
return val
.replace(/[\\]/g, "\\\\")
.replace(/["]/g, '\\"')
.replace(/[\n]/g, "\\n")
.replace(/[\t]/g, "\\t");
}handleRequest function · javascript · L19-L34 (16 LOC)app/firebase/functions/index.js
async function handleRequest(req, res) {
cors(req, res, () => {
console.log("Body:", req.body);
let url = req.query.url || req.body.url;
if (!url) {
res.status(403).send("URL is empty.");
}
https.get(url, (resp) => {
res.setHeader(
"content-type",
resp.headers["content-type"] || "image/jpeg",
);
resp.pipe(res);
});
});
}verifyAuthHeader function · javascript · L60-L77 (18 LOC)app/firebase/functions/index.js
async function verifyAuthHeader(request) {
const authorization = request.header("authorization");
if (!authorization) {
return null;
}
const idToken = authorization.includes("Bearer ")
? authorization.split("Bearer ")[1]
: null;
if (!idToken) {
return null;
}
try {
const authResult = await admin.auth().verifyIdToken(idToken);
return authResult;
} catch (err) {
return null;
}
}NotificationService class · swift · L4-L27 (24 LOC)app/ios/ImageNotification/NotificationService.swift
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = request.content
.mutableCopy() as? UNMutableNotificationContent
guard let bestAttemptContent = bestAttemptContent else { return }
FIRMessagingExtensionHelper().populateNotificationContent(
bestAttemptContent,
withContentHandler: contentHandler)
}
override func serviceExtensionTimeWillExpire() {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler =Want fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
FFAppConstants class · dart · L2-L5 (4 LOC)app/lib/app_constants.dart
abstract class FFAppConstants {
static const int zipId = 0;
static const String address = 'a';
}FFAppState class · dart · L3-L52 (50 LOC)app/lib/app_state.dart
class FFAppState extends ChangeNotifier {
static FFAppState _instance = FFAppState._internal();
factory FFAppState() {
return _instance;
}
FFAppState._internal();
static void reset() {
_instance = FFAppState._internal();
}
Future initializePersistedState() async {}
void update(VoidCallback callback) {
callback();
notifyListeners();
}
bool _showFullListFNF = true;
bool get showFullListFNF => _showFullListFNF;
set showFullListFNF(bool value) {
_showFullListFNF = value;
}
bool _export = true;
bool get export => _export;
set export(bool value) {
_export = value;
}
String _customerEmail = '';
String get customerEmail => _customerEmail;
set customerEmail(String value) {
_customerEmail = value;
}
String _stripeCustomerId = '';
String get stripeCustomerId => _stripeCustomerId;
set stripeCustomerId(String value) {
_stripeCustomerId = value;
}
dynamic _selectedProduct;
dynamic get selectedProduct => _AuthManager class · dart · L5-L12 (8 LOC)app/lib/auth/auth_manager.dart
abstract class AuthManager {
Future signOut();
Future deleteUser(BuildContext context);
Future updateEmail({required String email, required BuildContext context});
Future resetPassword({required String email, required BuildContext context});
Future sendEmailVerification() async => currentUser?.sendEmailVerification();
Future refreshUser() async => currentUser?.refreshUser();
}AuthUserInfo class · dart · L1-L15 (15 LOC)app/lib/auth/base_auth_user_provider.dart
class AuthUserInfo {
const AuthUserInfo({
this.uid,
this.email,
this.displayName,
this.photoUrl,
this.phoneNumber,
});
final String? uid;
final String? email;
final String? displayName;
final String? photoUrl;
final String? phoneNumber;
}BaseAuthUser class · dart · L17-L34 (18 LOC)app/lib/auth/base_auth_user_provider.dart
abstract class BaseAuthUser {
bool get loggedIn;
bool get emailVerified;
AuthUserInfo get authUserInfo;
Future? delete();
Future? updateEmail(String email);
Future? updatePassword(String newPassword);
Future? sendEmailVerification();
Future refreshUser() async {}
String? get uid => authUserInfo.uid;
String? get email => authUserInfo.email;
String? get displayName => authUserInfo.displayName;
String? get photoUrl => authUserInfo.photoUrl;
String? get phoneNumber => authUserInfo.phoneNumber;
}AuthUserStreamWidget class · dart · L60-L71 (12 LOC)app/lib/auth/firebase_auth/auth_util.dart
class AuthUserStreamWidget extends StatelessWidget {
const AuthUserStreamWidget({Key? key, required this.builder})
: super(key: key);
final WidgetBuilder builder;
@override
Widget build(BuildContext context) => StreamBuilder(
stream: authenticatedUserStream,
builder: (context, _) => builder(context),
);
}FirebasePhoneAuthManager class · dart · L20-L41 (22 LOC)app/lib/auth/firebase_auth/firebase_auth_manager.dart
class FirebasePhoneAuthManager extends ChangeNotifier {
bool? _triggerOnCodeSent;
FirebaseAuthException? phoneAuthError;
// Set when using phone verification (after phone number is provided).
String? phoneAuthVerificationCode;
// Set when using phone sign in in web mode (ignored otherwise).
ConfirmationResult? webPhoneAuthConfirmationResult;
// Used for handling verification codes for phone sign in.
void Function(BuildContext)? _onCodeSent;
bool get triggerOnCodeSent => _triggerOnCodeSent ?? false;
set triggerOnCodeSent(bool val) => _triggerOnCodeSent = val;
void Function(BuildContext) get onCodeSent =>
_onCodeSent == null ? (_) {} : _onCodeSent!;
set onCodeSent(void Function(BuildContext) func) => _onCodeSent = func;
void update(VoidCallback callback) {
callback();
notifyListeners();
}
}HabuFirebaseUser class · dart · L8-L62 (55 LOC)app/lib/auth/firebase_auth/firebase_user_provider.dart
class HabuFirebaseUser extends BaseAuthUser {
HabuFirebaseUser(this.user);
User? user;
bool get loggedIn => user != null;
@override
AuthUserInfo get authUserInfo => AuthUserInfo(
uid: user?.uid,
email: user?.email,
displayName: user?.displayName,
photoUrl: user?.photoURL,
phoneNumber: user?.phoneNumber,
);
@override
Future? delete() => user?.delete();
@override
Future? updateEmail(String email) async {
try {
await user?.updateEmail(email);
} catch (_) {
await user?.verifyBeforeUpdateEmail(email);
}
}
@override
Future? updatePassword(String newPassword) async {
await user?.updatePassword(newPassword);
}
@override
Future? sendEmailVerification() => user?.sendEmailVerification();
@override
bool get emailVerified {
// Reloads the user when checking in order to get the most up to date
// email verified status.
if (loggedIn && !user!.emailVerified) {
refreshUserRepobility analyzer · published findings · https://repobility.com
FirebaseCloudFunctionsGroup class · dart · L16-L21 (6 LOC)app/lib/backend/api_requests/api_calls.dart
class FirebaseCloudFunctionsGroup {
static String getBaseUrl() =>
'https://us-west1-habu-1gxak2.cloudfunctions.net/';
static Map<String, String> headers = {};
static CloudCalcsCall cloudCalcsCall = CloudCalcsCall();
}StripeAPIsGroup class · dart · L431-L439 (9 LOC)app/lib/backend/api_requests/api_calls.dart
class StripeAPIsGroup {
static ListAllProductsCall listAllProductsCall = ListAllProductsCall();
static GetPriceCall getPriceCall = GetPriceCall();
static CreateCheckoutSessionCall createCheckoutSessionCall =
CreateCheckoutSessionCall();
static GetCheckoutSessionCall getCheckoutSessionCall =
GetCheckoutSessionCall();
static CreateCustomerCall createCustomerCall = CreateCustomerCall();
}ListAllProductsCall class · dart · L441-L458 (18 LOC)app/lib/backend/api_requests/api_calls.dart
class ListAllProductsCall {
Future<ApiCallResponse> call() async {
final response = await makeCloudCall(
_kPrivateApiFunctionName,
{
'callName': 'ListAllProductsCall',
'variables': {},
},
);
return ApiCallResponse.fromCloudCallResponse(response);
}
List? data(dynamic response) => getJsonField(
response,
r'''$.data''',
true,
) as List?;
}GetPriceCall class · dart · L460-L480 (21 LOC)app/lib/backend/api_requests/api_calls.dart
class GetPriceCall {
Future<ApiCallResponse> call({
String? priceId = '',
}) async {
final response = await makeCloudCall(
_kPrivateApiFunctionName,
{
'callName': 'GetPriceCall',
'variables': {
'priceId': priceId,
},
},
);
return ApiCallResponse.fromCloudCallResponse(response);
}
int? unitAmout(dynamic response) => castToType<int>(getJsonField(
response,
r'''$.unit_amount''',
));
}CreateCheckoutSessionCall class · dart · L482-L514 (33 LOC)app/lib/backend/api_requests/api_calls.dart
class CreateCheckoutSessionCall {
Future<ApiCallResponse> call({
String? successUrl = '',
String? lineItems0PriceId = '',
int? lineItems0Quantity,
String? customer = '',
int? token,
}) async {
final response = await makeCloudCall(
_kPrivateApiFunctionName,
{
'callName': 'CreateCheckoutSessionCall',
'variables': {
'successUrl': successUrl,
'lineItems0PriceId': lineItems0PriceId,
'lineItems0Quantity': lineItems0Quantity,
'customer': customer,
'token': token,
},
},
);
return ApiCallResponse.fromCloudCallResponse(response);
}
String? checkoutId(dynamic response) => castToType<String>(getJsonField(
response,
r'''$.id''',
));
String? checkoutUrl(dynamic response) => castToType<String>(getJsonField(
response,
r'''$.url''',
));
}GetCheckoutSessionCall class · dart · L516-L527 (12 LOC)app/lib/backend/api_requests/api_calls.dart
class GetCheckoutSessionCall {
Future<ApiCallResponse> call() async {
final response = await makeCloudCall(
_kPrivateApiFunctionName,
{
'callName': 'GetCheckoutSessionCall',
'variables': {},
},
);
return ApiCallResponse.fromCloudCallResponse(response);
}
}CreateCustomerCall class · dart · L529-L549 (21 LOC)app/lib/backend/api_requests/api_calls.dart
class CreateCustomerCall {
Future<ApiCallResponse> call({
String? email = '',
}) async {
final response = await makeCloudCall(
_kPrivateApiFunctionName,
{
'callName': 'CreateCustomerCall',
'variables': {
'email': email,
},
},
);
return ApiCallResponse.fromCloudCallResponse(response);
}
String? id(dynamic response) => castToType<String>(getJsonField(
response,
r'''$.id''',
));
}GETZestimateCall class · dart · L554-L580 (27 LOC)app/lib/backend/api_requests/api_calls.dart
class GETZestimateCall {
static Future<ApiCallResponse> call({
String? zpid = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'GET zestimate',
apiUrl:
'https://us-west1-habu-1gxak2.cloudfunctions.net/propertyZestimate',
callType: ApiCallType.GET,
headers: {},
params: {
'zpid': zpid,
},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: true,
isStreamingApi: false,
alwaysAllowBody: false,
);
}
static int? zestimate(dynamic response) => castToType<int>(getJsonField(
response,
r'''$.value''',
));
}Want this analysis on your repo? https://repobility.com/scan/
GETPptyDetailsCall class · dart · L582-L613 (32 LOC)app/lib/backend/api_requests/api_calls.dart
class GETPptyDetailsCall {
static Future<ApiCallResponse> call({
String? zpid = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'GET PptyDetails',
apiUrl:
'https://us-west1-habu-1gxak2.cloudfunctions.net/propertyDetails',
callType: ApiCallType.GET,
headers: {},
params: {
'zpid': zpid,
},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: true,
isStreamingApi: false,
alwaysAllowBody: false,
);
}
static int? yearBuilt(dynamic response) => castToType<int>(getJsonField(
response,
r'''$.yearBuilt''',
));
static String? description(dynamic response) =>
castToType<String>(getJsonField(
response,
r'''$.description''',
));
}ApiPagingParams class · dart · L616-L630 (15 LOC)app/lib/backend/api_requests/api_calls.dart
class ApiPagingParams {
int nextPageNumber = 0;
int numItems = 0;
dynamic lastResponse;
ApiPagingParams({
required this.nextPageNumber,
required this.numItems,
required this.lastResponse,
});
@override
String toString() =>
'PagingParams(nextPageNumber: $nextPageNumber, numItems: $numItems, lastResponse: $lastResponse,)';
}ApiCallOptions class · dart · L36-L144 (109 LOC)app/lib/backend/api_requests/api_manager.dart
class ApiCallOptions extends Equatable {
const ApiCallOptions({
this.callName = '',
required this.callType,
required this.apiUrl,
required this.headers,
required this.params,
this.bodyType,
this.body,
this.returnBody = true,
this.encodeBodyUtf8 = false,
this.decodeUtf8 = false,
this.alwaysAllowBody = false,
this.cache = false,
this.isStreamingApi = false,
});
final String callName;
final ApiCallType callType;
final String apiUrl;
final Map<String, dynamic> headers;
final Map<String, dynamic> params;
final BodyType? bodyType;
final String? body;
final bool returnBody;
final bool encodeBodyUtf8;
final bool decodeUtf8;
final bool alwaysAllowBody;
final bool cache;
final bool isStreamingApi;
/// Creates a new [ApiCallOptions] with optionally updated parameters.
///
/// This helper function allows creating a copy of the current options while
/// selectively modifying specific fields. Any parameter thApiCallResponse class · dart · L146-L220 (75 LOC)app/lib/backend/api_requests/api_manager.dart
class ApiCallResponse {
const ApiCallResponse(
this.jsonBody,
this.headers,
this.statusCode, {
this.response,
this.streamedResponse,
this.exception,
});
final dynamic jsonBody;
final Map<String, String> headers;
final int statusCode;
final http.Response? response;
final http.StreamedResponse? streamedResponse;
final Object? exception;
// Whether we received a 2xx status (which generally marks success).
bool get succeeded => statusCode >= 200 && statusCode < 300;
String getHeader(String headerName) => headers[headerName] ?? '';
// Return the raw body from the response, or if this came from a cloud call
// and the body is not a string, then the json encoded body.
String get bodyText =>
response?.body ??
(jsonBody is String ? jsonBody as String : jsonEncode(jsonBody));
String get exceptionMessage => exception.toString();
/// Creates a new [ApiCallResponse] with optionally updated parameters.
///
/// This helper functApiManager class · dart · L222-L613 (392 LOC)app/lib/backend/api_requests/api_manager.dart
class ApiManager {
ApiManager._();
// Cache that will ensure identical calls are not repeatedly made.
static Map<ApiCallOptions, ApiCallResponse> _apiCache = {};
static ApiManager? _instance;
static ApiManager get instance => _instance ??= ApiManager._();
// If your API calls need authentication, populate this field once
// the user has authenticated. Alter this as needed.
static String? _accessToken;
// Map of active streaming response subscriptions
// Key is a unique identifier for the subscription
// Value is the stream subscription
final Map<String, StreamSubscription<ResponseStreamMessage>>
_activeStreamingResponseSubscriptions = {};
// Add a new active streaming response subscription
void addActiveStreamingResponseSubscription(
String subscriptionKey,
StreamSubscription<ResponseStreamMessage>? subscription,
) {
// Check if the subscription key is empty or if the subscription is null
if (subscriptionKey.isEmpty || subscriptioServerSentEvent class · dart · L4-L29 (26 LOC)app/lib/backend/api_requests/api_streaming.dart
class ServerSentEvent {
final String id;
final String event;
final String data;
late final dynamic _jsonData = _tryJsonDecode(data);
final int? retry;
dynamic get jsonData {
return _jsonData;
}
dynamic _tryJsonDecode(String dataString) {
try {
return jsonDecode(dataString);
} catch (_) {
return null;
}
}
ServerSentEvent({
required this.id,
required this.event,
required this.data,
this.retry,
});
}ResponseStreamMessage class · dart · L31-L70 (40 LOC)app/lib/backend/api_requests/api_streaming.dart
class ResponseStreamMessage {
final String message;
late final ServerSentEvent _serverSentEvent = _parseSseString(message);
ServerSentEvent get serverSentEvent {
return _serverSentEvent;
}
ResponseStreamMessage({
required this.message,
});
ServerSentEvent _parseSseString(String sseString) {
String id = '';
String event = '';
String data = '';
int? retry;
// Split the input string by lines
final lines = sseString.split('\n');
for (var line in lines) {
if (line.startsWith('id:')) {
id = line.substring(3).trim();
} else if (line.startsWith('event:')) {
event = line.substring(6).trim();
} else if (line.startsWith('data:')) {
data += line.substring(5).trim() + '\n';
} else if (line.startsWith('retry:')) {
retry = int.tryParse(line.substring(6).trim());
}
}
// Remove the trailing newline character from data
if (data.endsWith('\n')) {
data = data.substring(0, _NewlineEventSink class · dart · L83-L112 (30 LOC)app/lib/backend/api_requests/api_streaming.dart
class _NewlineEventSink implements EventSink<String> {
final EventSink<String> _sink;
String _buffer = '';
_NewlineEventSink(this._sink);
@override
void add(String data) {
if (data.isEmpty) {
_sink.add(_buffer);
_buffer = '';
} else {
_buffer += (_buffer.isNotEmpty ? '\n' : '') + data;
}
}
@override
void addError(Object error, [StackTrace? stackTrace]) {
_sink.addError(error, stackTrace);
}
@override
void close() {
if (_buffer.isNotEmpty) {
_sink.add(_buffer);
_buffer = '';
}
_sink.close();
}
}Repobility — the code-quality scanner for AI-generated software · https://repobility.com
PipelineApi class · dart · L5-L64 (60 LOC)app/lib/backend/api_requests/pipeline_api.dart
class PipelineApi {
/// NimbleDashboard backend URL.
/// In dev: localhost via port forwarding or local network IP.
/// In prod: replace with deployed URL.
static const String baseUrl = 'http://10.0.2.2:8001'; // Android emulator -> host
/// Send a saved property to the deal pipeline for scoring.
///
/// Returns the scored deal response or throws on failure.
static Future<Map<String, dynamic>> sendToPipeline({
required String realdealId,
required String address,
required int price,
required int impValue,
int? futureValue,
int? downPayment,
int? loanFees,
int? cashNeeded,
int? duration,
int? beds,
int? baths,
int? sqft,
String? city,
String? state,
String? zipCode,
String? strategy,
}) async {
final body = {
'realdeal_id': realdealId,
'address': address,
'price': price.toDouble(),
'impValue': impValue.toDouble(),
if (futureValue != null) 'futureValue': futureValue.toDoublFFFirestorePage class · dart · L224-L230 (7 LOC)app/lib/backend/backend.dart
class FFFirestorePage<T> {
final List<T> data;
final Stream<List<T>>? dataStream;
final QueryDocumentSnapshot? nextPageMarker;
FFFirestorePage(this.data, this.dataStream, this.nextPageMarker);
}ReInvestCalcsCombinedCloudFunctionCallResponse class · dart · L2-L15 (14 LOC)app/lib/backend/custom_cloud_functions/custom_cloud_function_response_manager.dart
class ReInvestCalcsCombinedCloudFunctionCallResponse {
ReInvestCalcsCombinedCloudFunctionCallResponse({
this.errorCode,
this.succeeded,
this.jsonBody,
this.resultAsString,
this.data,
});
String? errorCode;
bool? succeeded;
dynamic jsonBody;
String? resultAsString;
List<dynamic>? data;
}HandleStripeWebhookCloudFunctionCallResponse class · dart · L17-L26 (10 LOC)app/lib/backend/custom_cloud_functions/custom_cloud_function_response_manager.dart
class HandleStripeWebhookCloudFunctionCallResponse {
HandleStripeWebhookCloudFunctionCallResponse({
this.errorCode,
this.succeeded,
this.jsonBody,
});
String? errorCode;
bool? succeeded;
dynamic jsonBody;
}CreateCustomerCloudFunctionCallResponse class · dart · L28-L37 (10 LOC)app/lib/backend/custom_cloud_functions/custom_cloud_function_response_manager.dart
class CreateCustomerCloudFunctionCallResponse {
CreateCustomerCloudFunctionCallResponse({
this.errorCode,
this.succeeded,
this.jsonBody,
});
String? errorCode;
bool? succeeded;
dynamic jsonBody;
}CreateCheckoutSessionCloudFunctionCallResponse class · dart · L39-L48 (10 LOC)app/lib/backend/custom_cloud_functions/custom_cloud_function_response_manager.dart
class CreateCheckoutSessionCloudFunctionCallResponse {
CreateCheckoutSessionCloudFunctionCallResponse({
this.errorCode,
this.succeeded,
this.jsonBody,
});
String? errorCode;
bool? succeeded;
dynamic jsonBody;
}DealAlertsRecord class · dart · L10-L257 (248 LOC)app/lib/backend/schema/deal_alerts_record.dart
class DealAlertsRecord extends FirestoreRecord {
DealAlertsRecord._(
DocumentReference reference,
Map<String, dynamic> data,
) : super(reference, data) {
_initializeFields();
}
// "address" field.
String? _address;
String get address => _address ?? '';
bool hasAddress() => _address != null;
// "zpid" field.
String? _zpid;
String get zpid => _zpid ?? '';
bool hasZpid() => _zpid != null;
// "method" field.
String? _method;
String get method => _method ?? '';
bool hasMethod() => _method != null;
// "price" field.
int? _price;
int get price => _price ?? 0;
bool hasPrice() => _price != null;
// "netReturn" field.
int? _netReturn;
int get netReturn => _netReturn ?? 0;
bool hasNetReturn() => _netReturn != null;
// "netROI" field.
double? _netROI;
double get netROI => _netROI ?? 0.0;
bool hasNetROI() => _netROI != null;
// "cashNeeded" field.
int? _cashNeeded;
int get cashNeeded => _cashNeeded ?? 0;
bool hasCashNeCarouselPhotosStruct class · dart · L9-L63 (55 LOC)app/lib/backend/schema/structs/carousel_photos_struct.dart
class CarouselPhotosStruct extends FFFirebaseStruct {
CarouselPhotosStruct({
String? url,
FirestoreUtilData firestoreUtilData = const FirestoreUtilData(),
}) : _url = url,
super(firestoreUtilData);
// "url" field.
String? _url;
String get url => _url ?? '';
set url(String? val) => _url = val;
bool hasUrl() => _url != null;
static CarouselPhotosStruct fromMap(Map<String, dynamic> data) =>
CarouselPhotosStruct(
url: data['url'] as String?,
);
static CarouselPhotosStruct? maybeFromMap(dynamic data) => data is Map
? CarouselPhotosStruct.fromMap(data.cast<String, dynamic>())
: null;
Map<String, dynamic> toMap() => {
'url': _url,
}.withoutNulls;
@override
Map<String, dynamic> toSerializableMap() => {
'url': serializeParam(
_url,
ParamType.String,
),
}.withoutNulls;
static CarouselPhotosStruct fromSerializableMap(Map<String, dynamic> data) =>
CarouselWant fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
CompsStruct class · dart · L11-L268 (258 LOC)app/lib/backend/schema/structs/comps_struct.dart
class CompsStruct extends FFFirebaseStruct {
CompsStruct({
int? bedrooms,
List<MiniCardPhotosStruct>? miniCardPhotos,
int? price,
int? livingArea,
int? zpid,
int? bathrooms,
int? lotSize,
double? latitude,
double? longitude,
FirestoreUtilData firestoreUtilData = const FirestoreUtilData(),
}) : _bedrooms = bedrooms,
_miniCardPhotos = miniCardPhotos,
_price = price,
_livingArea = livingArea,
_zpid = zpid,
_bathrooms = bathrooms,
_lotSize = lotSize,
_latitude = latitude,
_longitude = longitude,
super(firestoreUtilData);
// "bedrooms" field.
int? _bedrooms;
int get bedrooms => _bedrooms ?? 0;
set bedrooms(int? val) => _bedrooms = val;
void incrementBedrooms(int amount) => bedrooms = bedrooms + amount;
bool hasBedrooms() => _bedrooms != null;
// "miniCardPhotos" field.
List<MiniCardPhotosStruct>? _miniCardPhotos;
List<MiniCardPhotosStruct> get miniCardPhDescriptionAnalysisStruct class · dart · L11-L119 (109 LOC)app/lib/backend/schema/structs/description_analysis_struct.dart
class DescriptionAnalysisStruct extends FFFirebaseStruct {
DescriptionAnalysisStruct({
bool? hasKeywords,
List<String>? keywords,
int? keywordCount,
FirestoreUtilData firestoreUtilData = const FirestoreUtilData(),
}) : _hasKeywords = hasKeywords,
_keywords = keywords,
_keywordCount = keywordCount,
super(firestoreUtilData);
// "hasKeywords" field.
bool? _hasKeywords;
bool get hasKeywords => _hasKeywords ?? false;
set hasKeywords(bool? val) => _hasKeywords = val;
bool hasHasKeywords() => _hasKeywords != null;
// "keywords" field.
List<String>? _keywords;
List<String> get keywords => _keywords ?? const [];
set keywords(List<String>? val) => _keywords = val;
void updateKeywords(Function(List<String>) updateFn) {
updateFn(_keywords ??= []);
}
bool hasKeywordsField() => _keywords != null;
// "keywordCount" field.
int? _keywordCount;
int get keywordCount => _keywordCount ?? 0;
set keywordCount(int? val) => DomStruct class · dart · L9-L84 (76 LOC)app/lib/backend/schema/structs/dom_struct.dart
class DomStruct extends FFFirebaseStruct {
DomStruct({
int? level,
int? value,
FirestoreUtilData firestoreUtilData = const FirestoreUtilData(),
}) : _level = level,
_value = value,
super(firestoreUtilData);
// "level" field.
int? _level;
int get level => _level ?? 0;
set level(int? val) => _level = val;
void incrementLevel(int amount) => level = level + amount;
bool hasLevel() => _level != null;
// "value" field.
int? _value;
int get value => _value ?? 0;
set value(int? val) => _value = val;
void incrementValue(int amount) => value = value + amount;
bool hasValue() => _value != null;
static DomStruct fromMap(Map<String, dynamic> data) => DomStruct(
level: castToType<int>(data['level']),
value: castToType<int>(data['value']),
);
static DomStruct? maybeFromMap(dynamic data) =>
data is Map ? DomStruct.fromMap(data.cast<String, dynamic>()) : null;
Map<String, dynamic> toMap() => {
'lpage 1 / 7next ›