neon_email 0.1.4 → 0.1.5

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: be4b6fb025dd2fe30c4d497fa3e7d46e2ee4eabecb3b47095a6265d1b299ebeb
4
- data.tar.gz: f04321b3dc8ebde85bc5440f2aaca06b5eccd8b19fcd30b59ff1aac631a325ce
3
+ metadata.gz: cb3f35cf3264d0b746bb69f06cf725c57e8dd4fd35b3a177a88d1fb3ab0902f4
4
+ data.tar.gz: 42ba2f0e1e14e0c510aa383b9a08cbaf80d9ac40747bcc7fd13e75cb4b455b62
5
5
  SHA512:
6
- metadata.gz: 67e899e8d39c93fba77c44221677137146ecd3214d760c2d434c771de435649040f9bfa41c24acbf345a854aee44c2dae471aaf1a80545308f556679a8440c27
7
- data.tar.gz: 0add3bb7214275ff319b4b46f5c157dd82364f17d32ccea18b96dfc9c7a4807346631abdbe554c2bbb294c80b3be2747ea64676a45c1f9bed7bd57fa728bc6f9
6
+ metadata.gz: 3ffdb88d7f5b1ec5970918be95d02a95beaafcadb2b96b1b84ccb5aed63d800d51e7f44928fb4118b03b77f5f0388ae720ff6b378ea97266ef0e6f9bc82b94ff
7
+ data.tar.gz: b189186688a0dee4fa06707d1b57f1ce9d509eae367c9ff9730674a84aa670fdf534dd17e60d24dc4efa2c2813b7b0ba7cc90337dbfcc405a5476bc8f5235a8d
data/Gemfile.lock CHANGED
@@ -4,6 +4,7 @@ PATH
4
4
  neon_email (0.1.4)
5
5
  functions_framework (= 0.9.0)
6
6
  neon_schemas (= 0.1.1)
7
+ neon_secrets (= 0.0.1)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
@@ -55,6 +56,18 @@ GEM
55
56
  gapic-common (~> 0.3)
56
57
  google-cloud-errors (~> 1.0)
57
58
  grpc-google-iam-v1 (>= 0.6.10, < 2.0)
59
+ google-cloud-secret_manager (1.1.0)
60
+ google-cloud-core (~> 1.5)
61
+ google-cloud-secret_manager-v1 (~> 0.1)
62
+ google-cloud-secret_manager-v1beta1 (~> 0.3)
63
+ google-cloud-secret_manager-v1 (0.10.0)
64
+ gapic-common (~> 0.4)
65
+ google-cloud-errors (~> 1.0)
66
+ grpc-google-iam-v1 (>= 0.6.10, < 2.0)
67
+ google-cloud-secret_manager-v1beta1 (0.8.0)
68
+ gapic-common (~> 0.3)
69
+ google-cloud-errors (~> 1.0)
70
+ grpc-google-iam-v1 (>= 0.6.10, < 2.0)
58
71
  google-protobuf (3.17.0)
59
72
  googleapis-common-protos (1.3.11)
60
73
  google-protobuf (~> 3.14)
@@ -85,6 +98,8 @@ GEM
85
98
  multipart-post (2.1.1)
86
99
  neon_schemas (0.1.1)
87
100
  avro (~> 1.10)
101
+ neon_secrets (0.0.1)
102
+ google-cloud-secret_manager (~> 1.1)
88
103
  nio4r (2.5.7)
89
104
  os (1.1.1)
90
105
  parallel (1.20.1)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Neon Email
2
2
 
3
- This gem is used to listen to email messages to Kafka and then interact with the
3
+ This gem is used to listen to email Pubsub messages and then interact with the
4
4
  Sendgrid API.
5
5
 
6
6
  ## Doppler Setup
data/app.rb CHANGED
@@ -6,14 +6,15 @@ require "json"
6
6
 
7
7
  logger = Logger.new($stdout)
8
8
 
9
- WELCOME_EMAIL_TOPIC = "com.neon_law.outbound_email.welcome_email".freeze
10
-
11
- FunctionsFramework.cloud_event WELCOME_EMAIL_TOPIC do |event|
9
+ FunctionsFramework.cloud_event "outbound_emails.welcome_email" do |event|
12
10
  logger.info "hey you!"
13
11
 
14
12
  data = JSON.parse(
15
13
  Base64.strict_decode64(event.data.fetch("message").fetch("data"))
16
14
  )
15
+ to_email = data.fetch("to")
16
+
17
+ NeonEmail::GreetingMailer.deliver(to_email: to_email)
17
18
 
18
19
  logger.info(data)
19
20
  end
data/lib/neon_email.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "neon_email/version"
2
+ require "neon_email/greeting_mailer"
2
3
 
3
4
  module NeonEmail
4
5
  class Error < StandardError; end
@@ -1,27 +1,28 @@
1
1
  require "sendgrid-ruby"
2
- # require "neon_secrets"
2
+ require "neon_secrets"
3
3
 
4
4
  module NeonEmail
5
5
  class GreetingMailer
6
6
  include SendGrid
7
7
 
8
- def self.deliver(message:)
9
- new(message: message).deliver
8
+ def self.deliver(to_email:)
9
+ new(to_email: to_email).deliver
10
10
  end
11
11
 
12
- def initialize(message:)
13
- @message = message
12
+ def initialize(to_email:)
13
+ @to_email = to_email
14
14
  end
15
15
 
16
16
  def deliver
17
- from = SendGrid::Email.new(email: "test@example.com")
18
- to = SendGrid::Email.new(email: "test@example.com")
19
- subject = "Sending with Twilio SendGrid is Fun"
20
- content = SendGrid::Content.new(type: "text/plain", value: message)
17
+ from = SendGrid::Email.new(email: "support@neonlaw.com")
18
+ to = SendGrid::Email.new(email: to_email)
19
+ subject = "Welcome to Neon Law!"
20
+ content = SendGrid::Content.new(type: "text/plain", value: "Welcome")
21
21
  mail = SendGrid::Mail.new(from, subject, to, content)
22
22
 
23
- sg = SendGrid::API.new(api_key: ENV["SENDGRID_API_KEY"])
24
- # sg = SendGrid::API.new(api_key: NeonSecrets::Getter.get(secret_name: "sendgrid_api_key"))
23
+ sg = SendGrid::API.new(
24
+ api_key: NeonSecrets::Getter.get(secret_name: "sendgrid_api_key")
25
+ )
25
26
  response = sg.client.mail._("send").post(request_body: mail.to_json)
26
27
 
27
28
  puts response
@@ -29,6 +30,6 @@ module NeonEmail
29
30
 
30
31
  private
31
32
 
32
- attr_reader :message
33
+ attr_reader :to_email
33
34
  end
34
35
  end
@@ -1,3 +1,3 @@
1
1
  module NeonEmail
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/neon_email.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_runtime_dependency "neon_schemas", "0.1.1"
26
26
  spec.add_runtime_dependency "functions_framework", "0.9.0"
27
+ spec.add_runtime_dependency "neon_secrets", "0.0.1"
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neon_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neon Law
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-15 00:00:00.000000000 Z
11
+ date: 2021-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: neon_schemas
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.9.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: neon_secrets
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.1
41
55
  description: A gem to handle outbound_email messages in Neon Law software space.
42
56
  email:
43
57
  - support@neonlaw.com