Class: Tama::Perception::Service
- Inherits:
-
Object
- Object
- Tama::Perception::Service
- Defined in:
- lib/tama/perception/service.rb
Instance Method Summary collapse
- #get_chain(space, slug, headers: {}, timeout: nil) ⇒ Object
-
#initialize(http) ⇒ Service
constructor
A new instance of Service.
- #list_concepts(entity_id, query: {}, headers: {}, timeout: nil) ⇒ Object
Constructor Details
#initialize(http) ⇒ Service
Returns a new instance of Service.
6 7 8 |
# File 'lib/tama/perception/service.rb', line 6 def initialize(http) @http = http end |
Instance Method Details
#get_chain(space, slug, headers: {}, timeout: nil) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/tama/perception/service.rb', line 10 def get_chain(space, slug, headers: {}, timeout: nil) @http.validate_namespace!("provision") space_id = space.is_a?(Neural::Space) ? space.id : space path = "perception/spaces/#{HTTP.segment(space_id, "space_id")}/chains/#{HTTP.segment(slug, "slug")}" @http.parse_data(@http.request(:get, path, headers:, timeout:), Chain) end |
#list_concepts(entity_id, query: {}, headers: {}, timeout: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tama/perception/service.rb', line 17 def list_concepts(entity_id, query: {}, headers: {}, timeout: nil) @http.validate_namespace!("perception") unless query.respond_to?(:each_pair) raise Error::ValidationError.new("query must be a hash", errors: {query: "must be a hash"}) end path = "entities/#{HTTP.segment(entity_id, "entity_id")}/concepts" response = @http.request(:get, path, query:, headers:, timeout:) @http.parse_data(response, Concept, list: true) end |