Add raindrop settings
This commit is contained in:
@@ -42,6 +42,6 @@ module Adamantium
|
|||||||
setting :mastodon_token, default: nil
|
setting :mastodon_token, default: nil
|
||||||
setting :mastodon_server, default: nil
|
setting :mastodon_server, default: nil
|
||||||
|
|
||||||
setting :pinboard_api_key, default: nil
|
setting :raindrop_api_key, default: nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
require "pinboard"
|
|
||||||
require "dry/monads"
|
require "dry/monads"
|
||||||
|
|
||||||
module Adamantium
|
module Adamantium
|
||||||
module Syndication
|
module Syndication
|
||||||
class Pinboard
|
class Raindrop
|
||||||
attr_reader :pinboard
|
attr_reader :api_key
|
||||||
include Dry::Monads[:result]
|
include Dry::Monads[:result]
|
||||||
|
|
||||||
def initialize(api_key:)
|
def initialize(api_key:)
|
||||||
@pinboard = ::Pinboard::Client.new(token: api_key)
|
@api_key = api_key
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(post:)
|
def call(post:)
|
||||||
if pinboard.add(url: post[:url], description: post[:content]) == "done"
|
if response.code == 200
|
||||||
href = pinboard.get(url: post[:url]).first.href
|
result = JSON.parse(response, symbolize_name: true)
|
||||||
|
result[:item]
|
||||||
Success(href)
|
Success(href)
|
||||||
else
|
else
|
||||||
Failure(:failed_to_post_to_pinboard)
|
Failure(:failed_to_post_to_pinboard)
|
Reference in New Issue
Block a user