Class: PortaText::Command::Api::Sounds

Inherits:
Base
  • Object
show all
Defined in:
lib/portatext/command/api/sounds.rb

Overview

The sounds endpoint. github.com/PortaText/docs/wiki/REST-API#api_sounds

Author

Marcelo Gornstein ([email protected])

Copyright

Copyright © 2015 PortaText

License

Apache-2.0

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#accept_content_type, #content_type, #delete, #get, #initialize, #patch, #post, #put, #set

Constructor Details

This class inherits a constructor from PortaText::Command::Base

Instance Method Details

#body(_method) ⇒ Object



31
32
33
34
# File 'lib/portatext/command/api/sounds.rb', line 31

def body(_method)
  return "file:#{@args[:sound_file]}" unless @args[:sound_file].nil?
  super
end

#description(description) ⇒ Object



19
20
21
# File 'lib/portatext/command/api/sounds.rb', line 19

def description(description)
  set :description, description
end

#endpoint(_method) ⇒ Object

rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/portatext/command/api/sounds.rb', line 38

def endpoint(_method)
  endpoint = 'sounds'
  id = @args[:id]
  @args.delete :id

  endpoint = "#{endpoint}/#{id}" unless id.nil?

  qs = {}
  unless @args[:description].nil?
    qs['description'] = @args[:description]
    @args.delete :description
  end

  unless @args[:name].nil?
    qs['name'] = @args[:name]
    @args.delete :name
  end

  unless qs.empty?
    qs = URI.encode_www_form qs
    return "#{endpoint}?#{qs}"
  end
  endpoint
end

#id(id) ⇒ Object



11
12
13
# File 'lib/portatext/command/api/sounds.rb', line 11

def id(id)
  set :id, id
end

#name(name) ⇒ Object



15
16
17
# File 'lib/portatext/command/api/sounds.rb', line 15

def name(name)
  set :name, name
end

#save_to(file) ⇒ Object



23
24
25
# File 'lib/portatext/command/api/sounds.rb', line 23

def save_to(file)
  set :accept_sound_file, file
end

#sound(file) ⇒ Object



27
28
29
# File 'lib/portatext/command/api/sounds.rb', line 27

def sound(file)
  set :sound_file, file
end