class CircleOrbit::Orbit

Public Class Methods

call(type:, data:, orbit_workspace:, orbit_api_key:) click to toggle source
# File lib/circle_orbit/orbit.rb, line 8
def self.call(type:, data:, orbit_workspace:, orbit_api_key:)
  if type == "post"
    CircleOrbit::Interactions::Post.new(
      post_title: data["name"],
      body: data["body"]["body"],
      created_at: data["body"]["created_at"],
      id: data["body"]["record_id"],
      space: data["space_name"],
      url: data["url"],
      author: data["user_name"],
      email: data["user_email"],
      workspace_id: orbit_workspace,
      api_key: orbit_api_key
    )
  end

  if type == "comment"
    CircleOrbit::Interactions::Comment.new(
      post_title: data["post_name"],
      body: data["body"]["body"],
      created_at: data["body"]["created_at"],
      id: data["body"]["record_id"],
      space: data["space_slug"].gsub(/-/, " ").capitalize,
      url: data["url"],
      author: data["user_name"],
      email: data["user_email"],
      workspace_id: orbit_workspace,
      api_key: orbit_api_key
    )
  end
end