Add raindrop settings

This commit is contained in:
2023-04-10 13:53:08 +10:00
parent dc1a2dcdd1
commit 4729066bbc
2 changed files with 7 additions and 7 deletions

View File

@@ -1,19 +1,19 @@
require "pinboard"
require "dry/monads"
module Adamantium
module Syndication
class Pinboard
attr_reader :pinboard
class Raindrop
attr_reader :api_key
include Dry::Monads[:result]
def initialize(api_key:)
@pinboard = ::Pinboard::Client.new(token: api_key)
@api_key = api_key
end
def call(post:)
if pinboard.add(url: post[:url], description: post[:content]) == "done"
href = pinboard.get(url: post[:url]).first.href
if response.code == 200
result = JSON.parse(response, symbolize_name: true)
result[:item]
Success(href)
else
Failure(:failed_to_post_to_pinboard)