neon_email 0.0.9 → 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: ad78eed256499a05d240ba99af40822ec4c985a1623d122e9fede55924ed5a80
4
- data.tar.gz: f5f653716b812dc9e965f4e5087911c23ee9ed2593c12f71e906e719fe90c5a7
3
+ metadata.gz: cb3f35cf3264d0b746bb69f06cf725c57e8dd4fd35b3a177a88d1fb3ab0902f4
4
+ data.tar.gz: 42ba2f0e1e14e0c510aa383b9a08cbaf80d9ac40747bcc7fd13e75cb4b455b62
5
5
  SHA512:
6
- metadata.gz: d5e47e66cf170397b079d1b24175df6acb3067cb08674a6cc4009c11e080bb906c0491909279dc216c79bc377545ad83a8a58e7d552abbd9e9e9b8cc28869f13
7
- data.tar.gz: 509b61b13a28d52e03912bb23a2ab3d2457adfcb0dcb6be2de0e27857f4456b57b5cd66618150f7e599d8d33fc01c83ca0bbee826453a0428584a1e2b1c5142c
6
+ metadata.gz: 3ffdb88d7f5b1ec5970918be95d02a95beaafcadb2b96b1b84ccb5aed63d800d51e7f44928fb4118b03b77f5f0388ae720ff6b378ea97266ef0e6f9bc82b94ff
7
+ data.tar.gz: b189186688a0dee4fa06707d1b57f1ce9d509eae367c9ff9730674a84aa670fdf534dd17e60d24dc4efa2c2813b7b0ba7cc90337dbfcc405a5476bc8f5235a8d
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neon_email (0.0.8)
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
@@ -1,11 +1,20 @@
1
1
  require "functions_framework"
2
2
  require "neon_email"
3
3
  require "logger"
4
+ require "base64"
5
+ require "json"
4
6
 
5
7
  logger = Logger.new($stdout)
6
8
 
7
- WELCOME_EMAIL_TOPIC = "com.neon_law.outbound_email.welcome_email".freeze
9
+ FunctionsFramework.cloud_event "outbound_emails.welcome_email" do |event|
10
+ logger.info "hey you!"
8
11
 
9
- FunctionsFramework.cloud_event WELCOME_EMAIL_TOPIC do |event|
10
- logger.info event.data
12
+ data = JSON.parse(
13
+ Base64.strict_decode64(event.data.fetch("message").fetch("data"))
14
+ )
15
+ to_email = data.fetch("to")
16
+
17
+ NeonEmail::GreetingMailer.deliver(to_email: to_email)
18
+
19
+ logger.info(data)
11
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.0.9"
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.0.9
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-14 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