// Drop-in Dart client library for the Friendship Tracker HTTP API. // // Save this file under your project as `lib/friendship_client.dart` and // import it directly: // // import 'package:my_project/friendship_client.dart'; // // final c = FriendshipClient('pat_...'); // final rows = await c.accountList(opts: ListOpts(limit: 20, sort: '-created_at')); // final fresh = await c.accountCreate({{'name': 'Example GmbH'}}); // // Every endpoint exposed by the HTTP API is wrapped as a typed // `` method on FriendshipClient. List endpoints take an optional // ListOpts; get/update/delete endpoints take the row id as the first // argument. // // Provided as-is, with no warranty. Vendor freely; modify as needed. // Targets Dart 3.0+; uses only the platform stdlib (`dart:io`, // `dart:convert`, `dart:async`). // // DO NOT EDIT THIS FILE MANUALLY - re-download from the docs site. // Local edits will be overwritten by the once-per-day version check. import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'dart:math'; // ── Identity (substituted at generation time) ──────────────────────── const String appSlug = 'friendship'; const String appName = 'Friendship Tracker'; const String moduleName = 'friendship_client'; const String clientVersion = '0.3.13'; const String language = 'dart'; const String _defaultBase = 'https://friendship-tracker.com'; /// Per-type metadata baked at generation time. Decoded once on first /// access; useful at runtime when calling code needs to know the legal /// filters / sort columns / max_limit for a model without a second /// round-trip. final Map types = json.decode(r'''{"activity":{"ops":["list","read","create","update","delete"],"create_fields":["parent_id","kind","summary","description","occurred_at","location"],"update_fields":["kind","summary","description","occurred_at","location"],"allowed_filters":["data__parent_id","data__kind","status","is_archived","owned_by"],"allowed_sorts":["created_at","data__occurred_at"],"default_sort":"data__occurred_at","max_limit":200,"fields":[{"name":"kind","type":"enum","values":["meeting","call","email","message","event","other"]},{"name":"summary","type":"string","max_len":400},{"name":"location","type":"string","max_len":200},{"name":"parent_id","type":"string","max_len":64,"ref":{"type":"contact","owned":true,"optional":false}},{"name":"description","type":"string","max_len":4000},{"name":"occurred_at","type":"string","max_len":32}]},"contact":{"ops":["list","read","create","update","delete"],"create_fields":["name","nickname","pronouns","email","phone","secondary_email","secondary_phone","company","job_title","address_line","city","country","website","linkedin","twitter","birthday","anniversary","gender","how_we_met","food_prefs","allergies","last_contacted_at","stay_in_touch_frequency","stay_in_touch_topic","notes","tags","favorite","avatar_blob_id","color"],"update_fields":["name","nickname","pronouns","email","phone","secondary_email","secondary_phone","company","job_title","address_line","city","country","website","linkedin","twitter","birthday","anniversary","gender","how_we_met","food_prefs","allergies","last_contacted_at","stay_in_touch_frequency","stay_in_touch_topic","notes","tags","favorite","avatar_blob_id","color"],"allowed_filters":["data__name","data__email","data__company","data__city","data__country","data__favorite","data__tags","data__gender","data__stay_in_touch_frequency","status","is_archived","owned_by"],"allowed_sorts":["created_at","updated_at","data__name","data__company","data__last_contacted_at","data__birthday","data__stay_in_touch_frequency"],"default_sort":"data__name","max_limit":200,"fields":[{"name":"city","type":"string","max_len":120},{"name":"name","type":"string","max_len":200},{"name":"tags","type":"tags"},{"name":"color","type":"string","max_len":24},{"name":"email","type":"string","max_len":320},{"name":"notes","type":"string","max_len":8000},{"name":"phone","type":"string","max_len":64},{"name":"gender","type":"enum","values":["male","female","other","unspecified"]},{"name":"company","type":"string","max_len":200},{"name":"country","type":"string","max_len":120},{"name":"twitter","type":"url"},{"name":"website","type":"url"},{"name":"birthday","type":"string","max_len":32},{"name":"favorite","type":"bool"},{"name":"linkedin","type":"url"},{"name":"nickname","type":"string","max_len":120},{"name":"pronouns","type":"string","max_len":32},{"name":"allergies","type":"string","max_len":600},{"name":"job_title","type":"string","max_len":200},{"name":"food_prefs","type":"string","max_len":600},{"name":"how_we_met","type":"string","max_len":1000},{"name":"anniversary","type":"string","max_len":32},{"name":"address_line","type":"string","max_len":200},{"name":"avatar_blob_id","type":"string","max_len":64},{"name":"secondary_email","type":"string","max_len":320},{"name":"secondary_phone","type":"string","max_len":64},{"name":"last_contacted_at","type":"string","max_len":32},{"name":"stay_in_touch_topic","type":"string","max_len":400},{"name":"stay_in_touch_frequency","type":"enum","values":["never","weekly","biweekly","monthly","quarterly","yearly"]}]},"conversation":{"ops":["list","read","create","update","delete"],"create_fields":["parent_id","channel","summary","content","occurred_at","sentiment","duration_minutes"],"update_fields":["channel","summary","content","occurred_at","sentiment","duration_minutes"],"allowed_filters":["data__parent_id","data__channel","data__sentiment","status","is_archived","owned_by"],"allowed_sorts":["created_at","data__occurred_at"],"default_sort":"data__occurred_at","max_limit":200,"fields":[{"name":"channel","type":"enum","values":["call","sms","whatsapp","email","in_person","video","voice","letter","other"]},{"name":"content","type":"string","max_len":8000},{"name":"summary","type":"string","max_len":400},{"name":"parent_id","type":"string","max_len":64,"ref":{"type":"contact","owned":true,"optional":false}},{"name":"sentiment","type":"enum","values":["positive","neutral","negative"]},{"name":"occurred_at","type":"string","max_len":32},{"name":"duration_minutes","type":"number"}]},"custom_field":{"ops":["list","read","create","update","delete"],"create_fields":["parent_id","label","value","kind","icon"],"update_fields":["label","value","kind","icon"],"allowed_filters":["data__parent_id","data__kind","status","is_archived","owned_by"],"allowed_sorts":["created_at","data__label"],"default_sort":"created_at","max_limit":200,"fields":[{"name":"icon","type":"string","max_len":32},{"name":"kind","type":"enum","values":["text","number","date","url","bool"]},{"name":"label","type":"string","max_len":80},{"name":"value","type":"string","max_len":2000},{"name":"parent_id","type":"string","max_len":64,"ref":{"type":"contact","owned":true,"optional":false}}]},"gift":{"ops":["list","read","create","update","delete"],"create_fields":["parent_id","title","occasion","status","occurred_at","price","currency","url","notes"],"update_fields":["title","occasion","status","occurred_at","price","currency","url","notes"],"allowed_filters":["data__parent_id","data__status","data__occasion","status","is_archived","owned_by"],"allowed_sorts":["created_at","data__occurred_at","data__title"],"default_sort":"data__occurred_at","max_limit":200,"fields":[{"name":"url","type":"url"},{"name":"notes","type":"string","max_len":4000},{"name":"price","type":"number"},{"name":"title","type":"string","max_len":200},{"name":"status","type":"enum","values":["idea","given","received"]},{"name":"currency","type":"string","max_len":8},{"name":"occasion","type":"string","max_len":120},{"name":"parent_id","type":"string","max_len":64,"ref":{"type":"contact","owned":true,"optional":false}},{"name":"occurred_at","type":"string","max_len":32}]},"journal_entry":{"ops":["list","read","create","update","delete"],"create_fields":["title","body","mood","occurred_at","tags"],"update_fields":["title","body","mood","occurred_at","tags"],"allowed_filters":["data__mood","data__tags","status","is_archived","owned_by"],"allowed_sorts":["data__occurred_at","created_at","updated_at"],"default_sort":"data__occurred_at","max_limit":200,"fields":[{"name":"body","type":"string","max_len":16000},{"name":"mood","type":"enum","values":["great","good","ok","down","awful"]},{"name":"tags","type":"tags"},{"name":"title","type":"string","max_len":200},{"name":"occurred_at","type":"string","max_len":32}]},"life_event":{"ops":["list","read","create","update","delete"],"create_fields":["parent_id","kind","title","occurred_at","description","location","recurring"],"update_fields":["kind","title","occurred_at","description","location","recurring"],"allowed_filters":["data__parent_id","data__kind","data__recurring","status","is_archived","owned_by"],"allowed_sorts":["data__occurred_at","created_at"],"default_sort":"data__occurred_at","max_limit":200,"fields":[{"name":"kind","type":"enum","values":["birthday","anniversary","met","graduation","job_start","job_end","move","marriage","birth","loss","milestone","custom"]},{"name":"title","type":"string","max_len":200},{"name":"location","type":"string","max_len":200},{"name":"parent_id","type":"string","max_len":64,"ref":{"type":"contact","owned":true,"optional":false}},{"name":"recurring","type":"bool"},{"name":"description","type":"string","max_len":4000},{"name":"occurred_at","type":"string","max_len":32}]},"note":{"ops":["list","read","create","update","delete"],"create_fields":["parent_id","body","pinned"],"update_fields":["body","pinned"],"allowed_filters":["data__parent_id","data__pinned","status","is_archived","owned_by"],"allowed_sorts":["created_at","updated_at"],"default_sort":"created_at","max_limit":200,"fields":[{"name":"body","type":"string","max_len":8000},{"name":"pinned","type":"bool"},{"name":"parent_id","type":"string","max_len":64,"ref":{"type":"contact","owned":true,"optional":false}}]},"pet":{"ops":["list","read","create","update","delete"],"create_fields":["parent_id","name","species","species_other","breed","born_at","color","notes"],"update_fields":["name","species","species_other","breed","born_at","color","notes"],"allowed_filters":["data__parent_id","data__species","status","is_archived","owned_by"],"allowed_sorts":["created_at","data__name","data__born_at"],"default_sort":"data__name","max_limit":200,"fields":[{"name":"name","type":"string","max_len":80},{"name":"breed","type":"string","max_len":120},{"name":"color","type":"string","max_len":80},{"name":"notes","type":"string","max_len":2000},{"name":"born_at","type":"string","max_len":32},{"name":"species","type":"enum","values":["dog","cat","bird","fish","rabbit","hamster","guinea_pig","reptile","horse","other"]},{"name":"parent_id","type":"string","max_len":64,"ref":{"type":"contact","owned":true,"optional":false}},{"name":"species_other","type":"string","max_len":80}]},"relationship":{"ops":["list","read","create","update","delete"],"create_fields":["parent_id","target_id","kind","label","since","notes"],"update_fields":["kind","label","since","notes"],"allowed_filters":["data__parent_id","data__target_id","data__kind","status","is_archived","owned_by"],"allowed_sorts":["created_at","data__kind"],"default_sort":"data__kind","max_limit":200,"fields":[{"name":"kind","type":"enum","values":["partner","spouse","parent","child","sibling","friend","colleague","manager","report","mentor","mentee","other"]},{"name":"label","type":"string","max_len":80},{"name":"notes","type":"string","max_len":2000},{"name":"since","type":"string","max_len":32},{"name":"parent_id","type":"string","max_len":64,"ref":{"type":"contact","owned":true,"optional":false}},{"name":"target_id","type":"string","max_len":64,"ref":{"type":"contact","owned":true,"optional":false}}]},"reminder":{"ops":["list","read","create","update","delete"],"create_fields":["parent_id","message","due_date","completed"],"update_fields":["message","due_date","completed"],"allowed_filters":["data__parent_id","data__completed","status","is_archived","owned_by"],"allowed_sorts":["created_at","data__due_date"],"default_sort":"data__due_date","max_limit":200,"fields":[{"name":"message","type":"string","max_len":400},{"name":"due_date","type":"string","max_len":32},{"name":"completed","type":"bool"},{"name":"parent_id","type":"string","max_len":64,"ref":{"type":"contact","owned":true,"optional":false}}]}}''') as Map; class ApiError implements Exception { final int status; final String message; final dynamic bodyRaw; ApiError(this.status, this.message, [this.bodyRaw]); @override String toString() => 'HTTP $status: $message'; } class ListOpts { final int? limit; final int? offset; final String? sort; final String? q; final Map? filters; ListOpts({this.limit, this.offset, this.sort, this.q, this.filters}); } class FriendshipClient { String _baseUrl; String _token; late final String _deviceId; late final String _sessionId; bool _autoupdateAttempted = false; bool _metaSentOnce = false; final HttpClient _http = HttpClient(); static const Set _retryableStatuses = {408, 425, 429, 500, 502, 503, 504}; static const int _maxRetries = 3; static const Duration _defaultTimeout = Duration(seconds: 30); FriendshipClient([String token = '']) : _baseUrl = _resolveBaseUrl(), _token = token.isNotEmpty ? token : (Platform.environment['XCLIENT_TOKEN'] ?? '') { _deviceId = _loadOrMintDeviceId(); _sessionId = _mintUuid(); _http.connectionTimeout = const Duration(seconds: 15); } void setToken(String token) { _token = token; } void setBaseUrl(String url) { _baseUrl = _trimRightSlash(url); } static String _trimRightSlash(String s) { var out = s; while (out.endsWith('/')) { out = out.substring(0, out.length - 1); } return out; } static String _resolveBaseUrl() { final env = Platform.environment['XCLIENT_BASE_URL']; return _trimRightSlash((env != null && env.isNotEmpty) ? env : _defaultBase); } // ── Identifier persistence ───────────────────────────────────────── static String? _stateDir() { final home = Platform.environment['HOME'] ?? Platform.environment['USERPROFILE']; if (home == null || home.isEmpty) return null; final d = '$home/.${moduleName}'; try { Directory(d).createSync(recursive: true); return d; } catch (_) { return null; } } static String _mintUuid() { final rng = Random.secure(); final bytes = List.generate(16, (_) => rng.nextInt(256)); bytes[6] = (bytes[6] & 0x0f) | 0x40; bytes[8] = (bytes[8] & 0x3f) | 0x80; String hx(int i) => bytes[i].toRadixString(16).padLeft(2, '0'); return '${hx(0)}${hx(1)}${hx(2)}${hx(3)}-${hx(4)}${hx(5)}-${hx(6)}${hx(7)}-${hx(8)}${hx(9)}-${hx(10)}${hx(11)}${hx(12)}${hx(13)}${hx(14)}${hx(15)}'; } static String _loadOrMintDeviceId() { final d = _stateDir(); if (d == null) return _mintUuid(); final f = File('$d/device.json'); if (f.existsSync()) { try { final blob = json.decode(f.readAsStringSync()) as Map; final did = blob['device_id']; if (did is String && did.length >= 32) return did; } catch (_) {} } final fresh = _mintUuid(); try { f.writeAsStringSync(json.encode({'device_id': fresh})); } catch (_) {} return fresh; } static bool _autoupdateEnabled() { final v = (Platform.environment['XCLIENT_NO_AUTOUPDATE'] ?? '').toLowerCase(); return v != '1' && v != 'true' && v != 'yes'; } static Map _fingerprint() { final env = Platform.environment; final tp = (env['TERM_PROGRAM'] ?? '').toLowerCase(); return { 'dart_version': Platform.version, 'os': Platform.operatingSystem, 'os_version': Platform.operatingSystemVersion, 'term_program': env['TERM_PROGRAM'], 'editor_env': env['EDITOR'], 'ci': env.containsKey('CI') || env.containsKey('GITHUB_ACTIONS'), 'claude_code': env.containsKey('CLAUDECODE') || env.containsKey('CLAUDE_CODE_ENTRYPOINT'), 'codex': env.containsKey('CODEX_HOME'), 'vscode': tp == 'vscode' && !env.containsKey('CURSOR_TRACE_ID'), 'cursor': env.containsKey('CURSOR_TRACE_ID'), 'antigravity': env.containsKey('ANTIGRAVITY_TRACE_ID'), 'jetbrains': tp.contains('jetbrains'), }; } String _userAgent() => '$moduleName/$clientVersion (lib/$language; dart/${Platform.version.split(' ').first}; ${Platform.operatingSystem})'; static double _backoffSeconds(int attempt, double? retryAfter) { if (retryAfter != null && retryAfter >= 0) return min(retryAfter, 60.0); return min(pow(2, attempt).toDouble(), 60.0); } // ── HTTP transport ───────────────────────────────────────────────── /// Generic request helper. JSON in / JSON out. Future?> requestJson( String method, String path, dynamic body) async { _maybeAutoupdate(); Object? lastErr; for (var attempt = 0; attempt < _maxRetries; attempt++) { try { final result = await _sendFollowingRedirects( method.toUpperCase(), '$_baseUrl$path', body); final status = result.status; final headers = result.headers; final raw = result.body; final fresh = headers['x-auth-refresh-token']; if (fresh != null && fresh.isNotEmpty) _token = fresh; if (_retryableStatuses.contains(status) && attempt + 1 < _maxRetries) { double? ra; final raStr = headers['retry-after']; if (raStr != null) ra = double.tryParse(raStr); await Future.delayed( Duration(milliseconds: (_backoffSeconds(attempt, ra) * 1000).round())); continue; } dynamic parsed; if (raw.isNotEmpty) { try { parsed = json.decode(raw); } catch (_) { parsed = null; } } if (status >= 400) { var msg = 'request failed'; if (parsed is Map) { final d = parsed['detail']; final m = parsed['message']; if (d is String) msg = d; else if (m is String) msg = m; } _emitCallEvent(method, path, status, false); throw ApiError(status, msg, parsed); } _emitCallEvent(method, path, status, true); if (parsed is Map) return parsed; return null; } on ApiError { rethrow; } catch (e) { lastErr = e; if (attempt + 1 < _maxRetries) { await Future.delayed( Duration(milliseconds: (_backoffSeconds(attempt, null) * 1000).round())); continue; } _emitCallEvent(method, path, 0, false); throw ApiError(0, e.toString()); } } _emitCallEvent(method, path, 0, false); throw ApiError(0, lastErr?.toString() ?? 'request failed'); } Future?> requestList(String path, ListOpts? opts) { final qs = {}; if (opts != null) { if (opts.limit != null) qs['limit'] = opts.limit.toString(); if (opts.offset != null) qs['offset'] = opts.offset.toString(); if (opts.sort != null && opts.sort!.isNotEmpty) qs['sort'] = opts.sort!; if (opts.q != null && opts.q!.isNotEmpty) qs['q'] = opts.q!; if (opts.filters != null) { opts.filters!.forEach((k, v) { if (v != null) qs[k] = v.toString(); }); } } var p = path; if (qs.isNotEmpty) { final encoded = qs.entries.map((e) => '${Uri.encodeQueryComponent(e.key)}=${Uri.encodeQueryComponent(e.value)}' ).join('&'); p = '$p${path.contains('?') ? '&' : '?'}$encoded'; } return requestJson('GET', p, null); } /// Walk the redirect chain manually so Authorization can be dropped /// on cross-origin hops. Caps at 5 hops; mirrors RFC 7231 method /// rewrite semantics. Future<_Response> _sendFollowingRedirects( String method, String urlIn, dynamic body) async { var url = urlIn; var currentMethod = method; dynamic currentBody = body; var stripAuth = false; for (var hop = 0; hop < 5; hop++) { final uri = Uri.parse(url); final req = await _http.openUrl(currentMethod, uri).timeout(_defaultTimeout); req.followRedirects = false; req.headers.set('Accept', 'application/json'); req.headers.set('User-Agent', _userAgent()); req.headers.set('X-Client-Channel', 'client_$language'); req.headers.set('X-Client-Version', clientVersion); req.headers.set('X-Analytics-Device-Id', _deviceId); req.headers.set('X-Analytics-Session-Id', _sessionId); if (!stripAuth && _token.isNotEmpty) { req.headers.set('Authorization', 'Bearer $_token'); } if (currentBody != null && currentMethod != 'GET' && currentMethod != 'HEAD') { req.headers.set('Content-Type', 'application/json'); final encoded = utf8.encode(json.encode(currentBody)); req.contentLength = encoded.length; req.add(encoded); } final resp = await req.close().timeout(_defaultTimeout); final raw = await resp.transform(utf8.decoder).join(); final hmap = {}; resp.headers.forEach((k, v) { hmap[k.toLowerCase()] = v.join(','); }); final status = resp.statusCode; if (status < 300 || status >= 400 || status == 304) { return _Response(status, hmap, raw); } final loc = hmap['location']; if (loc == null || loc.isEmpty) return _Response(status, hmap, raw); Uri nextUri; try { nextUri = uri.resolve(loc); } catch (_) { return _Response(status, hmap, raw); } if (nextUri.origin != uri.origin) stripAuth = true; if (status == 303 || ((status == 301 || status == 302) && currentMethod != 'GET' && currentMethod != 'HEAD')) { currentMethod = 'GET'; currentBody = null; } url = nextUri.toString(); } return _Response(0, const {}, ''); } // ── Analytics ────────────────────────────────────────────────────── void _emitCallEvent(String method, String path, int status, bool ok) { final includeEnv = !_metaSentOnce; _metaSentOnce = true; Future(() async { try { final meta = { 'channel': 'client_$language', 'client_version': clientVersion, 'module_name': moduleName, 'language': language, 'os': Platform.operatingSystem, 'dart_version': Platform.version, }; if (includeEnv) meta['env'] = _fingerprint(); final pathBase = path.split('?').first; final evt = { 'type': 'client.call', 'ts_client': DateTime.now().millisecondsSinceEpoch ~/ 1000, 'meta': { 'method': method.toUpperCase(), 'path': pathBase.length > 128 ? pathBase.substring(0, 128) : pathBase, 'status': status, 'ok': ok, }, }; final payload = json.encode({ 'device_id': _deviceId, 'session_id': _sessionId, 'events': [evt], 'meta': meta, }); final client = HttpClient(); client.connectionTimeout = const Duration(seconds: 2); try { final uri = Uri.parse('$_baseUrl/xapi2/analytics/challenge'); final req = await client.postUrl(uri).timeout(const Duration(seconds: 4)); req.headers.set('Content-Type', 'application/json'); req.headers.set('User-Agent', _userAgent()); final encoded = utf8.encode(payload); req.contentLength = encoded.length; req.add(encoded); final resp = await req.close().timeout(const Duration(seconds: 4)); await resp.drain(); } finally { client.close(force: true); } } catch (_) { /* fire-and-forget */ } }); } // ── Auto-update ──────────────────────────────────────────────────── void _maybeAutoupdate() { if (_autoupdateAttempted) return; _autoupdateAttempted = true; if (!_autoupdateEnabled()) return; Future(() async { try { final d = _stateDir(); if (d == null) return; final stamp = File('$d/update_check.json'); if (stamp.existsSync()) { try { final blob = json.decode(stamp.readAsStringSync()) as Map; final last = blob['checked_at']; if (last is num && (DateTime.now().millisecondsSinceEpoch ~/ 1000) - last.toInt() < 86400) { return; } } catch (_) {} } try { stamp.writeAsStringSync(json.encode({'checked_at': DateTime.now().millisecondsSinceEpoch ~/ 1000})); } catch (_) {} // Source replacement is intentionally a no-op in Dart - users // typically ship AOT-compiled artefacts (Flutter apps, dart // compile exe), so the .dart file on disk is just a record of // the version they vendored. Surface the new version through // the next build. } catch (_) { /* best-effort */ } }); } /// List `activity` rows. Future?> activityList({ListOpts? opts}) => requestList('/xapi2/data/activity', opts); /// Fetch one `activity` row by id. Future?> activityGet(String id) => requestJson('GET', '/xapi2/data/activity/' + id, null); /// Create a new `activity` row. Future?> activityCreate(Map data) => requestJson('POST', '/xapi2/data/activity', data); /// Patch a `activity` row. Future?> activityUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/activity/' + id, data); /// Delete a `activity` row. Future activityDelete(String id) async { await requestJson('DELETE', '/xapi2/data/activity/' + id, null); return true; } /// List `contact` rows. Future?> contactList({ListOpts? opts}) => requestList('/xapi2/data/contact', opts); /// Fetch one `contact` row by id. Future?> contactGet(String id) => requestJson('GET', '/xapi2/data/contact/' + id, null); /// Create a new `contact` row. Future?> contactCreate(Map data) => requestJson('POST', '/xapi2/data/contact', data); /// Patch a `contact` row. Future?> contactUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/contact/' + id, data); /// Delete a `contact` row. Future contactDelete(String id) async { await requestJson('DELETE', '/xapi2/data/contact/' + id, null); return true; } /// List `conversation` rows. Future?> conversationList({ListOpts? opts}) => requestList('/xapi2/data/conversation', opts); /// Fetch one `conversation` row by id. Future?> conversationGet(String id) => requestJson('GET', '/xapi2/data/conversation/' + id, null); /// Create a new `conversation` row. Future?> conversationCreate(Map data) => requestJson('POST', '/xapi2/data/conversation', data); /// Patch a `conversation` row. Future?> conversationUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/conversation/' + id, data); /// Delete a `conversation` row. Future conversationDelete(String id) async { await requestJson('DELETE', '/xapi2/data/conversation/' + id, null); return true; } /// List `custom_field` rows. Future?> customFieldList({ListOpts? opts}) => requestList('/xapi2/data/custom_field', opts); /// Fetch one `custom_field` row by id. Future?> customFieldGet(String id) => requestJson('GET', '/xapi2/data/custom_field/' + id, null); /// Create a new `custom_field` row. Future?> customFieldCreate(Map data) => requestJson('POST', '/xapi2/data/custom_field', data); /// Patch a `custom_field` row. Future?> customFieldUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/custom_field/' + id, data); /// Delete a `custom_field` row. Future customFieldDelete(String id) async { await requestJson('DELETE', '/xapi2/data/custom_field/' + id, null); return true; } /// List `gift` rows. Future?> giftList({ListOpts? opts}) => requestList('/xapi2/data/gift', opts); /// Fetch one `gift` row by id. Future?> giftGet(String id) => requestJson('GET', '/xapi2/data/gift/' + id, null); /// Create a new `gift` row. Future?> giftCreate(Map data) => requestJson('POST', '/xapi2/data/gift', data); /// Patch a `gift` row. Future?> giftUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/gift/' + id, data); /// Delete a `gift` row. Future giftDelete(String id) async { await requestJson('DELETE', '/xapi2/data/gift/' + id, null); return true; } /// List `journal_entry` rows. Future?> journalEntryList({ListOpts? opts}) => requestList('/xapi2/data/journal_entry', opts); /// Fetch one `journal_entry` row by id. Future?> journalEntryGet(String id) => requestJson('GET', '/xapi2/data/journal_entry/' + id, null); /// Create a new `journal_entry` row. Future?> journalEntryCreate(Map data) => requestJson('POST', '/xapi2/data/journal_entry', data); /// Patch a `journal_entry` row. Future?> journalEntryUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/journal_entry/' + id, data); /// Delete a `journal_entry` row. Future journalEntryDelete(String id) async { await requestJson('DELETE', '/xapi2/data/journal_entry/' + id, null); return true; } /// List `life_event` rows. Future?> lifeEventList({ListOpts? opts}) => requestList('/xapi2/data/life_event', opts); /// Fetch one `life_event` row by id. Future?> lifeEventGet(String id) => requestJson('GET', '/xapi2/data/life_event/' + id, null); /// Create a new `life_event` row. Future?> lifeEventCreate(Map data) => requestJson('POST', '/xapi2/data/life_event', data); /// Patch a `life_event` row. Future?> lifeEventUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/life_event/' + id, data); /// Delete a `life_event` row. Future lifeEventDelete(String id) async { await requestJson('DELETE', '/xapi2/data/life_event/' + id, null); return true; } /// List `note` rows. Future?> noteList({ListOpts? opts}) => requestList('/xapi2/data/note', opts); /// Fetch one `note` row by id. Future?> noteGet(String id) => requestJson('GET', '/xapi2/data/note/' + id, null); /// Create a new `note` row. Future?> noteCreate(Map data) => requestJson('POST', '/xapi2/data/note', data); /// Patch a `note` row. Future?> noteUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/note/' + id, data); /// Delete a `note` row. Future noteDelete(String id) async { await requestJson('DELETE', '/xapi2/data/note/' + id, null); return true; } /// List `pet` rows. Future?> petList({ListOpts? opts}) => requestList('/xapi2/data/pet', opts); /// Fetch one `pet` row by id. Future?> petGet(String id) => requestJson('GET', '/xapi2/data/pet/' + id, null); /// Create a new `pet` row. Future?> petCreate(Map data) => requestJson('POST', '/xapi2/data/pet', data); /// Patch a `pet` row. Future?> petUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/pet/' + id, data); /// Delete a `pet` row. Future petDelete(String id) async { await requestJson('DELETE', '/xapi2/data/pet/' + id, null); return true; } /// List `relationship` rows. Future?> relationshipList({ListOpts? opts}) => requestList('/xapi2/data/relationship', opts); /// Fetch one `relationship` row by id. Future?> relationshipGet(String id) => requestJson('GET', '/xapi2/data/relationship/' + id, null); /// Create a new `relationship` row. Future?> relationshipCreate(Map data) => requestJson('POST', '/xapi2/data/relationship', data); /// Patch a `relationship` row. Future?> relationshipUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/relationship/' + id, data); /// Delete a `relationship` row. Future relationshipDelete(String id) async { await requestJson('DELETE', '/xapi2/data/relationship/' + id, null); return true; } /// List `reminder` rows. Future?> reminderList({ListOpts? opts}) => requestList('/xapi2/data/reminder', opts); /// Fetch one `reminder` row by id. Future?> reminderGet(String id) => requestJson('GET', '/xapi2/data/reminder/' + id, null); /// Create a new `reminder` row. Future?> reminderCreate(Map data) => requestJson('POST', '/xapi2/data/reminder', data); /// Patch a `reminder` row. Future?> reminderUpdate(String id, Map data) => requestJson('PATCH', '/xapi2/data/reminder/' + id, data); /// Delete a `reminder` row. Future reminderDelete(String id) async { await requestJson('DELETE', '/xapi2/data/reminder/' + id, null); return true; } } class _Response { final int status; final Map headers; final String body; const _Response(this.status, this.headers, this.body); }