twilio_client 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d6d61edc39d8cc310dcf2c3967025bdc208a5fbc
4
+ data.tar.gz: 4d562e618e938c172a284cc24d706335f1197a7d
5
+ SHA512:
6
+ metadata.gz: 9361f72e9fc63b5c7c4056d8195cf6ed4ffd8d33669d7fccea807899001828c340a71fd982ee1055552646b206f5b182737438056e071b824c8e8eb7489eebcf
7
+ data.tar.gz: 72048680da696855a80e6af846cf7c8a173d1d574b98932b8c6920854b513814726f9e3ef616dcbe310060be1f582c1ab2d8762ff7588a4812fe562c683dbdc3
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in twilio_client.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Dylan Jhaveri
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,54 @@
1
+ # TwilioClient
2
+
3
+ Simple interface for initializing with your twilio account credentials and sending a text. You Can also access the Twilio client directly with TwilioClient.client
4
+
5
+ Initialize with account sid, account token and a from number
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'twilio-client'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install twilio-client
20
+
21
+ ## Configuration
22
+
23
+ ```ruby
24
+ TwilioClient.configure({
25
+ sid: 'string',
26
+ token: 'string',
27
+ from: '10 digit number'
28
+ })
29
+ ```
30
+
31
+ ## Public Class Methods
32
+
33
+ * TwilioClient.send_text(to, body)
34
+ * TwilioClient.client (to access the twilio client directly)
35
+
36
+ ## Test Mode
37
+
38
+ * Stops the supported methods from making API requests (you can still access the raw twilio client directly, which will still make API requests)
39
+ * Put the client into test mode:
40
+ ```ruby
41
+ # put the client into test mode:
42
+ TwilioClient.test_mode = true
43
+
44
+ # take the client out of test mode:
45
+ TwilioClient.test_mode = false
46
+ ```
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork it
51
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
52
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 4. Push to the branch (`git push origin my-new-feature`)
54
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,45 @@
1
+ require "twilio_client/version"
2
+ require 'twilio-ruby'
3
+
4
+ module TwilioClient
5
+
6
+ @config = {}
7
+ @test_mode = false
8
+
9
+ def self.test_mode=(boolean)
10
+ @test_mode = boolean
11
+ end
12
+
13
+ def self.configure(opts)
14
+ require_configs(opts)
15
+ @config[:sid] = opts.fetch(:sid)
16
+ @config[:token] = opts.fetch(:token)
17
+ @config[:from] = opts.fetch(:from)
18
+ end
19
+
20
+ def self.client
21
+ metaclass = class<<self;self;end
22
+ metaclass.send(:define_method, :client) do
23
+ Twilio::REST::Client.new(@config.fetch(:sid), @config.fetch(:token))
24
+ end
25
+ client
26
+ end
27
+
28
+ def self.send_text(to, body)
29
+ unless @test_mode
30
+ client.account.messages.create(
31
+ from: @config.fetch(:from),
32
+ to: to,
33
+ body: body,
34
+ )
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def self.require_configs(opts)
41
+ [:sid, :token, :from].each do |key|
42
+ raise ArgumentError.new "Must Supply a #{key} config" unless opts[key]
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ module TwilioClient
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,41 @@
1
+ require 'pry'
2
+ require 'twilio_client'
3
+ require 'test/unit'
4
+ require 'rr'
5
+
6
+ class TestTwilioClient < Test::Unit::TestCase
7
+
8
+ def setup
9
+ @sid = '123'
10
+ @token = '123'
11
+ @from = '123'
12
+ stub(TwilioClient).send_text
13
+ end
14
+
15
+ def config
16
+ TwilioClient.configure({
17
+ sid: @sid,
18
+ token: @token,
19
+ from: @from,
20
+ })
21
+ end
22
+
23
+ def test_config
24
+ assert_nothing_raised do
25
+ config
26
+ end
27
+ end
28
+
29
+ def test_client
30
+ mock(::Twilio::REST::Client).new(@sid, @token)
31
+ config
32
+ TwilioClient.client
33
+ end
34
+
35
+ def test_errors
36
+ assert_raises ArgumentError do
37
+ TwilioClient.configure({sid: @sid})
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'twilio_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "twilio_client"
8
+ spec.version = TwilioClient::VERSION
9
+ spec.authors = ["Dylan Jhaveri"]
10
+ spec.email = ["dylanjhaveri@gmail.com"]
11
+ spec.description = %q{ Twilio Client wrapper for twilio-ruby }
12
+ spec.summary = %q{ Twilio Client wrapper for twilio-ruby }
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "twilio-ruby"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "pry"
26
+ spec.add_development_dependency "rr"
27
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twilio_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dylan Jhaveri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: twilio-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: ' Twilio Client wrapper for twilio-ruby '
84
+ email:
85
+ - dylanjhaveri@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/twilio_client.rb
96
+ - lib/twilio_client/version.rb
97
+ - test/twilio_client_test.rb
98
+ - twilio_client.gemspec
99
+ homepage: ''
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.1.11
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Twilio Client wrapper for twilio-ruby
123
+ test_files:
124
+ - test/twilio_client_test.rb