Class: NewsmastMastodon::CustomBoostBotService
- Inherits:
-
BaseService
- Object
- BaseService
- NewsmastMastodon::CustomBoostBotService
- Defined in:
- app/services/newsmast_mastodon/custom_boost_bot_service.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(status_id, username) ⇒ CustomBoostBotService
constructor
A new instance of CustomBoostBotService.
Constructor Details
#initialize(status_id, username) ⇒ CustomBoostBotService
Returns a new instance of CustomBoostBotService.
9 10 11 12 13 14 |
# File 'app/services/newsmast_mastodon/custom_boost_bot_service.rb', line 9 def initialize(status_id, username) @base_url = ENV.fetch("#{username.upcase}_INSTANCE_URL", nil) @client_id = ENV.fetch("#{username.upcase}_CLIENT_ID", nil) @client_secret = ENV.fetch("#{username.upcase}_CLIENT_SECRET", nil) @status = Status.find_by(id: status_id) end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/newsmast_mastodon/custom_boost_bot_service.rb', line 16 def call return false unless @status url = @base_url + "/api/v1/custom_statuses/add_custom_boost_bot_status" status_url = build_status_url response = HTTParty.post(url, body: { client_id: @client_id, client_secret: @client_secret, status_url: status_url }.to_json, headers: { 'Content-Type' => 'application/json' }) end |