Class: RunApi::Midjourney::Resources::ImageToVideo
- Inherits:
-
Object
- Object
- RunApi::Midjourney::Resources::ImageToVideo
- Includes:
- Core::ResourceHelpers
- Defined in:
- lib/runapi/midjourney/resources/image_to_video.rb
Overview
Generates video from a source image.
Constant Summary collapse
- ENDPOINT =
"/api/v1/midjourney/image_to_video"- RESPONSE_CLASS =
Types::VideoTaskResponse
- COMPLETED_RESPONSE_CLASS =
Types::CompletedVideoTaskResponse
Instance Method Summary collapse
- #create(options: nil, **params) ⇒ Object
- #get(id, options: nil) ⇒ Object
-
#initialize(http) ⇒ ImageToVideo
constructor
A new instance of ImageToVideo.
- #run(options: nil, **params) ⇒ Object
Constructor Details
#initialize(http) ⇒ ImageToVideo
Returns a new instance of ImageToVideo.
14 |
# File 'lib/runapi/midjourney/resources/image_to_video.rb', line 14 def initialize(http) = (@http = http) |
Instance Method Details
#create(options: nil, **params) ⇒ Object
21 22 23 24 25 |
# File 'lib/runapi/midjourney/resources/image_to_video.rb', line 21 def create(options: nil, **params) params = compact_params(params) validate_contract!(CONTRACT["image-to-video"], params) request(:post, ENDPOINT, body: params, options: ) end |
#get(id, options: nil) ⇒ Object
27 28 29 |
# File 'lib/runapi/midjourney/resources/image_to_video.rb', line 27 def get(id, options: nil) request(:get, "#{ENDPOINT}/#{id}", options: ) end |
#run(options: nil, **params) ⇒ Object
16 17 18 19 |
# File 'lib/runapi/midjourney/resources/image_to_video.rb', line 16 def run(options: nil, **params) task = create(options: , **params) poll_until_complete { get(task.id, options: ) } end |