twilito 0.1.0 → 0.2.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: 7761e9e3ab42c77312bdb7207896ece722ce001a9a1c099c4a79b702f72c2aba
4
- data.tar.gz: e1e4830cf7ea75dd00f55ffb796bf034128490a2ecbc6e066d8195771e6bf133
3
+ metadata.gz: 319e2e7600c3634e97209ebeec8cde162d5dbae23d4f42854d9dd744babe6f05
4
+ data.tar.gz: 730b25f694951541de4a93a22f658e2dc9c3ea29d1604ad16a1a9a0602887a75
5
5
  SHA512:
6
- metadata.gz: 12b4f5cf4934394c5e4e2f2ff3a9931c42ea6d33ebdd8faa0e7a53f27ee89a6a7a779b2cac9b122264cfbd7358556c974728e7550075db92449b1f873a6b2ba8
7
- data.tar.gz: 7a4e56dfac70088de70c35bd34012573bb87c807461883062ec41a6149716676d2317f3fb849947b8a36b8bafe88251550f0f9d61d083c2840cc2a1ebe24efcc
6
+ metadata.gz: 784f7d0f2e7b19510da416817bcd807af73b05d3cb894233316d449490f74c5d5a6a6302a4f03294cd6a80cf8d17f22088003c629ae2c898d2a8426c9925ac48
7
+ data.tar.gz: a2e9efd049e3cedf04a3a83ac9ce0d6337b88a3bbb861858ff10b432445bf240b4de0b037fbd9c426d93dcd61fb6d22f46b9989877fea06600a4bbd181e52346
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ruby '2.6.1'
3
+ ruby '>= 2.4.0'
4
4
 
5
5
  source "https://rubygems.org"
6
6
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- twilito (0.1.0)
4
+ twilito (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -40,4 +40,4 @@ RUBY VERSION
40
40
  ruby 2.6.1p33
41
41
 
42
42
  BUNDLED WITH
43
- 2.0.1
43
+ 2.0.2
data/README.md CHANGED
@@ -2,15 +2,17 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/alexford/twilito.svg?branch=master)](https://travis-ci.org/alexford/twilito)
4
4
 
5
- A tiny, zero dependency helper for sending text messages with Twilio
5
+ A tiny, zero dependency helper for sending text messages with Twilio. Just enough of a wrapper to abstract away Twilio's REST API for sending messages, without *anything* else.
6
6
 
7
7
  ## Why
8
8
 
9
- Twilio's full on Ruby library does a lot, and has a large memory footprint—too large for just sending an SMS. It's also more difficult to mock and verify than I'd like for a simple task like sending an individual SMS.
9
+ Twilio's [full Ruby library](https://github.com/twilio/twilio-ruby) does a *lot*, and has a large memory footprint to go with it—too large for just sending a message. It's also more difficult to mock and verify in tests than I'd like.
10
10
 
11
- Using Twilio's REST API directly is fine, but can be cumbersome.
11
+ Using [Twilio's REST API](https://www.twilio.com/docs/usage/api) directly is fine, but can be cumbersome.
12
12
 
13
- Twilito is just enough of a wrapper to abstract away the REST API without loading the rest of the Twilio ecosystem.
13
+ You should consider using Twilito if the only thing you need to do is send text messages and you don't want to worry about making HTTP requests to Twilio yourself.
14
+
15
+ If you use more of Twilio, consider [twilio-ruby](https://github.com/twilio/twilio-ruby) or interact with the REST API in another way.
14
16
 
15
17
  ## Usage
16
18
 
@@ -41,7 +43,7 @@ result.response # => Raw response (instance of Net::HTTPResponse)
41
43
  result.data # => Hash of response data (parsed from JSON)
42
44
  ```
43
45
 
44
- #### Use send! to raise on error instead
46
+ #### Use send_sms! to raise on error instead
45
47
 
46
48
  ```ruby
47
49
  begin
@@ -78,27 +80,7 @@ end
78
80
  Twilito.send_sms!(to: '+15555555555', body: 'Foo')
79
81
  ```
80
82
 
81
- #### Really, everything
82
-
83
- ```ruby
84
- # In an initializer or something like that:
85
-
86
- Twilito.configure do |config|
87
- # Store your secrets elsewhere
88
- config.account_sid = ENV['TWILIO_ACCOUNT_SID']
89
- config.auth_token = ENV['TWILIO_AUTH_TOKEN']
90
-
91
- config.from = '+16145555555'
92
- config.to = '+15555555555'
93
- config.body = 'A new user signed up'
94
- end
95
- ```
96
-
97
- ```ruby
98
- # Later, in your code:
99
-
100
- Twilito.send_sms!
101
- ```
83
+ **Everything can be defaulted, including the message body, so that a bare `Twilio.send_sms!` can work in your code**
102
84
 
103
85
  ## Testing your code
104
86
 
@@ -7,6 +7,7 @@ module Twilito
7
7
 
8
8
  Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
9
9
  req = Net::HTTP::Post.new(uri)
10
+ req.initialize_http_header({ 'User-Agent' => "Ruby Twilito/#{Twilito::VERSION}" })
10
11
  req.basic_auth(args[:account_sid], args[:auth_token])
11
12
  req.set_form_data(twilio_params(args))
12
13
 
@@ -1,23 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Twilito
4
- Result = Struct.new(:success?, :errors, :sid, :response, keyword_init: true) do
5
- def self.success(**args)
6
- new(success?: true, **args)
4
+ Result = Struct.new(:success, :errors, :sid, :response) do
5
+ def initialize(success:, errors: [], sid: nil, response: nil)
6
+ super(success, errors, sid, response)
7
7
  end
8
8
 
9
- def self.failure(**args)
10
- new(success?: false, **args)
9
+ def self.success(**args)
10
+ new(success: true, **args)
11
11
  end
12
12
 
13
- def errors
14
- to_h[:errors] || []
13
+ def self.failure(**args)
14
+ new(success: false, **args)
15
15
  end
16
16
 
17
17
  def data
18
18
  JSON.parse(response_body || '{}')
19
19
  end
20
20
 
21
+ def success?
22
+ to_h[:success] || false
23
+ end
24
+
21
25
  private
22
26
 
23
27
  def response_body
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Twilito
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -10,6 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.version = Twilito::VERSION
11
11
  spec.authors = ["Alex Ford"]
12
12
  spec.email = ["alexford87@me.com"]
13
+ spec.required_ruby_version = '>= 2.4.0'
13
14
 
14
15
  spec.summary = "A tiny, zero dependency, and easy to test helper for sending text messages with Twilio"
15
16
  spec.homepage = "https://github.com/alexford/twilito"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Ford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-27 00:00:00.000000000 Z
11
+ date: 2019-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -116,14 +116,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: '0'
119
+ version: 2.4.0
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.0.1
126
+ rubygems_version: 3.0.3
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: A tiny, zero dependency, and easy to test helper for sending text messages