Class: OwlProxy::Service::Gyazo

Inherits:
Object
  • Object
show all
Defined in:
lib/owlproxy/services/gyazo.rb

Instance Method Summary collapse

Instance Method Details

#upload(config: nil, option: nil, image: nil, message: nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/owlproxy/services/gyazo.rb', line 7

def upload(config: nil, option: nil, image: nil, message: nil)
  # generate request
  request = RestClient::Request.new(
    method: :post,
    url: config['api_endpoint'],
    payload: {
      multipart: true,
      access_token: config['access_token'],
      imagedata: File.new(image)
    }
  )

  response = request.execute
  json = JSON.parse(response)

 "#{json["permalink_url"]} #{json["url"]}"
end