Class: NewsmastMastodon::BoostPostService

Inherits:
BaseService
  • Object
show all
Includes:
RoutingHelper
Defined in:
app/services/newsmast_mastodon/boost_post_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(post_url) ⇒ BoostPostService

Returns a new instance of BoostPostService.



12
13
14
15
16
17
18
# File 'app/services/newsmast_mastodon/boost_post_service.rb', line 12

def initialize(post_url)
  @post_url = post_url
  @base_url = ENV['BOOST_POST_INSTANCE_URL']
  @api_key = ENV['BOOST_POST_API_KEY']
  @api_secret = ENV['BOOST_POST_API_SECRET']
  @endpoint = '/api/v1/statuses/boost_post'
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
# File 'app/services/newsmast_mastodon/boost_post_service.rb', line 20

def call
  payload  = create_payload
  response = perform_request(payload)
  parse_response(response)
rescue StandardError => e
  Rails.logger.error "[BoostPostService] Error: #{e.class} - #{e.message}"
  { status: :error, body: e.message }
end