# class APIClient

- APIClient
- Reference
- Object

##
Defined in:

api_client.cr

##
Constant Summary

Log = `JosieHealth::Utils::Log`
VWRAPPED_TIMEOUT = `600`

  Timeout constants

##
Constructors

- .new

##
Instance Method Summary

- #annotate_last_dose(user_id : String, note_text : String) : Bool
- #check_interactions(substance1 : String, substance2 : String) : String | Nil
- #create_reminder(user_id : String, message : String, trigger_time : Int64, channel_id : UInt64, discord_user_id : UInt64, callback_url : String, recurrence : String = "") : String | Nil
- #delete_reminder(reminder_id : String) : Bool
- #delete_user_data(user_id : String) : String | Nil

  Delete all data for a user - returns deletion counts or nil on error

- #export_user_data(user_id : String) : String | Nil
- #get_alias(user_id : String, alias_name : String) : String | Nil
- #get_substance_dosage(substance_name : String) : String | Nil
- #get_substance_info(substance_name : String) : String | Nil
- #get_substance_info_formatted(substance_name : String) : String | Nil
- #get_user_aliases(user_id : String) : Hash(String, String)
- #get_user_data_stats(user_id : String) : String | Nil

  Get user data stats (counts of doses, vitals, etc.)

- #get_user_doseslogged(user_id : String) : String | Nil
- #get_user_grepdose(user_id : String, substance : String, n : Int32 | Nil = nil, roa : String | Nil = nil) : String | Nil
- #get_user_howhighami(user_id : String) : String | Nil
- #get_user_last_substance(user_id : String, substance : String) : String | Nil
- #get_user_lastdose(user_id : String, n : Int32 = 1) : String | Nil
- #get_user_listdose(user_id : String, n : Int32 = 5) : String | Nil
- #get_user_listdrugs(user_id : String) : String | Nil
- #get_user_reminders(user_id : String) : Array(Hash(String, String))
- #get_user_tally(user_id : String, substance : String) : String | Nil
- #get_user_timezone(user_id : String) : String | Nil
- #get_user_vwrapped(user_id : String, year : Int32) : String | Nil
- #get_user_vwrapped_with_status(user_id : String, year : Int32) : Tuple(Int32, String) | Nil
- #get_user_wrapped(user_id : String, year : Int32 | Nil = nil, alltime : Bool = false) : String | Nil
- #get_user_wrapped_image(user_id : String, year : Int32 | Nil = nil) : String | Nil
- #import_csv(user_id : String, csv_data : String) : String | Nil
- #list_api_keys(user_id : String) : String | Nil
- #log_lab_result(user_id : String, test_type : String, value : Float64, unit : String = "unknown", reference_range : String | Nil = nil, timestamp : String | Nil = nil) : Bool
- #log_medication(user_id : String, medication_name : String, dosage : String, route : String, unit : String = "", timestamp : String | Nil = nil, note_text : String = "") : String | Nil
- #log_raw_dose(user_id : String, raw_dose : String, timestamp : String | Nil = nil) : String | Nil

  Log a dose using raw_dose string - API parses substance, route, annotation

- #log_vitals(user_id : String, pulse : Int32 | Nil = nil, systolic_bp : Int32 | Nil = nil, diastolic_bp : Int32 | Nil = nil, blood_oxygen : Int32 | Nil = nil, notes : String | Nil = nil, timestamp : String | Nil = nil) : Bool
- #lookup_timezone(query : String) : Array(Hash(String, String)) | Nil

  Timezone lookup by city/country name

- #normalize_substance(substance_name : String) : String | Nil
- #remove_alias(user_id : String, alias_name : String) : Bool
- #revoke_api_key(user_id : String, prefix : String) : Bool
- #set_alias(user_id : String, alias_name : String, doses_string : String) : Bool
- #set_user_timezone(user_id : String, timezone : String) : Bool
- #start_vwrapped_video_async(user_id : String, year : Int32, request_id : String) : Tuple(Bool, String)
- #start_wrapped_image_async(user_id : String, year : Int32 | Nil, request_id : String) : Bool
- #undose_last_entry(user_id : String) : Bool

