Module: LingutestClient::Api::Operations::Create::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#create(**params) ⇒ Object



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

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

  response = Client.post(
    resource_url, self::OBJECT_NAME => schema.to_h
  )
  new(response.body[self::OBJECT_NAME])
end