# frozen_string_literal: true # Drop-in Ruby client library for the Friendship Tracker HTTP API. # # Save this file under your project as `friendship_client.rb` and require # it directly: # # require_relative 'friendship_client' # c = FriendshipClient::Client.new('pat_...') # rows = c.account_list(limit: 20, sort: '-created_at') # fresh = c.account_create({ 'name' => 'Example GmbH' }) # # Every endpoint exposed by the HTTP API is wrapped as an # `_` instance method on Client. List methods take keyword # args; get/update/delete methods take the row id as their first # positional argument. # # Provided as-is, with no warranty. Vendor freely; modify as needed. # Targets Ruby 3.0+; uses only the stdlib (`net/http`, `json`, # `securerandom`, `uri`). # # DO NOT EDIT THIS FILE MANUALLY - re-download from the docs site. # Local edits will be overwritten by the once-per-day version check. require 'net/http' require 'uri' require 'json' require 'securerandom' require 'fileutils' module FriendshipClient APP_SLUG = 'friendship' APP_NAME = 'Friendship Tracker' MODULE_NAME = 'friendship_client' CLIENT_VERSION = '0.3.13' LANGUAGE = 'ruby' DEFAULT_BASE = 'https://friendship-tracker.com' # Per-type metadata baked at generation time. Inspect with JSON.parse # if you need the legal filters / sorts / max_limit per model without # an extra round-trip. TYPES_JSON = <<~'JSON_BLOB' {"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}}]}} JSON_BLOB RETRYABLE_STATUSES = [408, 425, 429, 500, 502, 503, 504].freeze MAX_RETRIES = 3 DEFAULT_TIMEOUT = 30 class ApiError < StandardError attr_reader :status, :body_raw def initialize(status, message, body = nil) super("HTTP #{status}: #{message}") @status = status @body_raw = body end end class Client def initialize(token = nil) env_base = ENV['XCLIENT_BASE_URL'] @base_url = (env_base && !env_base.empty? ? env_base : DEFAULT_BASE).sub(%r{/+\z}, '') @token = (token && !token.empty? ? token : ENV.fetch('XCLIENT_TOKEN', '')).to_s @device_id = self.class.send(:load_or_mint_device_id) @session_id = SecureRandom.uuid @meta_sent_once = false @autoupdate_tried = false @meta_lock = Mutex.new end def set_token(token); @token = (token || '').to_s; end def set_base_url(url); @base_url = (url || '').sub(%r{/+\z}, ''); end # ── Identifier persistence ───────────────────────────────────── def self.state_dir home = ENV['HOME'] || ENV['USERPROFILE'] return nil if home.nil? || home.empty? d = File.join(home, ".#friendship_client") FileUtils.mkdir_p(d, mode: 0o700) d rescue StandardError nil end private_class_method :state_dir def self.load_or_mint_device_id d = state_dir return SecureRandom.uuid if d.nil? f = File.join(d, 'device.json') if File.exist?(f) begin blob = JSON.parse(File.read(f)) did = blob['device_id'] return did if did.is_a?(String) && did.length >= 32 rescue StandardError # fall through to mint end end fresh = SecureRandom.uuid begin File.write(f, JSON.dump('device_id' => fresh)) File.chmod(0o600, f) rescue StandardError end fresh end private_class_method :load_or_mint_device_id def self.autoupdate_enabled? v = (ENV['XCLIENT_NO_AUTOUPDATE'] || '').downcase !%w[1 true yes].include?(v) end private_class_method :autoupdate_enabled? # ── Editor / runtime fingerprint ─────────────────────────────── def self.fingerprint tp = (ENV['TERM_PROGRAM'] || '').downcase { 'ruby_version' => RUBY_VERSION, 'ruby_engine' => RUBY_ENGINE, 'os' => RUBY_PLATFORM, 'term_program' => ENV['TERM_PROGRAM'], 'editor_env' => ENV['EDITOR'], 'ci' => !!(ENV['CI'] || ENV['GITHUB_ACTIONS']), 'claude_code' => !!(ENV['CLAUDECODE'] || ENV['CLAUDE_CODE_ENTRYPOINT']), 'codex' => !!ENV['CODEX_HOME'], 'vscode' => tp == 'vscode' && ENV['CURSOR_TRACE_ID'].nil?, 'cursor' => !!ENV['CURSOR_TRACE_ID'], 'antigravity' => !!ENV['ANTIGRAVITY_TRACE_ID'], 'jetbrains' => tp.include?('jetbrains'), } end private_class_method :fingerprint # ── HTTP transport ───────────────────────────────────────────── def request_list(path, opts = nil) qs = [] if opts.is_a?(Hash) opts.each do |k, v| next if v.nil? if k.to_s == 'filters' && v.is_a?(Hash) v.each { |fk, fv| next if fv.nil?; qs << "#{URI.encode_www_form_component(fk.to_s)}=#{URI.encode_www_form_component(fv.to_s)}" } next end qs << "#{URI.encode_www_form_component(k.to_s)}=#{URI.encode_www_form_component(v.to_s)}" end end path = path + (path.include?('?') ? '&' : '?') + qs.join('&') unless qs.empty? request_json('GET', path, nil) end def request_json(method, path, body) maybe_autoupdate url = @base_url + path json = body.nil? ? nil : JSON.dump(body) last_err = nil MAX_RETRIES.times do |attempt| begin status, headers, raw_body = send_following_redirects(method.to_s.upcase, url, json) fresh = headers['x-auth-refresh-token'] @token = fresh if fresh && !fresh.empty? if RETRYABLE_STATUSES.include?(status) && attempt + 1 < MAX_RETRIES ra = headers['retry-after'] sleep(self.class.send(:backoff_seconds, attempt, ra ? ra.to_f : nil)) next end parsed = raw_body.empty? ? nil : (JSON.parse(raw_body) rescue nil) if status >= 400 msg = parsed.is_a?(Hash) ? (parsed['detail'] || parsed['message'] || 'request failed') : 'request failed' emit_call_event(method, path, status, false) raise ApiError.new(status, msg, parsed) end emit_call_event(method, path, status, true) return parsed rescue ApiError raise rescue StandardError => e last_err = e sleep(self.class.send(:backoff_seconds, attempt, nil)) if attempt + 1 < MAX_RETRIES next if attempt + 1 < MAX_RETRIES emit_call_event(method, path, 0, false) raise ApiError.new(0, e.message) end end emit_call_event(method, path, 0, false) raise ApiError.new(0, last_err ? last_err.message : 'request failed') end # Walk the redirect chain manually so Authorization can be dropped # on cross-origin hops. Caps at 5 hops; mirrors RFC 7231 method # rewrite semantics. def send_following_redirects(method, url, json) current_url = url current_method = method current_json = json strip_auth = false 6.times do |hop| uri = URI.parse(current_url) Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', open_timeout: 15, read_timeout: DEFAULT_TIMEOUT) do |http| klass = case current_method when 'GET' then Net::HTTP::Get when 'POST' then Net::HTTP::Post when 'PATCH' then Net::HTTP::Patch when 'PUT' then Net::HTTP::Put when 'DELETE' then Net::HTTP::Delete when 'HEAD' then Net::HTTP::Head else Net::HTTP::Get end req = klass.new(uri.request_uri) req['Accept'] = 'application/json' req['User-Agent'] = user_agent req['X-Client-Channel'] = 'client_' + LANGUAGE req['X-Client-Version'] = CLIENT_VERSION req['X-Analytics-Device-Id'] = @device_id req['X-Analytics-Session-Id'] = @session_id req['Authorization'] = 'Bearer ' + @token if !strip_auth && !@token.empty? if current_json && current_method != 'GET' && current_method != 'HEAD' req['Content-Type'] = 'application/json' req.body = current_json end resp = http.request(req) status = resp.code.to_i headers = {} resp.each_header { |k, v| headers[k.downcase] = v } if status < 300 || status >= 400 || status == 304 || hop == 5 return [status, headers, resp.body.to_s] end loc = headers['location'] return [status, headers, resp.body.to_s] if loc.nil? || loc.empty? next_uri = (URI.parse(loc).absolute? rescue false) ? URI.parse(loc) : uri + loc if origin_of(next_uri) != origin_of(uri) strip_auth = true end if status == 303 || ([301, 302].include?(status) && current_method != 'GET' && current_method != 'HEAD') current_method = 'GET' current_json = nil end current_url = next_uri.to_s end end [0, {}, ''] end private :send_following_redirects def origin_of(uri) port = uri.port || (uri.scheme == 'https' ? 443 : 80) "#{uri.scheme}://#{uri.host}:#{port}".downcase end private :origin_of def self.backoff_seconds(attempt, retry_after) return [retry_after, 60.0].min if retry_after && retry_after >= 0 [2 ** attempt, 60.0].min.to_f end private_class_method :backoff_seconds def user_agent "#friendship_client/#{CLIENT_VERSION} (lib/#ruby; ruby/#{RUBY_VERSION})" end private :user_agent # ── Analytics ────────────────────────────────────────────────── def emit_call_event(method, path, status, ok) include_env = nil @meta_lock.synchronize do include_env = !@meta_sent_once @meta_sent_once = true end Thread.new do begin meta = { 'channel' => 'client_' + LANGUAGE, 'client_version' => CLIENT_VERSION, 'module_name' => MODULE_NAME, 'language' => LANGUAGE, 'os' => RUBY_PLATFORM, 'ruby_version' => RUBY_VERSION, } meta['env'] = self.class.send(:fingerprint) if include_env body = { 'device_id' => @device_id, 'session_id' => @session_id, 'events' => [{ 'type' => 'client.call', 'ts_client' => Time.now.to_i, 'meta' => { 'method' => method.to_s.upcase, 'path' => path.split('?').first[0, 128], 'status' => status.to_i, 'ok' => !!ok, }, }], 'meta' => meta, } uri = URI.parse(@base_url + '/xapi2/analytics/challenge') Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', open_timeout: 2, read_timeout: 4) do |http| req = Net::HTTP::Post.new(uri.request_uri) req['Content-Type'] = 'application/json' req['User-Agent'] = user_agent req.body = JSON.dump(body) http.request(req) end rescue StandardError # fire and forget end end end private :emit_call_event # ── Auto-update ──────────────────────────────────────────────── def maybe_autoupdate return if @autoupdate_tried @autoupdate_tried = true return unless self.class.send(:autoupdate_enabled?) Thread.new { run_autoupdate } end private :maybe_autoupdate def run_autoupdate d = self.class.send(:state_dir) return if d.nil? stamp = File.join(d, 'update_check.json') if File.exist?(stamp) begin blob = JSON.parse(File.read(stamp)) return if (Time.now.to_i - blob['checked_at'].to_i) < 86400 rescue StandardError end end File.write(stamp, JSON.dump('checked_at' => Time.now.to_i)) uri = URI.parse(@base_url + '/xapi2/clients/version') payload = nil Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', open_timeout: 2, read_timeout: 4) do |http| resp = http.request(Net::HTTP::Get.new(uri.request_uri)) payload = (JSON.parse(resp.body) rescue nil) end return unless payload.is_a?(Hash) && payload['version'] && payload['version'] != CLIENT_VERSION uri2 = URI.parse(@base_url + '/xapi2/clients/script.' + LANGUAGE) body = nil Net::HTTP.start(uri2.host, uri2.port, use_ssl: uri2.scheme == 'https', open_timeout: 2, read_timeout: 10) do |http| body = http.request(Net::HTTP::Get.new(uri2.request_uri)).body end return unless body.is_a?(String) && self.class.send(:looks_like_valid_client?, body) target = File.expand_path(__FILE__) tmp = "#{target}.tmp.#{SecureRandom.hex(6)}" File.write(tmp, body) File.rename(tmp, target) rescue StandardError # best-effort end private :run_autoupdate def self.looks_like_valid_client?(blob) return false unless blob.is_a?(String) && blob.bytesize >= 2000 %w[MODULE_NAME CLIENT_VERSION APP_SLUG request_json].all? { |m| blob.include?(m) } end private_class_method :looks_like_valid_client? # ── Generated per-type wrapper methods ───────────────────────── # Every model that exposes an op gets one `_` method # below. The runtime above does the heavy lifting; these wrappers # just pin the URL + HTTP verb. # List `activity` rows. Pass any allowed filters as keyword args. def activity_list(**opts) request_list('/xapi2/data/activity', opts) end # Fetch one `activity` row by id. def activity_get(id) request_json('GET', '/xapi2/data/activity/' + id, nil) end # Create a new `activity` row. def activity_create(data) request_json('POST', '/xapi2/data/activity', data) end # Patch a `activity` row. def activity_update(id, data) request_json('PATCH', '/xapi2/data/activity/' + id, data) end # Delete a `activity` row. Returns true on success. def activity_delete(id) request_json('DELETE', '/xapi2/data/activity/' + id, nil) true end # List `contact` rows. Pass any allowed filters as keyword args. def contact_list(**opts) request_list('/xapi2/data/contact', opts) end # Fetch one `contact` row by id. def contact_get(id) request_json('GET', '/xapi2/data/contact/' + id, nil) end # Create a new `contact` row. def contact_create(data) request_json('POST', '/xapi2/data/contact', data) end # Patch a `contact` row. def contact_update(id, data) request_json('PATCH', '/xapi2/data/contact/' + id, data) end # Delete a `contact` row. Returns true on success. def contact_delete(id) request_json('DELETE', '/xapi2/data/contact/' + id, nil) true end # List `conversation` rows. Pass any allowed filters as keyword args. def conversation_list(**opts) request_list('/xapi2/data/conversation', opts) end # Fetch one `conversation` row by id. def conversation_get(id) request_json('GET', '/xapi2/data/conversation/' + id, nil) end # Create a new `conversation` row. def conversation_create(data) request_json('POST', '/xapi2/data/conversation', data) end # Patch a `conversation` row. def conversation_update(id, data) request_json('PATCH', '/xapi2/data/conversation/' + id, data) end # Delete a `conversation` row. Returns true on success. def conversation_delete(id) request_json('DELETE', '/xapi2/data/conversation/' + id, nil) true end # List `custom_field` rows. Pass any allowed filters as keyword args. def custom_field_list(**opts) request_list('/xapi2/data/custom_field', opts) end # Fetch one `custom_field` row by id. def custom_field_get(id) request_json('GET', '/xapi2/data/custom_field/' + id, nil) end # Create a new `custom_field` row. def custom_field_create(data) request_json('POST', '/xapi2/data/custom_field', data) end # Patch a `custom_field` row. def custom_field_update(id, data) request_json('PATCH', '/xapi2/data/custom_field/' + id, data) end # Delete a `custom_field` row. Returns true on success. def custom_field_delete(id) request_json('DELETE', '/xapi2/data/custom_field/' + id, nil) true end # List `gift` rows. Pass any allowed filters as keyword args. def gift_list(**opts) request_list('/xapi2/data/gift', opts) end # Fetch one `gift` row by id. def gift_get(id) request_json('GET', '/xapi2/data/gift/' + id, nil) end # Create a new `gift` row. def gift_create(data) request_json('POST', '/xapi2/data/gift', data) end # Patch a `gift` row. def gift_update(id, data) request_json('PATCH', '/xapi2/data/gift/' + id, data) end # Delete a `gift` row. Returns true on success. def gift_delete(id) request_json('DELETE', '/xapi2/data/gift/' + id, nil) true end # List `journal_entry` rows. Pass any allowed filters as keyword args. def journal_entry_list(**opts) request_list('/xapi2/data/journal_entry', opts) end # Fetch one `journal_entry` row by id. def journal_entry_get(id) request_json('GET', '/xapi2/data/journal_entry/' + id, nil) end # Create a new `journal_entry` row. def journal_entry_create(data) request_json('POST', '/xapi2/data/journal_entry', data) end # Patch a `journal_entry` row. def journal_entry_update(id, data) request_json('PATCH', '/xapi2/data/journal_entry/' + id, data) end # Delete a `journal_entry` row. Returns true on success. def journal_entry_delete(id) request_json('DELETE', '/xapi2/data/journal_entry/' + id, nil) true end # List `life_event` rows. Pass any allowed filters as keyword args. def life_event_list(**opts) request_list('/xapi2/data/life_event', opts) end # Fetch one `life_event` row by id. def life_event_get(id) request_json('GET', '/xapi2/data/life_event/' + id, nil) end # Create a new `life_event` row. def life_event_create(data) request_json('POST', '/xapi2/data/life_event', data) end # Patch a `life_event` row. def life_event_update(id, data) request_json('PATCH', '/xapi2/data/life_event/' + id, data) end # Delete a `life_event` row. Returns true on success. def life_event_delete(id) request_json('DELETE', '/xapi2/data/life_event/' + id, nil) true end # List `note` rows. Pass any allowed filters as keyword args. def note_list(**opts) request_list('/xapi2/data/note', opts) end # Fetch one `note` row by id. def note_get(id) request_json('GET', '/xapi2/data/note/' + id, nil) end # Create a new `note` row. def note_create(data) request_json('POST', '/xapi2/data/note', data) end # Patch a `note` row. def note_update(id, data) request_json('PATCH', '/xapi2/data/note/' + id, data) end # Delete a `note` row. Returns true on success. def note_delete(id) request_json('DELETE', '/xapi2/data/note/' + id, nil) true end # List `pet` rows. Pass any allowed filters as keyword args. def pet_list(**opts) request_list('/xapi2/data/pet', opts) end # Fetch one `pet` row by id. def pet_get(id) request_json('GET', '/xapi2/data/pet/' + id, nil) end # Create a new `pet` row. def pet_create(data) request_json('POST', '/xapi2/data/pet', data) end # Patch a `pet` row. def pet_update(id, data) request_json('PATCH', '/xapi2/data/pet/' + id, data) end # Delete a `pet` row. Returns true on success. def pet_delete(id) request_json('DELETE', '/xapi2/data/pet/' + id, nil) true end # List `relationship` rows. Pass any allowed filters as keyword args. def relationship_list(**opts) request_list('/xapi2/data/relationship', opts) end # Fetch one `relationship` row by id. def relationship_get(id) request_json('GET', '/xapi2/data/relationship/' + id, nil) end # Create a new `relationship` row. def relationship_create(data) request_json('POST', '/xapi2/data/relationship', data) end # Patch a `relationship` row. def relationship_update(id, data) request_json('PATCH', '/xapi2/data/relationship/' + id, data) end # Delete a `relationship` row. Returns true on success. def relationship_delete(id) request_json('DELETE', '/xapi2/data/relationship/' + id, nil) true end # List `reminder` rows. Pass any allowed filters as keyword args. def reminder_list(**opts) request_list('/xapi2/data/reminder', opts) end # Fetch one `reminder` row by id. def reminder_get(id) request_json('GET', '/xapi2/data/reminder/' + id, nil) end # Create a new `reminder` row. def reminder_create(data) request_json('POST', '/xapi2/data/reminder', data) end # Patch a `reminder` row. def reminder_update(id, data) request_json('PATCH', '/xapi2/data/reminder/' + id, data) end # Delete a `reminder` row. Returns true on success. def reminder_delete(id) request_json('DELETE', '/xapi2/data/reminder/' + id, nil) true end end end