textris 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd28b9ac3a423603ff04fe56ed5551b98e0ee25efb567c2e9bebf0e40607a547
4
- data.tar.gz: 303d52aac458a7cf0b7e779261b3356bf331229fafe0030802c06c760d692682
3
+ metadata.gz: b3b346e56a0f337f7bc490ece9137743617baf7f739c0c1029317602651b852d
4
+ data.tar.gz: a5125b59502e41ab9c2d94edbb68cc21aee52bcd4e6f95b05cf934c6668a80c6
5
5
  SHA512:
6
- metadata.gz: 8b90c45135057231f6b3689599628d9d3e2264938eb1f1d4526764e6e4ce198eeb500c367833e5d4ea581b81603b24f7b79a8794b687dd3015b613082228e830
7
- data.tar.gz: 1d19bfb9156bf45962134c08d6e96f8516fa65b8ae8fc7f17b8f3fbc4846a947c2c429f64655494831cd3127ae93f35849c67e49b19e785f394ee17613a7de71
6
+ metadata.gz: 00e3ac83e238ec56fe070f32efb04c72327d660301d42c0f1adaf8fa3d088e62215459ebdbc84860a9b78cb4777abe58faaae394e756ce161fcbe1dd56caeded
7
+ data.tar.gz: e2f655d43ecb4e2aa73a83635358cbc54832e05f0beadbe6e65f4855b891f270a2954a7282233a0a8c5a8ffefd0aa4098689ff2839cd5ccda4070da9a49b4519
data/README.md CHANGED
@@ -204,6 +204,8 @@ Twilio.configure do |config|
204
204
  end
205
205
  ```
206
206
 
207
+ To use Twilio's Copilot use `twilio_messaging_service_sid` in place of `from` when sending a text or setting defaults.
208
+
207
209
  #### Nexmo
208
210
 
209
211
  In order to use Nexmo with **textris**, you need to include the `nexmo` gem in your `Gemfile`:
@@ -8,7 +8,7 @@ module Textris
8
8
  log :debug, "Texter: #{message.texter || 'UnknownTexter'}" + "#" +
9
9
  "#{message.action || 'unknown_action'}"
10
10
  log :debug, "Date: #{Time.now}"
11
- log :debug, "From: #{message.from || 'unknown'}"
11
+ log :debug, "From: #{message.from || message.twilio_messaging_service_sid || 'unknown'}"
12
12
  log :debug, "To: #{message.to.map { |i| Phony.format(to) }.join(', ')}"
13
13
  log :debug, "Content: #{message.content}"
14
14
  (message.media_urls || []).each_with_index do |media_url, index|
@@ -23,7 +23,15 @@ module Textris
23
23
 
24
24
  def from_template
25
25
  Rails.application.config.try(:textris_mail_from_template) ||
26
- "%{from_name:d}-%{from_phone}@%{env:d}.%{app:d}.com"
26
+ "#{from_format}@%{env:d}.%{app:d}.com"
27
+ end
28
+
29
+ def from_format
30
+ if message.twilio_messaging_service_sid
31
+ '%{twilio_messaging_service_sid}'
32
+ else
33
+ '%{from_name:d}-%{from_phone}'
34
+ end
27
35
  end
28
36
 
29
37
  def to_template
@@ -59,7 +67,7 @@ module Textris
59
67
  case key
60
68
  when 'app', 'env'
61
69
  get_rails_variable(key)
62
- when 'texter', 'action', 'from_name', 'from_phone', 'content'
70
+ when 'texter', 'action', 'from_name', 'from_phone', 'content', 'twilio_messaging_service_sid'
63
71
  message.send(key)
64
72
  when 'media_urls'
65
73
  message.media_urls.join(', ')
@@ -3,13 +3,20 @@ module Textris
3
3
  class Twilio < Textris::Delivery::Base
4
4
  def deliver(to)
5
5
  options = {
6
- :from => PhoneFormatter.format(message.from_phone),
7
6
  :to => PhoneFormatter.format(to),
8
7
  :body => message.content
9
8
  }
9
+
10
+ if message.twilio_messaging_service_sid
11
+ options[:messaging_service_sid] = message.twilio_messaging_service_sid
12
+ else
13
+ options[:from] = PhoneFormatter.format(message.from_phone)
14
+ end
15
+
10
16
  if message.media_urls.is_a?(Array)
11
17
  options[:media_url] = message.media_urls
12
18
  end
19
+
13
20
  client.messages.create(options)
14
21
  end
15
22
 
@@ -1,7 +1,7 @@
1
1
  module Textris
2
2
  class Message
3
3
  attr_reader :content, :from_name, :from_phone, :to, :texter, :action, :args,
4
- :media_urls
4
+ :media_urls, :twilio_messaging_service_sid
5
5
 
6
6
  def initialize(options = {})
7
7
  initialize_content(options)
@@ -68,7 +68,9 @@ module Textris
68
68
  end
69
69
 
70
70
  def initialize_author(options)
71
- if options.has_key?(:from)
71
+ if options.has_key?(:twilio_messaging_service_sid)
72
+ @twilio_messaging_service_sid = options[:twilio_messaging_service_sid]
73
+ elsif options.has_key?(:from)
72
74
  @from_name, @from_phone = parse_from options[:from]
73
75
  else
74
76
  @from_name = options[:from_name]
@@ -1,3 +1,3 @@
1
1
  module Textris
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Visuality
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-24 00:00:00.000000000 Z
12
+ date: 2019-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler