Add raindrop settings
This commit is contained in:
@@ -42,6 +42,6 @@ module Adamantium
|
||||
setting :mastodon_token, default: nil
|
||||
setting :mastodon_server, default: nil
|
||||
|
||||
setting :pinboard_api_key, default: nil
|
||||
setting :raindrop_api_key, default: nil
|
||||
end
|
||||
end
|
||||
|
@@ -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)
|
Reference in New Issue
Block a user