Class: VzaarApi::Strategy::Image::Create

Inherits:
Abstract
  • Object
show all
Defined in:
lib/vzaar_api/strategy/image/create.rb

Instance Attribute Summary

Attributes inherited from Abstract

#scope_id

Instance Method Summary collapse

Methods inherited from Abstract

#initialize, #update_from_attributes

Constructor Details

This class inherits a constructor from VzaarApi::Abstract

Instance Method Details

#executeObject

Raises:



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/vzaar_api/strategy/image/create.rb', line 5

def execute
  path = attrs[:path]
  raise Error.new('Invalid parameters: path is missing') unless path

  File.open(path, "r") do |file|
    res = Lib::Api.new.post(url, image: file) do |body, headers|
      headers.delete('Content-Type')
      [body, headers]
    end

    video_class.new res.data
  end
end