lucid_intercom 0.10.0 → 0.11.0

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: 0fdfafd4312a7ee7bce683223c3b5ce972199834e5668c505a0fca07f5813faa
4
- data.tar.gz: 93d58ab3f55ea61f6c020dcc6f83a11b9e90ba3ba9521d45cd214bf8990fecfc
3
+ metadata.gz: 0c79fdf9db9290c3f3ce19018e653330829d4ae65d9d651dcc01a3654e38d3a2
4
+ data.tar.gz: 75ad290ae14e0f376d61481354be8d0f657975158cc909f6c0d835434a83d211
5
5
  SHA512:
6
- metadata.gz: 0c3bb863f4d31b9312b14d9774711f74e02e636bb9e58f092706ea3f2a316899a05b9ca21fbbf691c763e8666a13bbd5f2e2cbda6fa1b1c76a5298457ce94219
7
- data.tar.gz: 7523ced9f7b08cf4198130b741f13f762e171f653a91138625fa5192143fa7c9a2e5652f6b9fc579f67b3b97b118626a6eff1c9ba3aed8ce8dcbd6d90c58526a
6
+ metadata.gz: 51125d01350d54d600663f6be32bf98665bbb7c24f82aeae488fd8fe27b4a6ee0e4e6df0da1fbcf8acccc93f2cd16b627dda81ef2bea6b51b7e2c1e2fcc73c09
7
+ data.tar.gz: 0ea00b6f1ae51e1216e349d45cc5be0dd54f0363d1a4da3c952a1a5674ade82b5968b8f129c6472ba4736100cc637e9b9056be6e2a9abb42ef67ea03b11978a7
data/README.md CHANGED
@@ -18,7 +18,8 @@ Usage
18
18
  '...', # access_token
19
19
  '...', # secret
20
20
  '...', # app_id
21
- '...' # app_prefix
21
+ '...', # app_prefix
22
+ 123456 # admin_id
22
23
  )
23
24
 
24
25
  Here, ‘app_prefix’ is the snakecased app name, e.g. ‘smart_order_tags’
@@ -17,6 +17,8 @@ module LucidIntercom
17
17
  autoload :PostRequest, 'lucid_intercom/post_request.rb'
18
18
  autoload :RenderSnippet, 'lucid_intercom/render_snippet.rb'
19
19
  autoload :Response, 'lucid_intercom/response.rb'
20
+ autoload :SendEmail, 'lucid_intercom/send_email.rb'
21
+ autoload :SendMessage, 'lucid_intercom/send_message.rb'
20
22
  autoload :UpdateUser, 'lucid_intercom/update_user.rb'
21
23
  autoload :UserAttributes, 'lucid_intercom/user_attributes.rb'
22
24
  autoload :VERSION, 'lucid_intercom/version.rb'
@@ -15,7 +15,8 @@ module LucidIntercom
15
15
  :access_token,
16
16
  :secret,
17
17
  :app_id,
18
- :app_prefix
18
+ :app_prefix,
19
+ :admin_id # for messages/emails
19
20
  )
20
21
 
21
22
  # @param config [Config]
@@ -44,5 +45,7 @@ module LucidIntercom
44
45
  param :app_id
45
46
  # @return [String] the snakecased app name, e.g. 'smart_order_tags'
46
47
  param :app_prefix
48
+ # @return [Integer]
49
+ param :admin_id
47
50
  end
48
51
  end
@@ -16,5 +16,7 @@ module LucidIntercom
16
16
  Container.register(:notify_uninstalled) { NotifyUninstalled.new }
17
17
  Container.register(:post_request) { PostRequest.new }
18
18
  Container.register(:render_snippet) { RenderSnippet.new }
19
+ Container.register(:send_email) { SendEmail.new }
20
+ Container.register(:send_message) { SendMessage.new }
19
21
  Container.register(:update_user) { UpdateUser.new }
20
22
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lucid_intercom'
4
+
5
+ module LucidIntercom
6
+ class SendEmail
7
+ #
8
+ # @param post_request [#call]
9
+ #
10
+ def initialize(post_request: Container[:post_request])
11
+ @post_request = post_request
12
+ end
13
+
14
+ #
15
+ # @param to [String] a user email address
16
+ # @param subject [String]
17
+ # @param body [String]
18
+ #
19
+ def call(to, subject, body)
20
+ @post_request.('messages', {
21
+ message_type: 'email',
22
+ subject: subject,
23
+ body: body,
24
+ template: 'plain',
25
+ from: {
26
+ type: 'admin',
27
+ id: LucidIntercom.admin_id,
28
+ },
29
+ to: {
30
+ type: 'user',
31
+ email: to,
32
+ },
33
+ })
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lucid_intercom'
4
+
5
+ module LucidIntercom
6
+ class SendMessage
7
+ #
8
+ # @param post_request [#call]
9
+ #
10
+ def initialize(post_request: Container[:post_request])
11
+ @post_request = post_request
12
+ end
13
+
14
+ #
15
+ # @param to [String] a user email address
16
+ # @param body [String]
17
+ #
18
+ def call(to, body)
19
+ @post_request.('messages', {
20
+ message_type: 'inapp',
21
+ body: body,
22
+ from: {
23
+ type: 'admin',
24
+ id: LucidIntercom.admin_id,
25
+ },
26
+ to: {
27
+ type: 'user',
28
+ email: to,
29
+ },
30
+ })
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucidIntercom
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucid_intercom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelsey Judson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-26 00:00:00.000000000 Z
11
+ date: 2019-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -116,6 +116,8 @@ files:
116
116
  - lib/lucid_intercom/post_request.rb
117
117
  - lib/lucid_intercom/render_snippet.rb
118
118
  - lib/lucid_intercom/response.rb
119
+ - lib/lucid_intercom/send_email.rb
120
+ - lib/lucid_intercom/send_message.rb
119
121
  - lib/lucid_intercom/snippet.html
120
122
  - lib/lucid_intercom/update_user.rb
121
123
  - lib/lucid_intercom/user_attributes.rb