Class: Tana::Endpoints::Add::Action

Inherits:
Object
  • Object
show all
Includes:
Pipeable
Defined in:
lib/tana/endpoints/add/action.rb

Overview

Adds a node to the graph.

Instance Method Summary collapse

Constructor Details

#initialize(request: Requests::Add.new, response: Responses::Root, model: Models::Root) ⇒ Action

rubocop:todo Metrics/ParameterLists



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tana/endpoints/add/action.rb', line 14

def initialize(
  request: Requests::Add.new,
  response: Responses::Root,
  model: Models::Root,
  **
)
  @request = request
  @response = response
  @model = model
  super(**)
end

Instance Method Details

#call(body) ⇒ Object

rubocop:enable Metrics/ParameterLists



27
28
29
30
31
32
33
34
35
36
# File 'lib/tana/endpoints/add/action.rb', line 27

def call(body, **)
  pipe body,
       validate(request),
       insert("addToNodeV2", at: 0),
       insert(**),
       to(client, :post),
       try(:parse, catch: JSON::ParserError),
       validate(response, as: :to_h),
       to(model, :for)
end