Class: Exa::Responses::Research
- Inherits:
-
T::Struct
- Object
- T::Struct
- Exa::Responses::Research
- Defined in:
- lib/exa/responses/research_response.rb
Class Method Summary collapse
Class Method Details
.from_hash(hash) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/exa/responses/research_response.rb', line 17 def self.from_hash(hash) sym = Helpers.symbolize_keys(hash) new( id: sym[:researchId], model: sym[:model], instructions: sym[:instructions], status: sym[:status], created_at: sym[:createdAt]&.to_i, events: Array(sym[:events]), operations: Array(sym[:operations]), output: normalize_hash(sym[:output]), error: sym[:error], raw: sym ) end |
.normalize_hash(value) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/exa/responses/research_response.rb', line 33 def self.normalize_hash(value) return nil if value.nil? value.each_with_object({}) do |(k, v), acc| acc[k.to_sym] = v end end |