meetup_orbit 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +30 -0
- data/Gemfile.lock +1 -1
- data/README.md +11 -0
- data/bin/meetup_orbit +5 -0
- data/lib/meetup_orbit/client.rb +16 -9
- data/lib/meetup_orbit/interactions/events/rsvp.rb +45 -45
- data/lib/meetup_orbit/meetup.rb +86 -58
- data/lib/meetup_orbit/orbit.rb +10 -10
- data/lib/meetup_orbit/version.rb +2 -2
- data/scripts/check_rsvps.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8af06cb68160fe7a202dd3258d6a24956409df6dcaf481abdea8f0209d36b69d
|
4
|
+
data.tar.gz: ed909d8994847a164ca60f59d79987ad893a5d9f40ba90cb851738b9089356ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5eabe225def754c5dc35adaf28e44c03000d859f811b0051480562a46d7e246256a1faafbceb236e6f84a3f9fbbc11ffb0eb545baa9b995bc0f57f300ea703d8
|
7
|
+
data.tar.gz: 77a08aeef961a4421e2637a3ca8b32acbcdcec4e997373ea0b5164ddbcadaaaccf616d899006afcafc9393bbf7e620689290204e4cc56d6f4fdaed6312487a19
|
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.lock
CHANGED
data/README.md
CHANGED
@@ -53,6 +53,15 @@ client = MeetupOrbit::Client.new(
|
|
53
53
|
```ruby
|
54
54
|
client = MeetupOrbit::Client.new
|
55
55
|
```
|
56
|
+
### Performing a Historical Import
|
57
|
+
|
58
|
+
You may want to perform a one-time historical import to fetch all your previous Meetup interactions and bring them into your Orbit workspace. To do so, instantiate your `client` with the `historical_import` flag:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
client = MeetupOrbit::Client.new(
|
62
|
+
historical_import: true
|
63
|
+
)
|
64
|
+
```
|
56
65
|
### Fetching New Event RSVPs
|
57
66
|
|
58
67
|
Once, you have an instantiated client, you can fetch new Meetup event RSVPs and add them to your Orbit workspace by invoking the `#event_rsvps` method on the client:
|
@@ -70,6 +79,8 @@ To check for new event RSVPs:
|
|
70
79
|
$ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=... MEETUP_URLNAME=... bundle exec meetup_orbit --check-rsvps
|
71
80
|
```
|
72
81
|
|
82
|
+
**Add the `--historical-import` flag to your CLI command to perform a historical import of all your Meetup interactions using the CLI.**
|
83
|
+
|
73
84
|
## GitHub Actions Automation Setup
|
74
85
|
|
75
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.
|
data/bin/meetup_orbit
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'optparse'
|
3
3
|
|
4
4
|
check_rsvps = false
|
5
|
+
historical_import = false
|
5
6
|
|
6
7
|
options = {}
|
7
8
|
choices = OptionParser.new do |opts|
|
@@ -13,6 +14,9 @@ choices = OptionParser.new do |opts|
|
|
13
14
|
opts.on("--check-rsvps", "Check for new Meetup event RSVPs") do
|
14
15
|
check_rsvps = true
|
15
16
|
end
|
17
|
+
opts.on("--historical-import", "Perform a historical import of all Meetup interactions") do
|
18
|
+
historical_import = true
|
19
|
+
end
|
16
20
|
end.parse!
|
17
21
|
|
18
22
|
$LOAD_PATH.unshift(File.expand_path('../lib/meetup_orbit', __dir__))
|
@@ -23,5 +27,6 @@ require_relative '../scripts/check_rsvps'
|
|
23
27
|
if check_rsvps
|
24
28
|
puts "Checking for new Meetup event RSVPs and posting them to your Orbit workspace..."
|
25
29
|
ARGV[0] = 'render'
|
30
|
+
ARGV[1] = historical_import
|
26
31
|
MeetupOrbit::Scripts::CheckRsvps.start(ARGV)
|
27
32
|
end
|
data/lib/meetup_orbit/client.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "dotenv/load"
|
4
|
+
require "net/http"
|
5
|
+
require "json"
|
6
6
|
|
7
7
|
# Create a client to log Meetup activities in your Orbit workspace
|
8
8
|
# Credentials can either be passed in to the instance or be loaded
|
@@ -20,32 +20,39 @@ require 'json'
|
|
20
20
|
# @option params [String] :meetup_urlname
|
21
21
|
# The URL identifier of your Meetup
|
22
22
|
#
|
23
|
+
# @option params [Boolean] :historical_import
|
24
|
+
# Whether to do an import of all Meetup interactions ignoring latest
|
25
|
+
# activity already in the Orbit workspace.
|
26
|
+
# Default is false.
|
27
|
+
#
|
23
28
|
# @param [Hash] params
|
24
29
|
#
|
25
30
|
# @return [MeetupOrbit::Client]
|
26
31
|
#
|
27
32
|
module MeetupOrbit
|
28
33
|
class Client
|
29
|
-
attr_accessor :orbit_api_key, :orbit_workspace, :meetup_urlname
|
34
|
+
attr_accessor :orbit_api_key, :orbit_workspace, :meetup_urlname, :historical_import
|
30
35
|
|
31
36
|
def initialize(params = {})
|
32
|
-
@orbit_api_key = params.fetch(:orbit_api_key, ENV[
|
33
|
-
@orbit_workspace = params.fetch(:orbit_workspace, ENV[
|
34
|
-
@meetup_urlname = check_urlname(params.fetch(:meetup_urlname, ENV[
|
37
|
+
@orbit_api_key = params.fetch(:orbit_api_key, ENV["ORBIT_API_KEY"])
|
38
|
+
@orbit_workspace = params.fetch(:orbit_workspace, ENV["ORBIT_WORKSPACE_ID"])
|
39
|
+
@meetup_urlname = check_urlname(params.fetch(:meetup_urlname, ENV["MEETUP_URLNAME"]))
|
40
|
+
@historical_import = params.fetch(:historical_import, false)
|
35
41
|
end
|
36
42
|
|
37
43
|
def event_rsvps
|
38
44
|
MeetupOrbit::Meetup.new(
|
39
45
|
meetup_urlname: @meetup_urlname,
|
40
46
|
orbit_api_key: @orbit_api_key,
|
41
|
-
orbit_workspace: @orbit_workspace
|
47
|
+
orbit_workspace: @orbit_workspace,
|
48
|
+
historical_import: @historical_import
|
42
49
|
).process_event_rsvps
|
43
50
|
end
|
44
51
|
|
45
52
|
private
|
46
53
|
|
47
54
|
def check_urlname(urlname)
|
48
|
-
if urlname.start_with?(
|
55
|
+
if urlname.start_with?("http://") || urlname.start_with?("https://") || urlname.start_with?("www") || urlname.start_with?("meetup.com")
|
49
56
|
raise ArgumentError,
|
50
57
|
"'meetup_urlname' parameter must only be the unique identifier of your meetup not the entire URL. Please refer to the README for more details."
|
51
58
|
end
|
@@ -3,53 +3,53 @@
|
|
3
3
|
require "json"
|
4
4
|
|
5
5
|
module MeetupOrbit
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
module Interactions::Events
|
7
|
+
class Rsvp
|
8
|
+
def initialize(rsvp:, orbit_workspace:, orbit_api_key:)
|
9
|
+
@rsvp = rsvp
|
10
|
+
@orbit_workspace = orbit_workspace
|
11
|
+
@orbit_api_key = orbit_api_key
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
after_initialize!
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
def after_initialize!
|
17
|
+
OrbitActivities::Request.new(
|
18
|
+
api_key: @orbit_api_key,
|
19
|
+
workspace_id: @orbit_workspace,
|
20
|
+
user_agent: "community-ruby-meetup-orbit/#{MeetupOrbit::VERSION}",
|
21
|
+
action: "new_activity",
|
22
|
+
body: construct_body.to_json
|
23
|
+
)
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
def construct_body
|
27
|
+
hash = {
|
28
|
+
activity: {
|
29
|
+
activity_type: "meetup:rsvp",
|
30
|
+
tags: ["channel:meetup"],
|
31
|
+
title: "New RSVP for #{@rsvp[:event]}",
|
32
|
+
description: construct_description,
|
33
|
+
occurred_at: @rsvp[:occurred_at],
|
34
|
+
key: @rsvp[:id],
|
35
|
+
link: @rsvp[:link],
|
36
|
+
member: {
|
37
|
+
name: @rsvp[:member_name]
|
38
|
+
}
|
39
|
+
},
|
40
|
+
identity: {
|
41
|
+
source: "meetup",
|
42
|
+
name: @rsvp[:member_name],
|
43
|
+
uid: @rsvp[:member_id]
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
48
|
+
def construct_description
|
49
|
+
<<~HEREDOC
|
50
|
+
#{@rsvp[:member_name]} has registered for #{@rsvp[:event]} in the #{@rsvp[:group]} Meetup group
|
51
|
+
HEREDOC
|
52
|
+
end
|
54
53
|
end
|
55
|
-
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/meetup_orbit/meetup.rb
CHANGED
@@ -1,67 +1,95 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module MeetupOrbit
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
class Meetup
|
5
|
+
def initialize(params = {})
|
6
|
+
@meetup_urlname = params.fetch(:meetup_urlname)
|
7
|
+
@orbit_api_key = params.fetch(:orbit_api_key)
|
8
|
+
@orbit_workspace = params.fetch(:orbit_workspace)
|
9
|
+
@historical_import = params.fetch(:historical_import, false)
|
10
|
+
end
|
11
|
+
|
12
|
+
def process_event_rsvps
|
13
|
+
events = get_events
|
14
|
+
|
15
|
+
times = 0
|
16
|
+
events.each do |event|
|
17
|
+
next if event["yes_rsvp_count"] <= 1 || event["yes_rsvp_count"].nil?
|
10
18
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
rsvps.drop(1).each do |rsvp| # skip first item which is event owner
|
20
|
-
MeetupOrbit::Orbit.call(
|
21
|
-
type: "event_rsvp",
|
22
|
-
data: {
|
23
|
-
rsvp: {
|
24
|
-
event: rsvp["event"]["name"],
|
25
|
-
group: rsvp["group"]["name"],
|
26
|
-
member_id: rsvp["member"]["id"],
|
27
|
-
member_name: rsvp["member"]["name"],
|
28
|
-
occurred_at: Time.at(rsvp["created"] / 1000).utc,
|
29
|
-
id: "#{rsvp["member"]["id"]}-#{rsvp["event"]["id"]}",
|
30
|
-
link: "https://meetup.com/#{@meetup_urlname}/events/#{rsvp["event"]["id"]}",
|
31
|
-
response: rsvp["response"]
|
32
|
-
}
|
33
|
-
},
|
34
|
-
orbit_api_key: @orbit_api_key,
|
35
|
-
orbit_workspace: @orbit_workspace
|
36
|
-
)
|
37
|
-
end
|
19
|
+
rsvps = get_rsvps(event["id"])
|
20
|
+
|
21
|
+
orbit_timestamp = last_orbit_activity_timestamp
|
22
|
+
|
23
|
+
rsvps.drop(1).each do |rsvp| # skip first item which is event owner
|
24
|
+
unless @historical_import && orbit_timestamp # rubocop:disable all
|
25
|
+
next if Time.at(rsvp["created"]).utc.to_s < orbit_timestamp unless orbit_timestamp.nil? # rubocop:disable all
|
38
26
|
end
|
39
|
-
end
|
40
27
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
request = Net::HTTP::Get.new(url)
|
48
|
-
|
49
|
-
response = https.request(request)
|
50
|
-
|
51
|
-
response = JSON.parse(response.body)
|
52
|
-
end
|
28
|
+
if orbit_timestamp && @historical_import == false
|
29
|
+
next if Time.at(rsvp["created"]).utc.to_s < orbit_timestamp # rubocop:disable all
|
30
|
+
end
|
31
|
+
|
32
|
+
times += 1
|
53
33
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
34
|
+
MeetupOrbit::Orbit.call(
|
35
|
+
type: "event_rsvp",
|
36
|
+
data: {
|
37
|
+
rsvp: {
|
38
|
+
event: rsvp["event"]["name"],
|
39
|
+
group: rsvp["group"]["name"],
|
40
|
+
member_id: rsvp["member"]["id"],
|
41
|
+
member_name: rsvp["member"]["name"],
|
42
|
+
occurred_at: Time.at(rsvp["created"]).utc.to_s,
|
43
|
+
id: "#{rsvp["member"]["id"]}-#{rsvp["event"]["id"]}",
|
44
|
+
link: "https://meetup.com/#{@meetup_urlname}/events/#{rsvp["event"]["id"]}",
|
45
|
+
response: rsvp["response"]
|
46
|
+
}
|
47
|
+
},
|
48
|
+
orbit_api_key: @orbit_api_key,
|
49
|
+
orbit_workspace: @orbit_workspace
|
50
|
+
)
|
65
51
|
end
|
52
|
+
end
|
53
|
+
|
54
|
+
output = "Sent #{times} new RSVPs to your Orbit workspace"
|
55
|
+
puts output
|
56
|
+
output
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_events
|
60
|
+
url = URI("https://api.meetup.com/#{@meetup_urlname}/events")
|
61
|
+
|
62
|
+
https = Net::HTTP.new(url.host, url.port)
|
63
|
+
https.use_ssl = true
|
64
|
+
|
65
|
+
request = Net::HTTP::Get.new(url)
|
66
|
+
|
67
|
+
response = https.request(request)
|
68
|
+
|
69
|
+
response = JSON.parse(response.body)
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_rsvps(event)
|
73
|
+
url = URI("https://api.meetup.com/#{@meetup_urlname}/events/#{event}/rsvps")
|
74
|
+
|
75
|
+
https = Net::HTTP.new(url.host, url.port)
|
76
|
+
https.use_ssl = true
|
77
|
+
|
78
|
+
request = Net::HTTP::Get.new(url)
|
79
|
+
|
80
|
+
response = https.request(request)
|
81
|
+
|
82
|
+
response = JSON.parse(response.body)
|
83
|
+
end
|
84
|
+
|
85
|
+
def last_orbit_activity_timestamp
|
86
|
+
@last_orbit_activity_timestamp ||= OrbitActivities::Request.new(
|
87
|
+
api_key: @orbit_api_key,
|
88
|
+
workspace_id: @orbit_workspace,
|
89
|
+
user_agent: "community-ruby-meetup-orbit/#{MeetupOrbit::VERSION}",
|
90
|
+
action: "latest_activity_timestamp",
|
91
|
+
filters: { activity_type: "custom:meetup:rsvp" }
|
92
|
+
).response
|
66
93
|
end
|
67
|
-
end
|
94
|
+
end
|
95
|
+
end
|
data/lib/meetup_orbit/orbit.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module MeetupOrbit
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
4
|
+
class Orbit
|
5
|
+
def self.call(type:, data:, orbit_workspace:, orbit_api_key:)
|
6
|
+
if type == "event_rsvp"
|
7
|
+
MeetupOrbit::Interactions::Events::Rsvp.new(
|
8
|
+
rsvp: data[:rsvp],
|
9
|
+
orbit_workspace: orbit_workspace,
|
10
|
+
orbit_api_key: orbit_api_key
|
11
|
+
)
|
13
12
|
end
|
14
13
|
end
|
15
|
-
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/meetup_orbit/version.rb
CHANGED
data/scripts/check_rsvps.rb
CHANGED
@@ -8,8 +8,8 @@ module MeetupOrbit
|
|
8
8
|
module Scripts
|
9
9
|
class CheckRsvps < Thor
|
10
10
|
desc "render", "check for new Meetup event RSVPs and push them to Orbit"
|
11
|
-
def render
|
12
|
-
client = MeetupOrbit::Client.new
|
11
|
+
def render(*params)
|
12
|
+
client = MeetupOrbit::Client.new(historical_import: params[0])
|
13
13
|
client.event_rsvps
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meetup_orbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orbit DevRel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- ".github/CONTRIBUTING.md"
|
151
151
|
- ".github/workflows/CI.yml"
|
152
152
|
- ".gitignore"
|
153
|
+
- ".rubocop.yml"
|
153
154
|
- Gemfile
|
154
155
|
- Gemfile.lock
|
155
156
|
- LICENSE
|