Send bookmarks to Raindrop
This commit is contained in:
@@ -11,12 +11,27 @@ module Adamantium
|
||||
end
|
||||
|
||||
def call(post:)
|
||||
if response.code == 200
|
||||
result = JSON.parse(response, symbolize_name: true)
|
||||
result[:item]
|
||||
Success(href)
|
||||
uri = URI('https://api.raindrop.io/rest/v1/raindrop')
|
||||
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
http.use_ssl = true
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
||||
dict = {
|
||||
"title" => post[:name],
|
||||
"link" => post[:url]
|
||||
}
|
||||
body = JSON.dump(dict)
|
||||
req = Net::HTTP::Post.new(uri)
|
||||
req.add_field "Authorization", api_key
|
||||
req.add_field "Content-Type", "application/json; charset=utf-8"
|
||||
req.body = body
|
||||
|
||||
response = http.request(req)
|
||||
|
||||
if response.code.to_s == "200"
|
||||
Success()
|
||||
else
|
||||
Failure(:failed_to_post_to_pinboard)
|
||||
Failure(:failed_to_post_to_raindrop)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user