Send bookmarks to Raindrop

This commit is contained in:
2023-06-21 21:26:01 +10:00
parent 164e7496fd
commit 02ade37265
4 changed files with 27 additions and 9 deletions

View File

@@ -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