Class: LinkedinOrbit::Interactions::Comment
- Inherits:
-
Object
- Object
- LinkedinOrbit::Interactions::Comment
- Defined in:
- lib/linkedin_orbit/interactions/comment.rb
Instance Method Summary collapse
- #after_initialize! ⇒ Object
- #construct_body ⇒ Object
- #construct_description ⇒ Object
-
#initialize(title:, comment:, orbit_workspace:, orbit_api_key:) ⇒ Comment
constructor
A new instance of Comment.
- #name ⇒ Object
Constructor Details
#initialize(title:, comment:, orbit_workspace:, orbit_api_key:) ⇒ Comment
8 9 10 11 12 13 14 15 |
# File 'lib/linkedin_orbit/interactions/comment.rb', line 8 def initialize(title:, comment:, orbit_workspace:, orbit_api_key:) @title = title @comment = comment @orbit_workspace = orbit_workspace @orbit_api_key = orbit_api_key after_initialize! end |
Instance Method Details
#after_initialize! ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/linkedin_orbit/interactions/comment.rb', line 17 def after_initialize! OrbitActivities::Request.new( api_key: @orbit_api_key, workspace_id: @orbit_workspace, user_agent: "community-ruby-linkedin-orbit/#{LinkedinOrbit::VERSION}", action: "new_activity", body: construct_body.to_json ) end |
#construct_body ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/linkedin_orbit/interactions/comment.rb', line 27 def construct_body { activity: { activity_type: "linkedin:comment", tags: ["channel:linkedin"], title: "Commented on LinkedIn Post", description: construct_description, occurred_at: Time.at(@comment["created"]["time"] / 1000).utc, key: @comment["id"], link: "https://www.linkedin.com/feed/update/#{@comment["object"]}", link_text: "View on LinkedIn", member: { name: name } }, identity: { source: "linkedin", name: name, uid: @comment["actor"] } } end |
#construct_description ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/linkedin_orbit/interactions/comment.rb', line 58 def construct_description " LinkedIn post: \"\#{@title}...\"\n \\n\n Comment:\n \\n\n \"\#{@comment[\"message\"][\"text\"]}\"\n HEREDOC\nend\n" |
#name ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/linkedin_orbit/interactions/comment.rb', line 50 def name @name ||= begin return @comment["actor~"]["localizedName"] if @comment["actor~"]["localizedName"] "#{@comment["actor~"]["localizedFirstName"]} #{@comment["actor~"]["localizedLastName"]}" end end |