module Mushikago module Tombo class CaptureRequest < Request add_param :url add_param :image_format add_param :image_quality add_param :thumbnail do |v| (v.to_i != 0 ? 1 : 0).to_s end add_param :tags do |v| [v].flatten.compact.join(',') end def initialize url, options={} super(options) self.url = url self.image_format = options[:image_format] if options.has_key?(:image_format) self.image_quality = options[:image_quality] if options.has_key?(:image_quality) self.thumbnail = options[:thumbnail] if options.has_key?(:thumbnail) self.tags = options[:tags] if options.has_key?(:tags) @path = "/#{api_version}/capture.json" @headers['Content-type'] = 'application/x-www-form-urlencoded; charset=utf-8' end def new_http_request Net::HTTP::Post.new(path) end end end end