nexmo-voice 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: bf115bb53ea2a8a64922a53c9283fdd44b0fa0df
4
+ data.tar.gz: a3d27e3481f0192d4ca4ef47ca45df354c50726c
5
+ SHA512:
6
+ metadata.gz: f5135bae228164d0c543bc1aa829dfd768af8ce1c0062539b7fc86c7b61a1c2c60e06facce8cb40e243745154bf647ebd2ab63be6b78cc83816ae316d4075278
7
+ data.tar.gz: c302cdedce05dce11a6da0e1d93ad2dd4182e58e158e1166132507f8f924766a86be63ac910a5588f15fd5579185f8d7e54bd12040fe082a1ba01a9ff06e6933
@@ -0,0 +1,22 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nexmo-voice.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 fahchen
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,39 @@
1
+ # Nexmo::Voice
2
+
3
+ A Ruby wrapper for the Nexmo Voice API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'nexmo-voice'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install nexmo-voice
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ # Initialize your client
23
+ client = Nexmo::Voice::Client.new 'your_key', 'your_secret'
24
+
25
+ # Make a tts call with minimum options
26
+ options = {
27
+ to: 'recipient_number',
28
+ text: 'Hello from gem.'
29
+ }
30
+ client.ttses.create options
31
+ ```
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/fahchen/nexmo-voice/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,33 @@
1
+ require 'rest_client'
2
+
3
+ require 'nexmo/voice/version'
4
+ require 'nexmo/voice/calls'
5
+ require 'nexmo/voice/ttses'
6
+
7
+ module Nexmo
8
+ module Voice
9
+ BASE_URL = 'https://rest.nexmo.com'
10
+
11
+ class Client
12
+ attr_accessor :api_key, :api_secret,
13
+ :calls, :ttses
14
+
15
+ def initialize(api_key, api_secret)
16
+ @api_key, @api_secret = api_key, api_secret
17
+ @calls = Calls.new(self)
18
+ @ttses = Ttses.new(self)
19
+ end
20
+
21
+ def get(resource, entity = {})
22
+ uri = "#{BASE_URL}#{resource.class::RELATIVE_URL}"
23
+ params = entity.merge({
24
+ api_key: @api_key,
25
+ api_secret: @api_secret
26
+ })
27
+
28
+ RestClient.get(uri, params: params)
29
+ end
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ module Nexmo::Voice
2
+ class Calls
3
+ RELATIVE_URL = '/call/json'
4
+
5
+ attr_accessor :client
6
+
7
+ def initialize(client = nil)
8
+ raise "Can't create a call without Client" unless client
9
+ @client = client
10
+ end
11
+
12
+ def create(entity = {})
13
+ @client.get(self, entity)
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module Nexmo::Voice
2
+ class Ttses
3
+ RELATIVE_URL = '/tts/json'
4
+
5
+ attr_accessor :client
6
+
7
+ def initialize(client = nil)
8
+ raise "Can't create a call without Client" unless client
9
+ @client = client
10
+ end
11
+
12
+ def create(entity = {})
13
+ @client.get(self, entity)
14
+ end
15
+
16
+ end
17
+ end
18
+
@@ -0,0 +1,5 @@
1
+ module Nexmo
2
+ module Voice
3
+ VERSION = "0.0.1"
4
+ end
5
+ 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 'nexmo/voice/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'nexmo-voice'
8
+ spec.version = Nexmo::Voice::VERSION
9
+ spec.authors = ['fahchen']
10
+ spec.email = ['dev.fah@gmail.com']
11
+ spec.summary = %q{A Ruby wrapper for the Nexmo Voice API.}
12
+ spec.description = %q{A Ruby wrapper for the Nexmo Voice(only) API.}
13
+ spec.homepage = 'https://github.com/fahchen/nexmo-voice'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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 'rest-client', '~> 1.7.2'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.6'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec', '~> 3.0.0'
26
+ spec.add_development_dependency 'webmock', '~> 1.18.0'
27
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Nexmo::Voice::Calls do
4
+ let(:client) { Nexmo::Voice::Client.new('api_key', 'api_secret') }
5
+ let(:entity) { { to: '8618000000001', answer_url: 'http://test.com/answer_url' } }
6
+
7
+ before do
8
+ response_json = {
9
+ 'call-id' => 'd7d74aed5c754a992586c5baf01ed24d',
10
+ 'to' => '8618600000001',
11
+ 'status' => '0',
12
+ 'error-text' => 'Success'
13
+ }
14
+ stub_request(:get, %r(https://rest.nexmo.com/call/json.*)).to_return(body: response_json)
15
+ end
16
+
17
+ it 'not raises errors' do
18
+ expect {
19
+ client.calls.create(entity)
20
+ }.not_to raise_error
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Nexmo::Voice::Ttses do
4
+ let(:client) { Nexmo::Voice::Client.new('api_key', 'api_secret') }
5
+ let(:entity) { { to: '8618000000001', text: 'Hello from gem' } }
6
+
7
+ before do
8
+ response_json = {
9
+ 'call-id' => 'd7d74aed5c754a992586c5baf01ed24d',
10
+ 'to' => '8618600000001',
11
+ 'status' => '0',
12
+ 'error-text' => 'Success'
13
+ }
14
+ stub_request(:get, %r(https://rest.nexmo.com/tts/json.*)).to_return(body: response_json)
15
+ end
16
+
17
+ it 'not raises errors' do
18
+ expect {
19
+ client.ttses.create(entity)
20
+ }.not_to raise_error
21
+ end
22
+ end
23
+
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Nexmo::Voice do
4
+ it 'returns the base url' do
5
+ expect(Nexmo::Voice::BASE_URL).to eq 'https://rest.nexmo.com'
6
+ end
7
+ end
8
+
9
+ RSpec.describe Nexmo::Voice::Client do
10
+ let(:api_key) { 'test_api_key' }
11
+ let(:api_secret) { 'test_api_secret' }
12
+ let(:client) { Nexmo::Voice::Client.new api_key, api_secret }
13
+
14
+ it 'sets the api_key' do
15
+ expect(client.api_key).to eq api_key
16
+ end
17
+
18
+ it 'sets the api_secret' do
19
+ expect(client.api_secret).to eq api_secret
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ require 'nexmo/voice'
2
+ require 'webmock/rspec'
3
+
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nexmo-voice
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - fahchen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.7.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.7.2
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.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.18.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.18.0
83
+ description: A Ruby wrapper for the Nexmo Voice(only) API.
84
+ email:
85
+ - dev.fah@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/nexmo/voice.rb
97
+ - lib/nexmo/voice/calls.rb
98
+ - lib/nexmo/voice/ttses.rb
99
+ - lib/nexmo/voice/version.rb
100
+ - nexmo-voice.gemspec
101
+ - spec/nexmo/voice/calls_spec.rb
102
+ - spec/nexmo/voice/ttses_spec.rb
103
+ - spec/nexmo/voice_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: https://github.com/fahchen/nexmo-voice
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.2.2
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: A Ruby wrapper for the Nexmo Voice API.
129
+ test_files:
130
+ - spec/nexmo/voice/calls_spec.rb
131
+ - spec/nexmo/voice/ttses_spec.rb
132
+ - spec/nexmo/voice_spec.rb
133
+ - spec/spec_helper.rb