class DevOrbit::Interactions::Follower
Public Class Methods
new(id:, name:, username:, url:, workspace_id:, api_key:)
click to toggle source
# File lib/dev_orbit/interactions/follower.rb, line 11 def initialize(id:, name:, username:, url:, workspace_id:, api_key:) @id = id @name = name @username = username @url = url @workspace_id = workspace_id @api_key = api_key after_initialize! end
Public Instance Methods
after_initialize!()
click to toggle source
# File lib/dev_orbit/interactions/follower.rb, line 22 def after_initialize! url = URI("https://app.orbit.love/api/v1/#{@workspace_id}/members") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true req = Net::HTTP::Post.new(url) req["Accept"] = "application/json" req["Content-Type"] = "application/json" req["Authorization"] = "Bearer #{@api_key}" req["User-Agent"] = "community-ruby-dev-orbit/#{DevOrbit::VERSION}" req.body = construct_body req.body = req.body.to_json response = http.request(req) JSON.parse(response.body) if DevOrbit::Utils.valid_json?(response.body) end
construct_body()
click to toggle source
# File lib/dev_orbit/interactions/follower.rb, line 42 def construct_body { member: { name: @name.include?("_") ? @name.split("_").map(&:capitalize).join(" ") : @name, devto: @username } } end