class PipedriveOrbit::Interactions::PersonNote
Public Class Methods
new(note:, pipedrive_url:, orbit_workspace:, orbit_api_key:)
click to toggle source
# File lib/pipedrive_orbit/interactions/person_note.rb, line 8 def initialize(note:, pipedrive_url:, orbit_workspace:, orbit_api_key:) @note = note @pipedrive_url = pipedrive_url @orbit_workspace = orbit_workspace @orbit_api_key = orbit_api_key after_initialize! end
Public Instance Methods
after_initialize!()
click to toggle source
# File lib/pipedrive_orbit/interactions/person_note.rb, line 17 def after_initialize! OrbitActivities::Request.new( api_key: @orbit_api_key, workspace_id: @orbit_workspace, user_agent: "community-ruby-pipedrive-orbit/#{PipedriveOrbit::VERSION}", body: construct_body.to_json ) end
construct_body()
click to toggle source
# File lib/pipedrive_orbit/interactions/person_note.rb, line 42 def construct_body hash = { activity: { activity_type: "pipedrive:person_note", tags: ["channel:pipedrive"], title: "Added Note to Person in Pipedrive", description: construct_description, occurred_at: @note["add_time"], key: @note["id"], member: { name: construct_name } }, identity: { source: "pipedrive", name: construct_name } } hash[:activity].merge!(link: construct_url) unless construct_url.nil? || construct_url == "" hash[:activity][:member].merge!(company: @note["organization"]["name"]) if @note["organization"] hash end
construct_description()
click to toggle source
# File lib/pipedrive_orbit/interactions/person_note.rb, line 67 def construct_description note = @note["content"].dup note.prepend("Note added for person in connection to #{@note["deal"]["title"]}:<br>") unless @note["deal"] == nil note end
construct_name()
click to toggle source
# File lib/pipedrive_orbit/interactions/person_note.rb, line 36 def construct_name return @note["person"]["name"] if @note["person"] @note["organization"]["name"] end
construct_url()
click to toggle source
# File lib/pipedrive_orbit/interactions/person_note.rb, line 26 def construct_url return nil if @note["deal_id"].nil? if @pipedrive_url.end_with?("/") return "#{pipedrive_url}deal/#{@note["deal_id"]}" end "#{@pipedrive_url}/deal/#{@note["deal_id"]}" end