pipedrive_orbit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9335362bf049c2d9a22d9178b44a47ebae8dcbb78f8d2758a053dd65311cb4da
4
+ data.tar.gz: 61058eee3d43a573e3e64d9728b2fc7f5210a20fe2ee8500c3dda7c52614001e
5
+ SHA512:
6
+ metadata.gz: 3e8e428d5c715b2b25228dc003d67da8230ea36897096d8d0013d71feb7bcb3088aaf1620807effeb5192b5ff6fec4fec0c6aa7dee7c9607954394277782fdc7
7
+ data.tar.gz: 436ae33f3d8b8bef78136cc9ecf5bdc53a01ac87e2c45392f62085a36ea7b52d703379c83a6d52c07d7a96c5500b93ea8104fc82ab93878965d4c37cfc0e6f3c
data/.env.sample ADDED
@@ -0,0 +1,3 @@
1
+ PIPEDRIVE_API_KEY=
2
+ ORBIT_API_KEY=
3
+ ORBIT_WORKSPACE_ID=
@@ -0,0 +1,134 @@
1
+ <small><a href="../README.md">Back to README</a></small>
2
+
3
+ # Code of Conduct
4
+
5
+ ## Our Pledge
6
+
7
+ We as members, contributors, and leaders pledge to make participation in our
8
+ community a harassment-free experience for everyone, regardless of age, body
9
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
10
+ identity and expression, level of experience, education, socio-economic status,
11
+ nationality, personal appearance, race, caste, color, religion, or sexual identity
12
+ and orientation.
13
+
14
+ We pledge to act and interact in ways that contribute to an open, welcoming,
15
+ diverse, inclusive, and healthy community.
16
+
17
+ ## Our Standards
18
+
19
+ Examples of behavior that contributes to a positive environment for our
20
+ community include:
21
+
22
+ * Demonstrating empathy and kindness toward other people
23
+ * Being respectful of differing opinions, viewpoints, and experiences
24
+ * Giving and gracefully accepting constructive feedback
25
+ * Accepting responsibility and apologizing to those affected by our mistakes,
26
+ and learning from the experience
27
+ * Focusing on what is best not just for us as individuals, but for the
28
+ overall community
29
+
30
+ Examples of unacceptable behavior include:
31
+
32
+ * The use of sexualized language or imagery, and sexual attention or
33
+ advances of any kind
34
+ * Trolling, insulting or derogatory comments, and personal or political attacks
35
+ * Public or private harassment
36
+ * Publishing others' private information, such as a physical or email
37
+ address, without their explicit permission
38
+ * Other conduct which could reasonably be considered inappropriate in a
39
+ professional setting
40
+
41
+ ## Enforcement Responsibilities
42
+
43
+ Community leaders are responsible for clarifying and enforcing our standards of
44
+ acceptable behavior and will take appropriate and fair corrective action in
45
+ response to any behavior that they deem inappropriate, threatening, offensive,
46
+ or harmful.
47
+
48
+ Community leaders have the right and responsibility to remove, edit, or reject
49
+ comments, commits, code, wiki edits, issues, and other contributions that are
50
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
51
+ decisions when appropriate.
52
+
53
+ ## Scope
54
+
55
+ This Code of Conduct applies within all community spaces, and also applies when
56
+ an individual is officially representing the community in public spaces.
57
+ Examples of representing our community include using an official e-mail address,
58
+ posting via an official social media account, or acting as an appointed
59
+ representative at an online or offline event.
60
+
61
+ ## Enforcement
62
+
63
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
64
+ reported to the community leaders responsible for enforcement at
65
+ team@orbit.love.
66
+ All complaints will be reviewed and investigated promptly and fairly.
67
+
68
+ All community leaders are obligated to respect the privacy and security of the
69
+ reporter of any incident.
70
+
71
+ ## Enforcement Guidelines
72
+
73
+ Community leaders will follow these Community Impact Guidelines in determining
74
+ the consequences for any action they deem in violation of this Code of Conduct:
75
+
76
+ ### 1. Correction
77
+
78
+ **Community Impact**: Use of inappropriate language or other behavior deemed
79
+ unprofessional or unwelcome in the community.
80
+
81
+ **Consequence**: A private, written warning from community leaders, providing
82
+ clarity around the nature of the violation and an explanation of why the
83
+ behavior was inappropriate. A public apology may be requested.
84
+
85
+ ### 2. Warning
86
+
87
+ **Community Impact**: A violation through a single incident or series
88
+ of actions.
89
+
90
+ **Consequence**: A warning with consequences for continued behavior. No
91
+ interaction with the people involved, including unsolicited interaction with
92
+ those enforcing the Code of Conduct, for a specified period of time. This
93
+ includes avoiding interactions in community spaces as well as external channels
94
+ like social media. Violating these terms may lead to a temporary or
95
+ permanent ban.
96
+
97
+ ### 3. Temporary Ban
98
+
99
+ **Community Impact**: A serious violation of community standards, including
100
+ sustained inappropriate behavior.
101
+
102
+ **Consequence**: A temporary ban from any sort of interaction or public
103
+ communication with the community for a specified period of time. No public or
104
+ private interaction with the people involved, including unsolicited interaction
105
+ with those enforcing the Code of Conduct, is allowed during this period.
106
+ Violating these terms may lead to a permanent ban.
107
+
108
+ ### 4. Permanent Ban
109
+
110
+ **Community Impact**: Demonstrating a pattern of violation of community
111
+ standards, including sustained inappropriate behavior, harassment of an
112
+ individual, or aggression toward or disparagement of classes of individuals.
113
+
114
+ **Consequence**: A permanent ban from any sort of public interaction within
115
+ the community.
116
+
117
+ ## Attribution
118
+
119
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
120
+ version 2.0, available at
121
+ [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
122
+
123
+ Community Impact Guidelines were inspired by
124
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
128
+ at [https://www.contributor-covenant.org/translations][translations].
129
+
130
+ [homepage]: https://www.contributor-covenant.org
131
+ [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
132
+ [Mozilla CoC]: https://github.com/mozilla/diversity
133
+ [FAQ]: https://www.contributor-covenant.org/faq
134
+ [translations]: https://www.contributor-covenant.org/translations
@@ -0,0 +1,69 @@
1
+ <small><a href="../README.md">Back to README</a></small>
2
+
3
+ # Contributing Guidelines
4
+
5
+ We 💜 contributions from everyone! 🎉
6
+
7
+ It is a good idea to [talk to us on Discord](https://discord.orbit.love/) first if you plan to add any new functionality. Otherwise, bug reports, bug fixes and feedback on this project is always appreciated.
8
+
9
+ ![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat "Contributions Welcome")
10
+
11
+ The following is a set of guidelines for contributing to this project, which are hosted on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
12
+
13
+ Please take the time to review the [Code of Conduct](CODE_OF_CONDUCT.md), which all contributors are subject to on this project.
14
+
15
+ **Table of Contents**
16
+
17
+ - [Reporting Bugs](#reporting-bugs)
18
+ - [Suggesting Enhancements](#suggesting-enhancements)
19
+ - [Pull Requests](#pull-requests)
20
+
21
+ ## Reporting Bugs
22
+
23
+ This section guides you through submitting a bug report. Following these guidelines helps maintainers and the community understand your report , reproduce the behavior, and find related reports.
24
+
25
+ Before creating bug reports, please do a quick search of existing issues as you might find out that you don't need to create one.
26
+
27
+ When you are creating a bug report, please include as many details as possible. Fill out the required template, the information it asks for helps us resolve issues faster.
28
+
29
+ ### How Do I Submit A (Good) Bug Report?
30
+
31
+ Bugs are tracked as GitHub issues. Create an issue and provide the following information by filling in the provided template which appears when you try and open an issue.
32
+
33
+ Explain the problem and include additional details to help maintainers reproduce the problem:
34
+
35
+ * **Use a clear and descriptive title** for the issue to identify the problem.
36
+ * **Describe the exact steps which reproduce the problem** in as many details as possible. For example, start by explaining how you started. When listing steps, **don't just say what you did, but explain how you did it**.
37
+ * **Provide specific examples to demonstrate the steps**. Include links to files or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use Markdown code blocks.
38
+ * **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
39
+ * **Explain which behavior you expected to see instead and why.**
40
+ * **Include screenshots and animated GIFs** where possible. Show how you follow the described steps and clearly demonstrate the problem.
41
+ * **If the problem wasn't triggered by a specific action**, describe what you were doing before the problem happened and share more information using the guidelines below.
42
+ * **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens.
43
+ Include details about your configuration and environment:
44
+
45
+ ## Suggesting Enhancements
46
+
47
+ This section guides you through submitting a suggestion, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion and find related suggestions.
48
+
49
+ Before creating a suggestion, please do a quick search of existing issues as you might find out that you don't need to create one.
50
+
51
+ ### How Do I Submit A (Good) Enhancement Suggestion?
52
+
53
+ Enhancement suggestions are tracked as GitHub issues. Create an issue and provide the following information by filling in the provided template which appears when you try and open an issue.
54
+
55
+ * **Use a clear and descriptive title** for the issue to identify the suggestion.
56
+ * **Provide a step-by-step description of the suggested enhancement** in as many details as possible.
57
+ * **Provide specific examples to demonstrate the steps**. Include copy/pasteable snippets which you use in those examples, as Markdown code blocks.
58
+ * **Describe the current behavior** and **explain which behavior you expected to see instead** and why.
59
+ * **Explain why this enhancement would be useful** to most users.
60
+
61
+ ## Pull Requests
62
+
63
+ Please follow these steps to have your contribution considered by the maintainers:
64
+
65
+ 1. Follow all instructions in the template.
66
+ 2. Adhear the Code of Conduct.
67
+ 3. After you submit your pull request, verify that all [status checks](https://help.github.com/articles/about-status-checks/) are passing.
68
+
69
+ While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional design work, tests, or other changes before your pull request can be ultimately accepted.
@@ -0,0 +1,25 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ strategy:
12
+ matrix:
13
+ os: [ubuntu-latest, macos-latest]
14
+ ruby: [2.7, 3.0]
15
+ runs-on: ${{ matrix.os }}
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Set up Ruby
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby }}
22
+ - name: Install dependencies
23
+ run: bundle install
24
+ - name: Run tests
25
+ run: bundle exec rspec
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ .env
2
+ *.db
3
+ .DS_Store
4
+ node_modules
5
+ *.gem
6
+ *.rbc
7
+ *.sassc
8
+ .bundle
9
+ .config
10
+ .yardoc
11
+ .rvmrc
12
+ .rspec
13
+ .sass-cache
14
+ .DS_Store
15
+ Gemfile.lock # gem projects only!
16
+ InstalledFiles
17
+ _yardoc
18
+ coverage
19
+ lib/bundler/man
20
+ capybara-*.html
21
+ pkg
22
+ rdoc
23
+ spec/reports
24
+ spec/tmp
25
+ test/tmp
26
+ test/version_tmp
27
+ tmp
28
+ logs
29
+ *.log
30
+ npm-debug.log*
31
+ yarn-debug.log*
32
+ yarn-error.log*
33
+ .npm
34
+ .byebug_history
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ gem "rake", "~> 13.0"
8
+
9
+ gem "rubocop", "~> 1.7"
10
+
11
+ gem "orbit_activities"
12
+
13
+ gem "byebug"
data/Gemfile.lock ADDED
@@ -0,0 +1,103 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pipedrive_orbit (0.0.1)
5
+ dotenv (~> 2.7)
6
+ http (~> 4.4)
7
+ json (~> 2.5)
8
+ orbit_activities (~> 0.0.2)
9
+ thor (~> 1.1)
10
+ zeitwerk (~> 2.4)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ addressable (2.7.0)
16
+ public_suffix (>= 2.0.2, < 5.0)
17
+ ast (2.4.2)
18
+ byebug (11.1.3)
19
+ crack (0.4.5)
20
+ rexml
21
+ diff-lcs (1.4.4)
22
+ domain_name (0.5.20190701)
23
+ unf (>= 0.0.5, < 1.0.0)
24
+ dotenv (2.7.6)
25
+ ffi (1.15.0)
26
+ ffi-compiler (1.0.1)
27
+ ffi (>= 1.0.0)
28
+ rake
29
+ hashdiff (1.0.1)
30
+ http (4.4.1)
31
+ addressable (~> 2.3)
32
+ http-cookie (~> 1.0)
33
+ http-form_data (~> 2.2)
34
+ http-parser (~> 1.2.0)
35
+ http-cookie (1.0.3)
36
+ domain_name (~> 0.5)
37
+ http-form_data (2.3.0)
38
+ http-parser (1.2.3)
39
+ ffi-compiler (>= 1.0, < 2.0)
40
+ json (2.5.1)
41
+ orbit_activities (0.0.2)
42
+ http (~> 4.4)
43
+ json (~> 2.5)
44
+ rake (~> 13.0)
45
+ zeitwerk (~> 2.4)
46
+ parallel (1.20.1)
47
+ parser (3.0.1.1)
48
+ ast (~> 2.4.1)
49
+ public_suffix (4.0.6)
50
+ rainbow (3.0.0)
51
+ rake (13.0.3)
52
+ regexp_parser (2.1.1)
53
+ rexml (3.2.5)
54
+ rspec (3.10.0)
55
+ rspec-core (~> 3.10.0)
56
+ rspec-expectations (~> 3.10.0)
57
+ rspec-mocks (~> 3.10.0)
58
+ rspec-core (3.10.1)
59
+ rspec-support (~> 3.10.0)
60
+ rspec-expectations (3.10.1)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.10.0)
63
+ rspec-mocks (3.10.2)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.10.0)
66
+ rspec-support (3.10.2)
67
+ rubocop (1.15.0)
68
+ parallel (~> 1.10)
69
+ parser (>= 3.0.0.0)
70
+ rainbow (>= 2.2.2, < 4.0)
71
+ regexp_parser (>= 1.8, < 3.0)
72
+ rexml
73
+ rubocop-ast (>= 1.5.0, < 2.0)
74
+ ruby-progressbar (~> 1.7)
75
+ unicode-display_width (>= 1.4.0, < 3.0)
76
+ rubocop-ast (1.5.0)
77
+ parser (>= 3.0.1.1)
78
+ ruby-progressbar (1.11.0)
79
+ thor (1.1.0)
80
+ unf (0.1.4)
81
+ unf_ext
82
+ unf_ext (0.0.7.7)
83
+ unicode-display_width (2.0.0)
84
+ webmock (3.13.0)
85
+ addressable (>= 2.3.6)
86
+ crack (>= 0.3.2)
87
+ hashdiff (>= 0.4.0, < 2.0.0)
88
+ zeitwerk (2.4.2)
89
+
90
+ PLATFORMS
91
+ arm64-darwin-20
92
+
93
+ DEPENDENCIES
94
+ byebug
95
+ orbit_activities
96
+ pipedrive_orbit!
97
+ rake (~> 13.0)
98
+ rspec (~> 3.4)
99
+ rubocop (~> 1.7)
100
+ webmock (~> 3.12)
101
+
102
+ BUNDLED WITH
103
+ 2.2.16
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Orbit Labs, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Pipedrive Interactions to Orbit Workspace
2
+
3
+ ![Build Status](https://github.com/orbit-love/community-ruby-pipedrive-orbit/workflows/CI/badge.svg)
4
+ [![Gem Version](https://badge.fury.io/rb/pipedrive_orbit.svg)](https://badge.fury.io/rb/pipedrive_orbit)
5
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](.github/CODE_OF_CONDUCT.md)
6
+
7
+ Add your Pipedrive CRM interactions into your Orbit workspace with this community-built integration.
8
+
9
+ |<p align="left">:sparkles:</p> This is a *community project*. The Orbit team does its best to maintain it and keep it up to date with any recent API changes.<br/><br/>We welcome community contributions to make sure that it stays current. <p align="right">:sparkles:</p>|
10
+ |-----------------------------------------|
11
+
12
+ ![There are three ways to use this integration. Install package - build and run your own applications. Run the CLI - run on-demand directly from your terminal. Schedule an automation with GitHub - get started in minutes - no coding required](readme-images/ways-to-use.png)
13
+
14
+ ## First Time Setup
15
+
16
+ To set up this integration you will need your Pipedrive API key and Pipedrive organization URL. See the below table for instructions on where to find those details.
17
+ ## Application Credentials
18
+
19
+ The application requires the following environment variables:
20
+
21
+ | Variable | Description | More Info
22
+ |---|---|--|
23
+ | `PIPEDRIVE_API_KEY` | API key for Pipedrive | Found in `Personal Preferences -> API` in your Pipedrive user settings
24
+ | `PIPEDRIVE_URL` | Organizational Pipedrive URL | First part of the Pipedrive organization URL, i.e. `https://example-134554.pipedrive.com`
25
+ | `ORBIT_API_KEY` | API key for Orbit | Found in `Account Settings` in your Orbit workspace
26
+ | `ORBIT_WORKSPACE_ID` | ID for your Orbit workspace | Last part of the Orbit workspace URL, i.e. `https://app.orbit.love/my-workspace`, the ID is `my-workspace`
27
+
28
+ ## Package Usage
29
+
30
+ Install the package with the following command
31
+
32
+ ```
33
+ $ gem install pipedrive_orbit
34
+ ```
35
+
36
+ Then, run `bundle install` from your terminal.
37
+
38
+ You can instantiate a client by either passing in the required credentials during instantiation or by providing them in your `.env` file.
39
+
40
+ ### Instantiation with credentials:
41
+
42
+ ```ruby
43
+ client = PipedriveOrbit::Client.new(
44
+ orbit_api_key: YOUR_API_KEY,
45
+ orbit_workspace_id: YOUR_ORBIT_WORKSPACE_ID,
46
+ pipedrive_api_key: YOUR_PIPEDRIVE_API_KEY,
47
+ pipedrive_url: YOUR_PIPEDRIVE_URL
48
+ )
49
+ ```
50
+
51
+ ### Instantiation with credentials in dotenv file:
52
+
53
+ ```ruby
54
+ client = PipedriveOrbit::Client.new
55
+ ```
56
+ ### Fetching Pipedrive Notes
57
+
58
+ Once, you have an instantiated client, you can fetch Pipedrive deal notes and send them to Orbit by invoking the `#notes` instance method:
59
+
60
+ ```ruby
61
+ client.notes
62
+ ```
63
+ ## CLI Usage
64
+
65
+ 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:
66
+
67
+ ```bash
68
+ $ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=... PIPEDRIVE_API_KEY=... PIPEDRIVE_URL=... bundle exec pipedrive_orbit --check_notes
69
+ ```
70
+ ## GitHub Actions Automation Setup
71
+
72
+ ⚡ 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.
73
+
74
+ [See our guide for setting up this automation](https://github.com/orbit-love/github-actions-templates/blob/main/Pipedrive/README.md)
75
+
76
+ ## Contributing
77
+
78
+ We 💜 contributions from everyone! Check out the [Contributing Guidelines](.github/CONTRIBUTING.md) for more information.
79
+
80
+ ## License
81
+
82
+ This project is under the [MIT License](./LICENSE).
83
+
84
+ ## Code of Conduct
85
+
86
+ This project uses the [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). We ask everyone to please adhere by its guidelines.
@@ -0,0 +1,28 @@
1
+
2
+ #!/usr/bin/env ruby
3
+ require 'optparse'
4
+
5
+ check_notes = false
6
+
7
+ options = {}
8
+ choices = OptionParser.new do |opts|
9
+ opts.banner = "Usage: pipedrive_orbit --check-notes"
10
+ opts.on("-h", "--help", "Prints help instructions") do
11
+ puts opts
12
+ exit
13
+ end
14
+ opts.on("--check-notes", "Check for new Pipedrive deal notes") do
15
+ check_notes = true
16
+ end
17
+ end.parse!
18
+
19
+ $LOAD_PATH.unshift(File.expand_path('../lib/pipedrive_orbit', __dir__))
20
+
21
+ require_relative '../lib/pipedrive_orbit'
22
+ require_relative '../scripts/check_notes'
23
+
24
+ if check_notes
25
+ puts "Checking for new Pipedrive deal notes and posting them to your Orbit workspace..."
26
+ ARGV[0] = 'render'
27
+ PipedriveOrbit::Scripts::CheckNotes.start(ARGV)
28
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "zeitwerk"
4
+ require "orbit_activities"
5
+ require_relative "pipedrive_orbit/version"
6
+
7
+ module PipedriveOrbit
8
+ loader = Zeitwerk::Loader.new
9
+ loader.tag = File.basename(__FILE__, ".rb")
10
+ loader.push_dir(__dir__)
11
+ loader.setup
12
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dotenv/load"
4
+ require "net/http"
5
+ require "json"
6
+
7
+ # Create a client to log Pipedrive activities and notes in your Orbit workspace
8
+ # Credentials can either be passed in to the instance or be loaded
9
+ # from environment variables
10
+ #
11
+ # @example
12
+ # client = PipedriveOrbit::Client.new
13
+ #
14
+ # @option params [String] :orbit_api_key
15
+ # The API key for the Orbit API
16
+ #
17
+ # @option params [String] :orbit_workspace
18
+ # The workspace ID for the Orbit workspace
19
+ #
20
+ # @option params [String] :pipedrive_api_key
21
+ # The token obtained after authenticating with LinkedIn
22
+ # Required if value not provided for Pipedrive API key environment variable
23
+ #
24
+ # @option params [String] :pipedrive_url
25
+ # The Pipedrive organization website URL
26
+ #
27
+ # @param [Hash] params
28
+ #
29
+ # @return [PipedriveOrbit::Client]
30
+ #
31
+ module PipedriveOrbit
32
+ class Client
33
+ attr_accessor :orbit_api_key, :orbit_workspace, :pipedrive_api_key, :pipedrive_url
34
+
35
+ def initialize(params = {})
36
+ @orbit_api_key = params.fetch(:orbit_api_key, ENV["ORBIT_API_KEY"])
37
+ @orbit_workspace = params.fetch(:orbit_workspace, ENV["ORBIT_WORKSPACE_ID"])
38
+ @pipedrive_api_key = params.fetch(:pipedrive_api_key, ENV["PIPEDRIVE_API_KEY"])
39
+ @pipedrive_url = params.fetch(:pipedrive_url, ENV["PIPEDRIVE_URL"])
40
+ end
41
+
42
+ def notes
43
+ PipedriveOrbit::Pipedrive.new(
44
+ pipedrive_api_key: @pipedrive_api_key,
45
+ pipedrive_url: @pipedrive_url,
46
+ orbit_api_key: @orbit_api_key,
47
+ orbit_workspace: @orbit_workspace
48
+ ).process_notes
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module PipedriveOrbit
6
+ module Interactions
7
+ class Note
8
+ def initialize(note:, pipedrive_url:, orbit_workspace:, orbit_api_key:)
9
+ @note = note
10
+ @pipedrive_url = pipedrive_url
11
+ @orbit_workspace = orbit_workspace
12
+ @orbit_api_key = orbit_api_key
13
+
14
+ after_initialize!
15
+ end
16
+
17
+ def after_initialize!
18
+ OrbitActivities::Request.new(
19
+ api_key: @orbit_api_key,
20
+ workspace_id: @orbit_workspace,
21
+ user_agent: "community-ruby-pipedrive-orbit/#{PipedriveOrbit::VERSION}",
22
+ body: construct_body.to_json
23
+ )
24
+ end
25
+
26
+ def construct_url
27
+ return nil if @note["deal_id"].nil?
28
+
29
+ if @pipedrive_url.end_with?("/")
30
+ return "#{pipedrive_url}deal/#{@note["deal_id"]}"
31
+ end
32
+
33
+ "#{@pipedrive_url}/deal/#{@note["deal_id"]}"
34
+ end
35
+
36
+ def construct_name
37
+ return @note["person"]["name"] if @note["person"]
38
+
39
+ @note["organization"]["name"]
40
+ end
41
+
42
+ def construct_body
43
+ hash = {
44
+ activity: {
45
+ activity_type: "pipedrive:note",
46
+ tags: ["channel:pipedrive"],
47
+ title: "Added Note to Pipedrive",
48
+ description: construct_description,
49
+ occurred_at: @note["add_time"],
50
+ key: @note["id"],
51
+ member: {
52
+ name: construct_name
53
+ }
54
+ },
55
+ identity: {
56
+ source: "pipedrive",
57
+ name: construct_name
58
+ }
59
+ }
60
+
61
+ hash[:activity].merge!(link: construct_url) unless construct_url.nil? || construct_url == ""
62
+ hash[:activity][:member].merge!(company: @note["organization"]["name"]) if @note["organization"]
63
+
64
+ hash
65
+ end
66
+
67
+ def construct_description
68
+ note = @note["content"].dup
69
+
70
+ note.prepend("Note added for deal - #{@note["deal"]["title"]}:<br>") unless @note["deal"] == nil
71
+
72
+ note
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PipedriveOrbit
4
+ class Orbit
5
+ def self.call(type:, data:, orbit_workspace:, orbit_api_key:)
6
+ if type == "note"
7
+ PipedriveOrbit::Interactions::Note.new(
8
+ note: data[:note],
9
+ pipedrive_url: data[:pipedrive_url],
10
+ orbit_workspace: orbit_workspace,
11
+ orbit_api_key: orbit_api_key
12
+ )
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PipedriveOrbit
4
+ class Pipedrive
5
+ def initialize(params = {})
6
+ @orbit_api_key = params.fetch(:orbit_api_key)
7
+ @orbit_workspace = params.fetch(:orbit_workspace)
8
+ @pipedrive_api_key = params.fetch(:pipedrive_api_key)
9
+ @pipedrive_url = params.fetch(:pipedrive_url)
10
+ end
11
+
12
+ def process_notes
13
+ notes = get_notes
14
+
15
+ notes["data"].each do |note|
16
+ next if note["person"] == nil || note["organization"] == nil
17
+
18
+ PipedriveOrbit::Orbit.call(
19
+ type: "note",
20
+ data: {
21
+ note: note,
22
+ pipedrive_url: @pipedrive_url
23
+ },
24
+ orbit_workspace: @orbit_workspace,
25
+ orbit_api_key: @orbit_api_key )
26
+ end
27
+ end
28
+
29
+ def get_notes
30
+ url = URI("https://api.pipedrive.com/v1/notes")
31
+ url.query = "sort=add_time DESC&api_token=#{@pipedrive_api_key}"
32
+ https = Net::HTTP.new(url.host, url.port)
33
+ https.use_ssl = true
34
+
35
+ request = Net::HTTP::Get.new(url)
36
+
37
+ response = https.request(request)
38
+
39
+ response = JSON.parse(response.body)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal = true
2
+
3
+ module PipedriveOrbit
4
+ VERSION = "0.0.1"
5
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/pipedrive_orbit/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "pipedrive_orbit"
7
+ spec.version = PipedriveOrbit::VERSION
8
+ spec.authors = ["Orbit DevRel", "Ben Greenberg"]
9
+ spec.email = ["devrel@orbit.love"]
10
+
11
+ spec.summary = "Integrate Pipedrive CRM interactions into Orbit"
12
+ spec.description = "This gem brings in Pipedrive activities to your Orbit workspace"
13
+ spec.homepage = "https://github.com/orbit-love/community-ruby-pipedrive-orbit"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.2")
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata["changelog_uri"] = "https://github.com/orbit-love/community-ruby-pipedrive-orbit/blob/main/CHANGELOG.md"
20
+
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
23
+ end
24
+
25
+ spec.bindir = "bin"
26
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "http", "~> 4.4"
30
+ spec.add_dependency "json", "~> 2.5"
31
+ spec.add_dependency "zeitwerk", "~> 2.4"
32
+ spec.add_dependency "thor", "~> 1.1"
33
+ spec.add_dependency "dotenv", "~> 2.7"
34
+ spec.add_dependency "orbit_activities", "~> 0.0.2"
35
+ spec.add_development_dependency "rspec", "~> 3.4"
36
+ spec.add_development_dependency "webmock", "~> 3.12"
37
+ end
Binary file
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "pipedrive_orbit"
5
+ require "thor"
6
+
7
+ module PipedriveOrbit
8
+ module Scripts
9
+ class CheckNotes < Thor
10
+ desc "render", "check for new Pipedrive deal notes and push them to Orbit"
11
+ def render
12
+ client = PipedriveOrbit::Client.new
13
+ client.notes
14
+ end
15
+ end
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pipedrive_orbit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Orbit DevRel
8
+ - Ben Greenberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2021-05-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: http
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '4.4'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '4.4'
28
+ - !ruby/object:Gem::Dependency
29
+ name: json
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.5'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '2.5'
42
+ - !ruby/object:Gem::Dependency
43
+ name: zeitwerk
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.4'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.4'
56
+ - !ruby/object:Gem::Dependency
57
+ name: thor
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.1'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.1'
70
+ - !ruby/object:Gem::Dependency
71
+ name: dotenv
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '2.7'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '2.7'
84
+ - !ruby/object:Gem::Dependency
85
+ name: orbit_activities
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 0.0.2
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 0.0.2
98
+ - !ruby/object:Gem::Dependency
99
+ name: rspec
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '3.4'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '3.4'
112
+ - !ruby/object:Gem::Dependency
113
+ name: webmock
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '3.12'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '3.12'
126
+ description: This gem brings in Pipedrive activities to your Orbit workspace
127
+ email:
128
+ - devrel@orbit.love
129
+ executables:
130
+ - pipedrive_orbit
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - ".env.sample"
135
+ - ".github/CODE_OF_CONDUCT.md"
136
+ - ".github/CONTRIBUTING.md"
137
+ - ".github/workflows/CI.yml"
138
+ - ".gitignore"
139
+ - Gemfile
140
+ - Gemfile.lock
141
+ - LICENSE
142
+ - README.md
143
+ - bin/pipedrive_orbit
144
+ - lib/pipedrive_orbit.rb
145
+ - lib/pipedrive_orbit/client.rb
146
+ - lib/pipedrive_orbit/interactions/note.rb
147
+ - lib/pipedrive_orbit/orbit.rb
148
+ - lib/pipedrive_orbit/pipedrive.rb
149
+ - lib/pipedrive_orbit/version.rb
150
+ - pipedrive_orbit.gemspec
151
+ - readme-images/ways-to-use.png
152
+ - scripts/check_notes.rb
153
+ homepage: https://github.com/orbit-love/community-ruby-pipedrive-orbit
154
+ licenses:
155
+ - MIT
156
+ metadata:
157
+ homepage_uri: https://github.com/orbit-love/community-ruby-pipedrive-orbit
158
+ source_code_uri: https://github.com/orbit-love/community-ruby-pipedrive-orbit
159
+ changelog_uri: https://github.com/orbit-love/community-ruby-pipedrive-orbit/blob/main/CHANGELOG.md
160
+ post_install_message:
161
+ rdoc_options: []
162
+ require_paths:
163
+ - lib
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: 2.7.2
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ requirements: []
175
+ rubygems_version: 3.2.15
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: Integrate Pipedrive CRM interactions into Orbit
179
+ test_files: []