Sha256: d29641977d124cd09caa8f7b34d51feff561a43a13f913d21e96699a20f8faf0

Contents?: true

Size: 1.86 KB

Versions: 5

Compression:

Stored size: 1.86 KB

Contents

# frozen_string_literal: true

require "linkedin"
require "dotenv/load"
require "net/http"
require "json"

# Create a client to log LinkedIn interactions in your Orbit workspace
# Credentials can either be passed in to the instance or be loaded
# from environment variables
#
# @example
#   client = LinkedinOrbit::Client.new
#
# @option params [String] :orbit_api_key
#   The API key for the Orbit API
#
# @option params [String] :orbit_workspace
#   The workspace ID for the Orbit workspace
#
# @option params [String] :linkedin_token
#   The token obtained after authenticating with LinkedIn
#   Required if value not provided for LINKEDIN_TOKEN environment variable
#
# @option params [String] :linkedin_organization
#   The LinkedIn schema for the LinkedIn organization to log interactions from
#   For example, a company on LinkedIn with the web address of:
#   "https://www.linkedin.com/company/28866695"
#   The LinkedIn organization would use the last component of that web address and would be:
#   urn:li:organization:28866695
#
# @param [Hash] params
#
# @return [DevOrbit::Client]
#
module LinkedinOrbit
  class Client
    attr_accessor :orbit_api_key, :orbit_workspace, :linkedin_organization
    attr_reader :linkedin_token

    def initialize(params = {})
      @orbit_api_key = params.fetch(:orbit_api_key, ENV["ORBIT_API_KEY"])
      @orbit_workspace = params.fetch(:orbit_workspace, ENV["ORBIT_WORKSPACE_ID"])
      @linkedin_token = token
      @linkedin_organization = params.fetch(:linkedin_organization, ENV["LINKEDIN_ORGANIZATION"])
    end

    def token
      @token ||= ENV["LINKEDIN_TOKEN"]
    end

    def comments
      LinkedinOrbit::Linkedin.new(
        linkedin_token: @linkedin_token,
        linkedin_organization: @linkedin_organization,
        orbit_api_key: @orbit_api_key,
        orbit_workspace: @orbit_workspace
      ).process_comments
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
linkedin_orbit-0.1.4 lib/linkedin_orbit/client.rb
linkedin_orbit-0.1.3 lib/linkedin_orbit/client.rb
linkedin_orbit-0.1.2 lib/linkedin_orbit/client.rb
linkedin_orbit-0.1.1 lib/linkedin_orbit/client.rb
linkedin_orbit-0.1.0 lib/linkedin_orbit/client.rb