Sha256: 5ed5b7805373c8f17ee54984fc9365f98f2a61703a15511bd8a36328d79b1c00

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require "net/http"
require "json"

module CircleOrbit
  class Orbit
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
circle_orbit-0.0.1 lib/circle_orbit/orbit.rb