chatwoot-develop/enterprise/app/services/captain/tools/parsers/status_suites_parser.rb

28 lines
754 B
Ruby

class Captain::Tools::Parsers::StatusSuitesParser
def self.parse(response_body)
# Assuming response_body is already a Hash or needs parsing
data = begin
response_body.is_a?(String) ? JSON.parse(response_body) : response_body
rescue StandardError
{}
end
# Example normalization logic based on prompt
{
tool_key: 'status_suites',
free: normalize_items(data['free'] || []),
occupied: normalize_items(data['occupied'] || []),
cleaning: normalize_items(data['cleaning'] || [])
}
end
def self.normalize_items(items)
items.map do |item|
{
suite: item['suite'] || item['id'],
category: item['category'] || item['categoria'] || 'Standard'
}
end
end
end