Class: PipedriveOrbit::Interactions::PersonNote
- Inherits:
-
Object
- Object
- PipedriveOrbit::Interactions::PersonNote
- Defined in:
- lib/pipedrive_orbit/interactions/person_note.rb
Instance Method Summary collapse
- #after_initialize! ⇒ Object
- #construct_body ⇒ Object
- #construct_description ⇒ Object
- #construct_name ⇒ Object
- #construct_url ⇒ Object
-
#initialize(note:, pipedrive_url:, orbit_workspace:, orbit_api_key:) ⇒ PersonNote
constructor
A new instance of PersonNote.
Constructor Details
#initialize(note:, pipedrive_url:, orbit_workspace:, orbit_api_key:) ⇒ PersonNote
Returns a new instance of PersonNote.
8 9 10 11 12 13 14 15 |
# 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 |
Instance Method Details
#after_initialize! ⇒ Object
17 18 19 20 21 22 23 24 |
# 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 ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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 ⇒ Object
67 68 69 70 71 72 73 |
# 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 ⇒ Object
36 37 38 39 40 |
# 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 ⇒ Object
26 27 28 29 30 31 32 33 34 |
# 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 |