Class: CircleOrbit::Orbit

Inherits:
Object
  • Object
show all
Defined in:
lib/circle_orbit/orbit.rb

Class Method Summary collapse

Class Method Details

.call(type:, data:, orbit_workspace:, orbit_api_key:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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