Class: Imagga::BaseCommand

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Exceptions
Defined in:
lib/imagga/commands.rb

Direct Known Subclasses

CropCommand, ExtractCommand

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Exceptions

#raise_if_request_failed!, #raise_missing

Constructor Details

#initialize(api_key, api_secret, base_uri) ⇒ BaseCommand

Returns a new instance of BaseCommand.



11
12
13
14
# File 'lib/imagga/commands.rb', line 11

def initialize(api_key, api_secret, base_uri)
  @api_key, @api_secret, @base_uri = api_key, api_secret, base_uri
  self.class.base_uri @base_uri
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



9
10
11
# File 'lib/imagga/commands.rb', line 9

def api_key
  @api_key
end

#api_secretObject (readonly)

Returns the value of attribute api_secret.



9
10
11
# File 'lib/imagga/commands.rb', line 9

def api_secret
  @api_secret
end

#base_uriObject (readonly)

Returns the value of attribute base_uri.



9
10
11
# File 'lib/imagga/commands.rb', line 9

def base_uri
  @base_uri
end

Instance Method Details

#args(options) ⇒ Object



22
23
24
# File 'lib/imagga/commands.rb', line 22

def args(options)
  options_class.new(api_key, api_secret).options(options)
end

#execute(options) ⇒ Object



16
17
18
19
20
# File 'lib/imagga/commands.rb', line 16

def execute(options)
  JSON.parse(self.class.post(service_path, body: args(options))).tap do |result|
    raise_if_request_failed!(result)
  end
end

#options_classObject



26
# File 'lib/imagga/commands.rb', line 26

def options_class; BaseOptions; end