meetup_orbit 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbc753203183aaba02954bca4c979f8b6d82a146dc2e538f55faa00c7b9a90fd
4
- data.tar.gz: 5e55cd5d2c4af97c24188bbcc4166946a6fdfacd849f487d8a9bddea4936661d
3
+ metadata.gz: 45dfbec09beb01a4c5b758beee8c758483f1c3fd9f7dc5f41ddd23094144c477
4
+ data.tar.gz: 88a86b167f70350ecba27d34c8211201583e4065ac5d74cd74ae22b1633270e9
5
5
  SHA512:
6
- metadata.gz: 68d7c11ecc2a9bad11b415cda11d77d45afcccdf8374370eca3c80c95807b1e03890803091276b99e6eae278881a67d2eee0798794dd0a22908c5dcae86fee36
7
- data.tar.gz: 0421e61aa08e40b720f8be0a677984cbc965e2f1e363f24b2becdf34967ce61d67e066a5e7c5dcf1cde9afae7a2baeac978ad0a5ed3c2643267115dcf22e3d24
6
+ metadata.gz: b5ca74f6194e87b68465f10746e7089d0989444a39bbabcb4a8d7bb8e653a0b289a69eef584cf7ef9855354b78803b55b4a4d46cb94c236c6469452be655ffe0
7
+ data.tar.gz: 4d342606142de2e614583e97e0380a94ca53dabbe9fd38bebcb8869dcdf6e6a75257c01387a6113b3b6469172db8df1be887ee30b08d8f4256c0bfe265a8b556
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- meetup_orbit (0.0.1)
4
+ meetup_orbit (0.1.0)
5
5
  activesupport (~> 6.1)
6
6
  dotenv (~> 2.7)
7
7
  http (~> 4.4)
@@ -13,24 +13,24 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activesupport (6.1.3.2)
16
+ activesupport (6.1.4)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
18
  i18n (>= 1.6, < 2)
19
19
  minitest (>= 5.1)
20
20
  tzinfo (~> 2.0)
21
21
  zeitwerk (~> 2.3)
22
- addressable (2.7.0)
22
+ addressable (2.8.0)
23
23
  public_suffix (>= 2.0.2, < 5.0)
24
24
  ast (2.4.2)
25
25
  byebug (11.1.3)
26
- concurrent-ruby (1.1.8)
26
+ concurrent-ruby (1.1.9)
27
27
  crack (0.4.5)
28
28
  rexml
29
29
  diff-lcs (1.4.4)
30
30
  domain_name (0.5.20190701)
31
31
  unf (>= 0.0.5, < 1.0.0)
32
32
  dotenv (2.7.6)
33
- ffi (1.15.1)
33
+ ffi (1.15.3)
34
34
  ffi-compiler (1.0.1)
35
35
  ffi (>= 1.0.0)
36
36
  rake
@@ -40,7 +40,7 @@ GEM
40
40
  http-cookie (~> 1.0)
41
41
  http-form_data (~> 2.2)
42
42
  http-parser (~> 1.2.0)
43
- http-cookie (1.0.3)
43
+ http-cookie (1.0.4)
44
44
  domain_name (~> 0.5)
45
45
  http-form_data (2.3.0)
46
46
  http-parser (1.2.3)
@@ -49,17 +49,17 @@ GEM
49
49
  concurrent-ruby (~> 1.0)
50
50
  json (2.5.1)
51
51
  minitest (5.14.4)
52
- orbit_activities (0.1.0)
52
+ orbit_activities (0.2.2)
53
53
  http (~> 4.4)
54
54
  json (~> 2.5)
55
55
  rake (~> 13.0)
56
56
  zeitwerk (~> 2.4)
57
57
  parallel (1.20.1)
58
- parser (3.0.1.1)
58
+ parser (3.0.2.0)
59
59
  ast (~> 2.4.1)
60
60
  public_suffix (4.0.6)
61
61
  rainbow (3.0.0)
62
- rake (13.0.3)
62
+ rake (13.0.6)
63
63
  regexp_parser (2.1.1)
64
64
  rexml (3.2.5)
65
65
  rspec (3.10.0)
@@ -75,16 +75,16 @@ GEM
75
75
  diff-lcs (>= 1.2.0, < 2.0)
76
76
  rspec-support (~> 3.10.0)
77
77
  rspec-support (3.10.2)
78
- rubocop (1.15.0)
78
+ rubocop (1.18.3)
79
79
  parallel (~> 1.10)
80
80
  parser (>= 3.0.0.0)
81
81
  rainbow (>= 2.2.2, < 4.0)
82
82
  regexp_parser (>= 1.8, < 3.0)
83
83
  rexml
84
- rubocop-ast (>= 1.5.0, < 2.0)
84
+ rubocop-ast (>= 1.7.0, < 2.0)
85
85
  ruby-progressbar (~> 1.7)
86
86
  unicode-display_width (>= 1.4.0, < 3.0)
