Skip to content

Commit

Permalink
add spec and instructions for activities check
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Greenberg committed May 19, 2021
1 parent c605739 commit c3b3386
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 2 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,29 @@ Once, you have an instantiated client, you can fetch Pipedrive deal notes and se
```ruby
client.notes
```
### Fetching Pipedrive Notes

Once, you have an instantiated client, you can fetch Pipedrive activities and send them to Orbit by invoking the `#activities` instance method:

```ruby
client.activities
```
## CLI Usage

You can also use this package with the included CLI. To use the CLI pass in the required environment variables on the command line before invoking the CLI:
You can also use this package with the included CLI. To use the CLI pass in the required environment variables on the command line before invoking the CLI.

To check for new deal notes:

```bash
$ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=... PIPEDRIVE_API_KEY=... PIPEDRIVE_URL=... bundle exec pipedrive_orbit --check_notes
```

To check for new activities:

```bash
$ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=... PIPEDRIVE_API_KEY=... PIPEDRIVE_URL=... bundle exec pipedrive_orbit --check_activities
```

## GitHub Actions Automation Setup

⚡ You can set up this integration in a matter of minutes using our GitHub Actions template. It will run regularly to add new activities to your Orbit workspace. All you need is a GitHub account.
Expand Down
10 changes: 10 additions & 0 deletions bin/pipedrive_orbit
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'optparse'

check_notes = false
check_activities = false

options = {}
choices = OptionParser.new do |opts|
Expand All @@ -14,6 +15,9 @@ choices = OptionParser.new do |opts|
opts.on("--check-notes", "Check for new Pipedrive deal notes") do
check_notes = true
end
opts.on("--check-check_activities", "Check for new Pipedrive activities") do
check_activities = true
end
end.parse!

$LOAD_PATH.unshift(File.expand_path('../lib/pipedrive_orbit', __dir__))
Expand All @@ -25,4 +29,10 @@ if check_notes
puts "Checking for new Pipedrive deal notes and posting them to your Orbit workspace..."
ARGV[0] = 'render'
PipedriveOrbit::Scripts::CheckNotes.start(ARGV)
end

if check_activities
puts "Checking for new Pipedrive activities and posting them to your Orbit workspace..."
ARGV[0] = 'render'
PipedriveOrbit::Scripts::CheckActivities.start(ARGV)
end
2 changes: 1 addition & 1 deletion lib/pipedrive_orbit/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal = true

module PipedriveOrbit
VERSION = "0.0.1"
VERSION = "0.0.2"
end
17 changes: 17 additions & 0 deletions scripts/check_activities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "pipedrive_orbit"
require "thor"

module PipedriveOrbit
module Scripts
class CheckActivities < Thor
desc "render", "check for new Pipedrive activities and push them to Orbit"
def render
client = PipedriveOrbit::Client.new
client.activities
end
end
end
end
50 changes: 50 additions & 0 deletions spec/interactions/activity_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

require "spec_helper"


RSpec.describe PipedriveOrbit::Interactions::Activity do
let(:subject) do
PipedriveOrbit::Interactions::Activity.new(
activity: {
"id" => "82",
"user_id" => "12301519",
"deal_id" => "1234",
"person_id" => "123",
"org_id" => "444",
"type" => "email",
"person_name" => "Testing Person",
"add_time" => "2021-05-18 05:11:52",
"note" => "Testing note"
},
pipedrive_url: "https://example.com",
orbit_workspace: "1234",
orbit_api_key: "12345",

)
end

describe "#call" do
context "when the type is a note" do
it "returns a Activity Object" do
stub_request(:post, "https://app.orbit.love/api/v1/1234/activities")
.with(
headers: { 'Authorization' => "Bearer 12345", 'Content-Type' => 'application/json', 'User-Agent'=>"community-ruby-pipedrive-orbit/#{PipedriveOrbit::VERSION}" },
body: "{\"activity\":{\"activity_type\":\"pipedrive:activity\",\"tags\":[\"channel:pipedrive\"],\"title\":\"Added New Email Activity to Pipedrive\",\"description\":\"Testing note\",\"occurred_at\":\"2021-05-18 05:11:52\",\"key\":\"82\",\"member\":{\"name\":\"Testing Person\"}},\"identity\":{\"source\":\"pipedrive\",\"name\":\"Testing Person\"}}"
)
.to_return(
status: 200,
body: {
response: {
code: 'SUCCESS'
}
}.to_json.to_s
)

content = subject.construct_body

expect(content[:activity][:key]).to eql("82")
end
end
end
end

0 comments on commit c3b3386

Please sign in to comment.