Class: Asimov::ApiV1::Images

Inherits:
Base
  • Object
show all
Defined in:
lib/asimov/api_v1/images.rb

Overview

Class interface for API methods in the “/images” URI subspace.

Constant Summary collapse

URI_PREFIX =
"/images".freeze

Instance Method Summary collapse

Methods inherited from Base

#check_for_api_error, #http_delete, #http_get, #http_streamed_download, #initialize, #json_post, #multipart_post, #wrap_response_with_error_handling

Constructor Details

This class inherits a constructor from Asimov::ApiV1::Base

Instance Method Details

#create(parameters:) ⇒ Object



11
12
13
14
15
# File 'lib/asimov/api_v1/images.rb', line 11

def create(parameters:)
  raise MissingRequiredParameterError.new(:prompt) unless parameters[:prompt]

  json_post(path: "#{URI_PREFIX}/generations", parameters: parameters)
end

#create_edit(parameters:) ⇒ Object



17
18
19
20
21
# File 'lib/asimov/api_v1/images.rb', line 17

def create_edit(parameters:)
  raise MissingRequiredParameterError.new(:prompt) unless parameters[:prompt]

  multipart_post(path: "#{URI_PREFIX}/edits", parameters: open_files(parameters))
end

#create_variation(parameters:) ⇒ Object



23
24
25
# File 'lib/asimov/api_v1/images.rb', line 23

def create_variation(parameters:)
  multipart_post(path: "#{URI_PREFIX}/variations", parameters: open_files(parameters))
end