87
- rubocop-ast (1.5.0)
87
+ rubocop-ast (1.8.0)
88
88
  parser (>= 3.0.1.1)
89
89
  ruby-progressbar (1.11.0)
90
90
  thor (1.1.0)
data/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  Add your Meetup interactions into your Orbit workspace with this community-built integration.
8
8
 
9
+ ![New RSVP in Orbit screenshot](readme-images/new-rsvp-screenshot.png)
10
+
9
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>|
10
12
  |-----------------------------------------|
11
13
 
@@ -51,6 +53,15 @@ client = MeetupOrbit::Client.new(
51
53
  ```ruby
52
54
  client = MeetupOrbit::Client.new
53
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
+ ```
54
65
  ### Fetching New Event RSVPs
55
66
 
56
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:
@@ -68,6 +79,8 @@ To check for new event RSVPs:
68
79
  $ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=... MEETUP_URLNAME=... bundle exec meetup_orbit --check-rsvps
69
80
  ```
70
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
+
71
84
  ## GitHub Actions Automation Setup
72
85
 
73
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|
@@ -11,7 +12,10 @@ choices = OptionParser.new do |opts|
11
12
  exit
12
13
  end
13
14
  opts.on("--check-rsvps", "Check for new Meetup event RSVPs") do
14
- check_notes = true
15
+ check_rsvps = true
16
+ end
17
+ opts.on("--historical-import", "Perform a historical import of all Meetup interactions") do
18
+ historical_import = true
15
19
  end
16
20
  end.parse!
17
21
 
@@ -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
@@ -20,26 +20,44 @@ 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
37
  @orbit_api_key = params.fetch(:orbit_api_key, ENV["ORBIT_API_KEY"])
33
38
  @orbit_workspace = params.fetch(:orbit_workspace, ENV["ORBIT_WORKSPACE_ID"])
34
- @meetup_urlname = params.fetch(:meetup_urlname, ENV["MEETUP_URLNAME"])
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
51
+
52
+ private
53
+
54
+ def check_urlname(urlname)
55
+ if urlname.start_with?("http://") || urlname.start_with?("https://") || urlname.start_with?("www") || urlname.start_with?("meetup.com")
56
+ raise ArgumentError,
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."
58
+ end
59
+
60
+ urlname
61
+ end
44
62
  end
45
- end
63
+ end
@@ -3,53 +3,53 @@
3
3
  require "json"
4
4
 
5
5
  module MeetupOrbit
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
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
- after_initialize!
14
- end
13
+ after_initialize!
14
+ end
15
15
 
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
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
- 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
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
- def construct_description
49
- <<~HEREDOC
50
- #{@rsvp[:member_name]} has registered for #{@rsvp[:event]} in the #{@rsvp[:group]} Meetup group
51
- HEREDOC
52
- end
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
@@ -1,67 +1,95 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MeetupOrbit
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
- end
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
- def process_event_rsvps
12
- events = get_events
13
-
14
- events.each do |event|
15
- next if event["yes_rsvp_count"] <= 1 || event["yes_rsvp_count"].nil?
16
-
17
- rsvps = get_rsvps(event["id"])
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"] / 1000).utc.to_s < orbit_timestamp unless orbit_timestamp.nil? # rubocop:disable all
38
26
  end
39
- end
40
27
 
41
- def get_events
42
- url = URI("https://api.meetup.com/#{@meetup_urlname}/events")
43
-
44
- https = Net::HTTP.new(url.host, url.port)
45
- https.use_ssl = true
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"] / 1000).utc.to_s < orbit_timestamp # rubocop:disable all
30
+ end
31
+
32
+ times += 1
53
33
 
54
- def get_rsvps(event)
55
- url = URI("https://api.meetup.com/#{@meetup_urlname}/events/#{event}/rsvps")
56
-
57
- https = Net::HTTP.new(url.host, url.port)
58
- https.use_ssl = true
59
-
60
- request = Net::HTTP::Get.new(url)
61
-
62
- response = https.request(request)
63
-
64
- response = JSON.parse(response.body)
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"] / 1000).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
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MeetupOrbit
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
- )
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal = true
2
2
 
3
3
  module MeetupOrbit
4
- VERSION = "0.0.1"
5
- end
4
+ VERSION = "0.1.1"
5
+ end
@@ -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.1
4
+ version: 0.1.1
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-05-25 00:00:00.000000000 Z
12
+ date: 2021-08-09 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
@@ -164,6 +165,7 @@ files:
164
165
  - lib/meetup_orbit/orbit.rb
165
166
  - lib/meetup_orbit/version.rb
166
167
  - meetup_orbit.gemspec
168
+ - readme-images/new-rsvp-screenshot.png
167
169
  - readme-images/ways-to-use.png
168
170
  - scripts/check_rsvps.rb
169
171
  homepage: https://github.com/orbit-love/community-ruby-meetup-orbit