planningcenter_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: 0cff67f2a9d1f77853c4b726045549eb0b6a767708c4edfe14422f9baa6f475a
4
+ data.tar.gz: 43141d9e286837e7275cd021bbd873130123d92b4eabe95236e888d185e20be0
5
+ SHA512:
6
+ metadata.gz: 607e6155cc958936d0181a91ac49929afea8d98e1f813c7010c29277ec623c45401ddb4213bc08d053121e07bea9353de213bbce48498cc1160bb7f5e50e8cca
7
+ data.tar.gz: 29a12b554def3403c5fbc237ee262471908e683c2f90384e68b6ee930a518871873c886c7cf925f6fe4511fa364b254f963177932681780ce3cac8eb23cab388
data/.env.sample ADDED
@@ -0,0 +1,4 @@
1
+ ORBIT_API_KEY=
2
+ ORBIT_WORKSPACE_ID=
3
+ PLANNING_CENTER_API_SECRET=
4
+ PLANNING_CENTER_APP_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/.rubocop.yml ADDED
@@ -0,0 +1,30 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+ Exclude:
4
+ - 'spec/**/*'
5
+
6
+ Style/StringLiterals:
7
+ Enabled: true
8
+ EnforcedStyle: double_quotes
9
+
10
+ Style/StringLiteralsInInterpolation:
11
+ Enabled: true
12
+ EnforcedStyle: double_quotes
13
+
14
+ Layout/LineLength:
15
+ Max: 120
16
+
17
+ Metrics/MethodLength:
18
+ Enabled: false
19
+
20
+ Style/GuardClause:
21
+ Enabled: false
22
+
23
+ Style/Documentation:
24
+ Enabled: false
25
+
26
+ Metrics/AbcSize:
27
+ Enabled: false
28
+
29
+ Naming/AccessorMethodName:
30
+ Enabled: false
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,116 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ planningcenter_orbit (0.0.1)
5
+ activesupport (~> 6.1)
6
+ dotenv (~> 2.7)
7
+ http (~> 4.4)
8
+ json (~> 2.5)
9
+ orbit_activities (~> 0.1)
10
+ thor (~> 1.1)
11
+ zeitwerk (~> 2.4)
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ activesupport (6.1.3.2)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ tzinfo (~> 2.0)
21
+ zeitwerk (~> 2.3)
22
+ addressable (2.7.0)
23
+ public_suffix (>= 2.0.2, < 5.0)
24
+ ast (2.4.2)
25
+ byebug (11.1.3)
26
+ concurrent-ruby (1.1.9)
27
+ crack (0.4.5)
28
+ rexml
29
+ diff-lcs (1.4.4)
30
+ domain_name (0.5.20190701)
31
+ unf (>= 0.0.5, < 1.0.0)
32
+ dotenv (2.7.6)
33
+ ffi (1.15.3)
34
+ ffi-compiler (1.0.1)
35
+ ffi (>= 1.0.0)
36
+ rake
37
+ hashdiff (1.0.1)
38
+ http (4.4.1)
39
+ addressable (~> 2.3)
40
+ http-cookie (~> 1.0)
41
+ http-form_data (~> 2.2)
42
+ http-parser (~> 1.2.0)
43
+ http-cookie (1.0.4)
44
+ domain_name (~> 0.5)
45
+ http-form_data (2.3.0)
46
+ http-parser (1.2.3)
47
+ ffi-compiler (>= 1.0, < 2.0)
48
+ i18n (1.8.10)
49
+ concurrent-ruby (~> 1.0)
50
+ json (2.5.1)
51
+ minitest (5.14.4)
52
+ orbit_activities (0.1.0)
53
+ http (~> 4.4)
54
+ json (~> 2.5)
55
+ rake (~> 13.0)
56
+ zeitwerk (~> 2.4)
57
+ parallel (1.20.1)
58
+ parser (3.0.1.1)
59
+ ast (~> 2.4.1)
60
+ public_suffix (4.0.6)
61
+ rainbow (3.0.0)
62
+ rake (13.0.3)
63
+ regexp_parser (2.1.1)
64
+ rexml (3.2.5)
65
+ rspec (3.10.0)
66
+ rspec-core (~> 3.10.0)
67
+ rspec-expectations (~> 3.10.0)
68
+ rspec-mocks (~> 3.10.0)
69
+ rspec-core (3.10.1)
70
+ rspec-support (~> 3.10.0)
71
+ rspec-expectations (3.10.1)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.10.0)
74
+ rspec-mocks (3.10.2)
75
+ diff-lcs (>= 1.2.0, < 2.0)
76
+ rspec-support (~> 3.10.0)
77
+ rspec-support (3.10.2)
78
+ rubocop (1.17.0)
79
+ parallel (~> 1.10)
80
+ parser (>= 3.0.0.0)
81
+ rainbow (>= 2.2.2, < 4.0)
82
+ regexp_parser (>= 1.8, < 3.0)
83
+ rexml
84
+ rubocop-ast (>= 1.7.0, < 2.0)
85
+ ruby-progressbar (~> 1.7)
86
+ unicode-display_width (>= 1.4.0, < 3.0)
87
+ rubocop-ast (1.7.0)
88
+ parser (>= 3.0.1.1)
89
+ ruby-progressbar (1.11.0)
90
+ thor (1.1.0)
91
+ tzinfo (2.0.4)
92
+ concurrent-ruby (~> 1.0)
93
+ unf (0.1.4)
94
+ unf_ext
95
+ unf_ext (0.0.7.7)
96
+ unicode-display_width (2.0.0)
97
+ webmock (3.13.0)
98
+ addressable (>= 2.3.6)
99
+ crack (>= 0.3.2)
100
+ hashdiff (>= 0.4.0, < 2.0.0)
101
+ zeitwerk (2.4.2)
102
+
103
+ PLATFORMS
104
+ arm64-darwin-20
105
+
106
+ DEPENDENCIES
107
+ byebug
108
+ orbit_activities
109
+ planningcenter_orbit!
110
+ rake (~> 13.0)
111
+ rspec (~> 3.4)
112
+ rubocop (~> 1.7)
113
+ webmock (~> 3.12)
114
+
115
+ BUNDLED WITH
116
+ 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,99 @@
1
+ # Planning Center to Orbit Workspace Ruby App
2
+
3
+ ![Build Status](https://github.com/orbit-love/community-ruby-planningcenter-orbit/workflows/CI/badge.svg)
4
+ [![Gem Version](https://badge.fury.io/rb/planningcenter_orbit.svg)](https://badge.fury.io/rb/planningcenter_orbit)
5
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](code_of_conduct.md)
6
+
7
+ Add your Planning Center interactions into your Orbit workspace with this community-built integration.
8
+
9
+ ![New Planning Center check-in for event in Orbit screenshot](readme_images/new-checkin-screenshot.png)
10
+
11
+ |<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>|
12
+ |-----------------------------------------|
13
+
14
+ ![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](docs/ways-to-use.png)
15
+ ## First Time Setup
16
+
17
+ To set up this integration you will need your Planning Center API secret and your Planning Center app ID. See the below table for instructions on where to find them, along with your Orbit API credentials.
18
+ ## Application Credentials
19
+
20
+ The application requires the following environment variables:
21
+
22
+ | Variable | Description | More Info
23
+ |---|---|--|
24
+ | `PLANNING_CENTER_APP_ID` | Planning Center App ID | Create a new "Personal Access Token" in the [Planning Center Developer Dashboard](https://api.planningcenteronline.com/oauth/applications), your Application ID will be shown after creating it.
25
+ | `PLANNING_CENTER_API_SECRET` | Planning Center API secret | Create a new "Personal Access Token" in the [Planning Center Developer Dashboard](https://api.planningcenteronline.com/oauth/applications), your API secret will be shown after creating it.
26
+ | `ORBIT_API_KEY` | API key for Orbit | Found in `Account Settings` in your Orbit workspace
27
+ | `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`
28
+
29
+ ## Package Usage
30
+
31
+ To install this integration in a standalone app, add the gem to your `Gemfile`:
32
+
33
+ ```ruby
34
+ gem "planningcenter_orbit"
35
+ ```
36
+
37
+ Then, run `bundle install` from your terminal.
38
+
39
+ You can instantiate a client by either passing in the required credentials during instantiation or by providing them in your `.env` file.
40
+
41
+ ### Instantiation with credentials:
42
+
43
+ ```ruby
44
+ client = PlanningcenterOrbit::Client.new(
45
+ orbit_api_key: YOUR_API_KEY,
46
+ orbit_workspace_id: YOUR_ORBIT_WORKSPACE_ID,
47
+ pc_app_id: YOUR_PLANNING_CENTER_APP_ID,
48
+ pc_api_secret: YOUR_PLANNING_CENTER_API_SECRET
49
+ )
50
+ ```
51
+
52
+ ### Instantiation with credentials in dotenv file:
53
+
54
+ ```ruby
55
+ client = PlanningcenterOrbit::Client.new
56
+ ```
57
+
58
+ ### Performing a Historical Import
59
+
60
+ By default, the integration will only import activities that are newer than the newest Planning Center activity in your Orbit workspace. You may want to perform a one-time historical import to fetch all your previous Planning Center activities and bring them into your Orbit workspace. To do so, instantiate your `client` with the `historical_import` flag:
61
+
62
+ ```ruby
63
+ client = PlanningcenterOrbit::Client.new(
64
+ historical_import: true
65
+ )
66
+ ```
67
+
68
+ ### Fetching Planning Center Event Check-ins
69
+
70
+ Once, you have an instantiated client, you can fetch event check-ins from Planning Center and send them to Orbit by invoking the `#check_ins` instance method:
71
+
72
+ ```ruby
73
+ client.check_ins
74
+ ```
75
+ ## CLI Usage
76
+
77
+ 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:
78
+
79
+ ```bash
80
+ $ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=... LINKEDIN_TOKEN=... LINKEDIN_ORGANIZATION=... bundle exec planningcenter_orbit --check-event-checkins
81
+ ```
82
+
83
+ Add the `--historical-import` flag to your CLI command to perform a historical import of all your Planning Center data using the CLI.
84
+ ## GitHub Actions Automation Setup
85
+
86
+ ⚡ 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.
87
+
88
+ [See our guide for setting up this automation](https://github.com/orbit-love/github-actions-templates/blob/main/PlanningCenter/README.md).
89
+ ## Contributing
90
+
91
+ We 💜 contributions from everyone! Check out the [Contributing Guidelines](.github/CONTRIBUTING.md) for more information.
92
+
93
+ ## License
94
+
95
+ This is available as open source under the terms of the [MIT License](LICENSE).
96
+
97
+ ## Code of Conduct
98
+
99
+ 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,34 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "optparse"
5
+
6
+ check_event_checkins = false
7
+ historical_import = false
8
+
9
+ options = {}
10
+ choices = OptionParser.new do |opts|
11
+ opts.banner = "Usage: planningcenter_orbit --check-event-checkins"
12
+ opts.on("-h", "--help", "Prints help instructions") do
13
+ puts opts
14
+ exit
15
+ end
16
+ opts.on("--check-event-checkins", "Check for new event check-ins on Planning Center") do
17
+ check_event_checkins = true
18
+ end
19
+ opts.on("--historical-import", "Perform a historical import of all the Planning Center data") do
20
+ historical_import = true
21
+ end
22
+ end.parse!
23
+
24
+ $LOAD_PATH.unshift(File.expand_path("../lib/circle_orbit", __dir__))
25
+
26
+ require_relative "../lib/planningcenter_orbit"
27
+ require_relative "../scripts/check_event_checkins"
28
+
29
+ if check_event_checkins
30
+ puts "Checking for new event check-ins and sending them to your Orbit workspace..."
31
+ ARGV[0] = "render"
32
+ ARGV[1] = historical_import
33
+ PlanningcenterOrbit::Scripts::CheckEventCheckins.start(ARGV)
34
+ end
Binary file
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "zeitwerk"
4
+ require "orbit_activities"
5
+ require_relative "planningcenter_orbit/version"
6
+
7
+ module PlanningcenterOrbit
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,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dotenv/load"
4
+ require "net/http"
5
+ require "json"
6
+
7
+ # Create a client to log Planning Center interactions 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 = PlanningcenterOrbit::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] :pc_app_id
21
+ # The Planning Center application ID obtained from Planning Center's dashboard
22
+ #
23
+ # @option params [String] :pc_api_secret
24
+ # The Planning Center API secret obtained from Planning Center's dashboard
25
+ #
26
+ # @option params [Boolean] :historical_import
27
+ # Boolean flag to indicate whether to import all historical activities to Orbit.
28
+ # Default is false.
29
+ #
30
+ # @param [Hash] params
31
+ #
32
+ # @return [PlanningcenterOrbit::Client]
33
+ #
34
+ module PlanningcenterOrbit
35
+ class Client
36
+ attr_accessor :orbit_api_key, :orbit_workspace, :pc_app_id, :pc_api_secret, :historical_import
37
+
38
+ def initialize(params = {})
39
+ @orbit_api_key = params.fetch(:orbit_api_key, ENV["ORBIT_API_KEY"])
40
+ @orbit_workspace = params.fetch(:orbit_workspace, ENV["ORBIT_WORKSPACE_ID"])
41
+ @pc_app_id = params.fetch(:pc_app_id, ENV["PLANNING_CENTER_APP_ID"])
42
+ @pc_api_secret = params.fetch(:pc_api_secret, ENV["PLANNING_CENTER_API_SECRET"])
43
+ @historical_import = params.fetch(:historical_import, false)
44
+ end
45
+
46
+ def check_ins
47
+ PlanningcenterOrbit::Planningcenter.new(
48
+ pc_app_id: @pc_app_id,
49
+ pc_api_secret: @pc_api_secret,
50
+ orbit_api_key: @orbit_api_key,
51
+ orbit_workspace: @orbit_workspace,
52
+ historical_import: @historical_import
53
+ ).process_checkins
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module PlanningcenterOrbit
6
+ module Interactions
7
+ class Checkin
8
+ def initialize(event_title:, url:, checkin:, workspace_id:, api_key:)
9
+ @event_title = event_title
10
+ @url = url
11
+ @id = checkin["id"]
12
+ @created_at = checkin["attributes"]["created_at"]
13
+ @guest = "#{checkin["attributes"]["first_name"]} #{checkin["attributes"]["last_name"]}"
14
+ @workspace_id = workspace_id
15
+ @api_key = api_key
16
+
17
+ after_initialize!
18
+ end
19
+
20
+ def after_initialize!
21
+ OrbitActivities::Request.new(
22
+ api_key: @api_key,
23
+ workspace_id: @workspace_id,
24
+ user_agent: "community-ruby-planningcenter-orbit/#{PlanningcenterOrbit::VERSION}",
25
+ action: "new_activity",
26
+ body: construct_body.to_json
27
+ )
28
+ end
29
+
30
+ def construct_body
31
+ {
32
+ activity: {
33
+ activity_type: "planning_center:check_in",
34
+ tags: ["channel:planning_center"],
35
+ key: @id,
36
+ title: "New guest check-in for #{@event_title}",
37
+ description: "#{@guest} checked in for #{@event_title} on Planning Center",
38
+ occurred_at: @created_at,
39
+ link: @url,
40
+ link_text: "Link to Planning Center Event",
41
+ member: {
42
+ name: @guest
43
+ }
44
+ },
45
+ identity: {
46
+ source: "planning_center",
47
+ username: @guest.parameterize
48
+ }
49
+ }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,18 @@
1
+
2
+ # frozen_string_literal: true
3
+
4
+ module PlanningcenterOrbit
5
+ class Orbit
6
+ def self.call(type:, data:, workspace_id:, api_key:)
7
+ if type == "checkin"
8
+ PlanningcenterOrbit::Interactions::Checkin.new(
9
+ event_title: data[:title],
10
+ checkin: data[:checkin],
11
+ url: data[:url],
12
+ workspace_id: workspace_id,
13
+ api_key: api_key
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/time"
4
+
5
+ module PlanningcenterOrbit
6
+ class Planningcenter
7
+ def initialize(params = {})
8
+ @pc_app_id = params.fetch(:pc_app_id)
9
+ @pc_api_secret = params.fetch(:pc_api_secret)
10
+ @orbit_api_key = params.fetch(:orbit_api_key)
11
+ @orbit_workspace = params.fetch(:orbit_workspace)
12
+ @historical_import = params.fetch(:historical_import, false)
13
+ end
14
+
15
+ def process_checkins
16
+ events = get_events
17
+
18
+ return "Something went wrong with the Planning Center API" unless events["data"].is_a?(Array)
19
+
20
+ events["data"].each do |event|
21
+ checkins = get_event_checkins(link: "#{event["links"]["self"]}/check_ins")
22
+
23
+ next if checkins.nil? || checkins.empty?
24
+
25
+ times = 0
26
+ checkins.each do |checkin|
27
+ unless @historical_import
28
+ next if checkin["attributes"]["created_at"] < last_orbit_activity_timestamp
29
+ end
30
+
31
+ unless last_orbit_activity_timestamp.nil? || last_orbit_activity_timestamp.empty?
32
+ next if checkin["attributes"]["created_at"] < last_orbit_activity_timestamp
33
+ end
34
+
35
+ times += 1
36
+ PlanningcenterOrbit::Orbit.call(
37
+ type: "checkin",
38
+ data: {
39
+ checkin: checkin,
40
+ title: event["attributes"]["name"],
41
+ url: "https://check-ins.planningcenteronline.com/events/#{event["id"]}"
42
+ },
43
+ workspace_id: @orbit_workspace,
44
+ api_key: @orbit_api_key
45
+ )
46
+ end
47
+
48
+ return "Sent #{times} checkins to your Orbit workspace"
49
+ end
50
+ end
51
+
52
+ def get_events
53
+ url = URI("https://api.planningcenteronline.com/check-ins/v2/events")
54
+ https = Net::HTTP.new(url.host, url.port)
55
+ https.use_ssl = true
56
+
57
+ request = Net::HTTP::Get.new(url)
58
+ request["Accept"] = "application/json"
59
+ request["Content-Type"] = "application/json"
60
+ request.basic_auth @pc_app_id, @pc_api_secret
61
+
62
+ response = https.request(request)
63
+
64
+ response = JSON.parse(response.body)
65
+
66
+ if response["data"].nil? || response["data"].empty?
67
+ return <<~HEREDOC
68
+ No new events from your Planning Center organization.
69
+ If you suspect this is incorrect, verify your Planning Center credentials are correct.
70
+ HEREDOC
71
+ end
72
+
73
+ response
74
+ end
75
+
76
+ def get_event_checkins(link:)
77
+ url = URI(link)
78
+ https = Net::HTTP.new(url.host, url.port)
79
+ https.use_ssl = true
80
+
81
+ request = Net::HTTP::Get.new(url)
82
+ request["Accept"] = "application/json"
83
+ request["Content-Type"] = "application/json"
84
+ request.basic_auth @pc_app_id, @pc_api_secret
85
+
86
+ response = https.request(request)
87
+
88
+ response = JSON.parse(response.body)
89
+
90
+ response["data"]
91
+ end
92
+
93
+ private
94
+
95
+ def last_orbit_activity_timestamp
96
+ @last_orbit_activity_timestamp ||= begin
97
+ url = URI("https://app.orbit.love/api/v1/#{@orbit_workspace}/activities")
98
+ params = {
99
+ items: 10,
100
+ direction: "DESC",
101
+ activity_type: "custom:planning_center:check_in"
102
+ }
103
+ url.query = URI.encode_www_form(params)
104
+ http = Net::HTTP.new(url.host, url.port)
105
+ http.use_ssl = true
106
+ req = Net::HTTP::Get.new(url)
107
+ req["Accept"] = "application/json"
108
+ req["Content-Type"] = "application/json"
109
+ req["Authorization"] = "Bearer #{@orbit_api_key}"
110
+ req["User-Agent"] = "community-ruby-planningcenter-orbit/#{PlanningcenterOrbit::VERSION}"
111
+
112
+ response = http.request(req)
113
+
114
+ response = JSON.parse(response.body)
115
+
116
+ return nil if response["data"].nil? || response["data"].empty?
117
+
118
+ response["data"][0]["attributes"]["created_at"]
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PlanningcenterOrbit
4
+ VERSION = "0.0.1"
5
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/planningcenter_orbit/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "planningcenter_orbit"
7
+ spec.version = PlanningcenterOrbit::VERSION
8
+ spec.authors = ["Orbit DevRel", "Ben Greenberg"]
9
+ spec.email = ["devrel@orbit.love"]
10
+
11
+ spec.summary = "Integrate Planning Center interactions into Orbit"
12
+ spec.description = "This gem brings in Planning Center interactions to your Orbit workspace"
13
+ spec.homepage = "https://github.com/orbit-love/community-ruby-planningcenter-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-planningcenter-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.1"
35
+ spec.add_dependency "activesupport", "~> 6.1"
36
+ spec.add_development_dependency "rspec", "~> 3.4"
37
+ spec.add_development_dependency "webmock", "~> 3.12"
38
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # require "planningcenter_orbit"
5
+ require "thor"
6
+
7
+ module PlanningcenterOrbit
8
+ module Scripts
9
+ class CheckEventCheckins < Thor
10
+ desc "render", "check for new event check-ins and push them to Orbit"
11
+ def render(*params)
12
+ client = PlanningcenterOrbit::Client.new(historical_import: params[0])
13
+ client.check_ins
14
+ end
15
+ end
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: planningcenter_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-06-24 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.1'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.1'
98
+ - !ruby/object:Gem::Dependency
99
+ name: activesupport
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '6.1'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '6.1'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rspec
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '3.4'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '3.4'
126
+ - !ruby/object:Gem::Dependency
127
+ name: webmock
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '3.12'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '3.12'
140
+ description: This gem brings in Planning Center interactions to your Orbit workspace
141
+ email:
142
+ - devrel@orbit.love
143
+ executables:
144
+ - planningcenter_orbit
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - ".env.sample"
149
+ - ".github/CODE_OF_CONDUCT.md"
150
+ - ".github/CONTRIBUTING.md"
151
+ - ".github/workflows/CI.yml"
152
+ - ".gitignore"
153
+ - ".rubocop.yml"
154
+ - Gemfile
155
+ - Gemfile.lock
156
+ - LICENSE
157
+ - README.md
158
+ - bin/planningcenter_orbit
159
+ - docs/ways-to-use.png
160
+ - lib/planningcenter_orbit.rb
161
+ - lib/planningcenter_orbit/client.rb
162
+ - lib/planningcenter_orbit/interactions/checkin.rb
163
+ - lib/planningcenter_orbit/orbit.rb
164
+ - lib/planningcenter_orbit/planningcenter.rb
165
+ - lib/planningcenter_orbit/version.rb
166
+ - planningcenter_orbit.gemspec
167
+ - readme_images/new-checkin-screenshot.png
168
+ - scripts/check_event_checkins.rb
169
+ homepage: https://github.com/orbit-love/community-ruby-planningcenter-orbit
170
+ licenses:
171
+ - MIT
172
+ metadata:
173
+ homepage_uri: https://github.com/orbit-love/community-ruby-planningcenter-orbit
174
+ source_code_uri: https://github.com/orbit-love/community-ruby-planningcenter-orbit
175
+ changelog_uri: https://github.com/orbit-love/community-ruby-planningcenter-orbit/blob/main/CHANGELOG.md
176
+ post_install_message:
177
+ rdoc_options: []
178
+ require_paths:
179
+ - lib
180
+ required_ruby_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: 2.7.2
185
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ">="
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ requirements: []
191
+ rubygems_version: 3.2.15
192
+ signing_key:
193
+ specification_version: 4
194
+ summary: Integrate Planning Center interactions into Orbit
195
+ test_files: []