##
Constructor Detail

def self.new #

##
Instance Method Detail

def annotate_last_dose(user_id : String, note_text : String) : Bool #
def check_interactions(substance1 : String, substance2 : String) : String | Nil #
def create_reminder(user_id : String, message : String, trigger_time : Int64, channel_id : UInt64, discord_user_id : UInt64, callback_url : String, recurrence : String = "") : String | Nil #
def delete_reminder(reminder_id : String) : Bool #
def delete_user_data(user_id : String) : String | Nil #

Delete all data for a user - returns deletion counts or nil on error

def export_user_data(user_id : String) : String | Nil #
def get_alias(user_id : String, alias_name : String) : String | Nil #
def get_substance_dosage(substance_name : String) : String | Nil #
def get_substance_info(substance_name : String) : String | Nil #
def get_substance_info_formatted(substance_name : String) : String | Nil #
def get_user_aliases(user_id : String) : Hash(String, String) #
def get_user_data_stats(user_id : String) : String | Nil #

Get user data stats (counts of doses, vitals, etc.)

def get_user_doseslogged(user_id : String) : String | Nil #
def get_user_grepdose(user_id : String, substance : String, n : Int32 | Nil = nil, roa : String | Nil = nil) : String | Nil #
def get_user_howhighami(user_id : String) : String | Nil #
def get_user_last_substance(user_id : String, substance : String) : String | Nil #
def get_user_lastdose(user_id : String, n : Int32 = 1) : String | Nil #
def get_user_listdose(user_id : String, n : Int32 = 5) : String | Nil #
def get_user_listdrugs(user_id : String) : String | Nil #
def get_user_reminders(user_id : String) : Array(Hash(String, String)) #
def get_user_tally(user_id : String, substance : String) : String | Nil #
def get_user_timezone(user_id : String) : String | Nil #
def get_user_vwrapped(user_id : String, year : Int32) : String | Nil #
def get_user_vwrapped_with_status(user_id : String, year : Int32) : Tuple(Int32, String) | Nil #
def get_user_wrapped(user_id : String, year : Int32 | Nil = nil, alltime : Bool = false) : String | Nil #
def get_user_wrapped_image(user_id : String, year : Int32 | Nil = nil) : String | Nil #
def import_csv(user_id : String, csv_data : String) : String | Nil #
def list_api_keys(user_id : String) : String | Nil #
def log_lab_result(user_id : String, test_type : String, value : Float64, unit : String = "unknown", reference_range : String | Nil = nil, timestamp : String | Nil = nil) : Bool #
def log_medication(user_id : String, medication_name : String, dosage : String, route : String, unit : String = "", timestamp : String | Nil = nil, note_text : String = "") : String | Nil #
def log_raw_dose(user_id : String, raw_dose : String, timestamp : String | Nil = nil) : String | Nil #

Log a dose using raw_dose string - API parses substance, route, annotation

def log_vitals(user_id : String, pulse : Int32 | Nil = nil, systolic_bp : Int32 | Nil = nil, diastolic_bp : Int32 | Nil = nil, blood_oxygen : Int32 | Nil = nil, notes : String | Nil = nil, timestamp : String | Nil = nil) : Bool #
def lookup_timezone(query : String) : Array(Hash(String, String)) | Nil #

Timezone lookup by city/country name

def normalize_substance(substance_name : String) : String | Nil #
def remove_alias(user_id : String, alias_name : String) : Bool #
def revoke_api_key(user_id : String, prefix : String) : Bool #
def set_alias(user_id : String, alias_name : String, doses_string : String) : Bool #
def set_user_timezone(user_id : String, timezone : String) : Bool #
def start_vwrapped_video_async(user_id : String, year : Int32, request_id : String) : Tuple(Bool, String) #
def start_wrapped_image_async(user_id : String, year : Int32 | Nil, request_id : String) : Bool #
def undose_last_entry(user_id : String) : Bool #