Module: LingutestClient::Api::Operations::Update::ClassMethods

Defined in:
lib/lingutest_client/api/operations/update.rb

Instance Method Summary collapse

Instance Method Details

#update(id, **params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/lingutest_client/api/operations/update.rb', line 8

def update(id, **params)
  schema = const_get(:UpdateSchema).call(params)
  unless schema.success?
    raise ValidationError,
          schema.errors.to_h.to_a.first.flatten.join(' ')
  end

  new(
    Client.put(
      member_resource_url(id), self::OBJECT_NAME => schema.to_h
    ).body[self::OBJECT_NAME]
  )
end