boundio 0.0.3 → 0.0.4

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.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Mobalean LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/[YOUR_GITHUB_USERNAME]/[YOUR_PROJECT_NAME].png)](http://travis-ci.org/pwim/boundio)
4
4
 
5
- Alpha-version of the beta-api for Boundio. See details [the documentation](http://www.doorkeeperhq.com/developer/boundio-ruby-gem) for details.
5
+ Alpha-version of the beta-api for Boundio. See [the documentation](http://www.doorkeeperhq.com/developer/boundio-ruby-gem) for details.
@@ -2,6 +2,10 @@ module Boundio
2
2
  class AudioFile < Resource
3
3
  attr_accessor :convtext, :id, :file
4
4
 
5
+ def self.api_version
6
+ "v1"
7
+ end
8
+
5
9
  def self.exceptions
6
10
  super.merge(2 => ArgumentError.new("insufficient parameters or file to big"))
7
11
  end
data/lib/boundio/call.rb CHANGED
@@ -2,7 +2,7 @@ module Boundio
2
2
  class Call < Resource
3
3
  attr_accessor :tel_to, :cast, :id
4
4
  def self.exceptions
5
- super.merge(4 => NotEnoughPoints)
5
+ super.merge(3 => NoVoiceFile, 4 => NotEnoughPoints)
6
6
  end
7
7
 
8
8
  def save
@@ -11,7 +11,7 @@ module Boundio
11
11
  true
12
12
  end
13
13
 
14
- class NotEnoughPoints < Boundio::Exception
15
- end
14
+ class NotEnoughPoints < Boundio::Exception; end
15
+ class NoVoiceFile < Boundio::Exception; end
16
16
  end
17
17
  end
@@ -1,22 +1,21 @@
1
1
  module Boundio
2
2
  class Resource
3
3
  class << self
4
- def user_serial_id
5
- ENV["BOUNDIO_USER_SERIAL_ID"]
6
- end
7
-
8
- def api_key
9
- ENV["BOUNDIO_API_KEY"]
4
+ def api_version
5
+ "vd1"
10
6
  end
11
7
 
12
- def user_authentication_key
13
- ENV["BOUNDIO_USER_AUTHENTICATION_KEY"]
8
+ %w[user_serial_id api_key user_key].each do |s|
9
+ var = "BOUNDIO_#{s.upcase}"
10
+ define_method(s) do
11
+ ENV[var] || raise("Please export #{var}")
12
+ end
14
13
  end
15
14
 
16
15
  def request(method, path, params)
17
- params = params.merge(:key => api_key, :auth => user_authentication_key)
16
+ params = params.merge(:key => api_key, :auth => user_key)
18
17
  res = RestClient.send method,
19
- File.join("https://boundio.jp/api/vd1/#{user_serial_id}", path),
18
+ File.join("https://boundio.jp/api/", api_version, user_serial_id, path),
20
19
  method == :get ? { :params => params } : params
21
20
  res = JSON.parse(res)
22
21
  res = res.first if res.is_a?(Array)
@@ -1,3 +1,3 @@
1
1
  module Boundio
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -2,7 +2,7 @@ require "test_helper"
2
2
 
3
3
  class TestAudioFile < BoundioTest
4
4
  def test_create
5
- stub_request(:post, "https://boundio.jp/api/vd1/user_serial_id/file/post").
5
+ stub_request(:post, "https://boundio.jp/api/v1/user_serial_id/file/post").
6
6
  with(:body => {"auth"=>"user_authentication_key", "convtext"=>"foo", "filename"=>"foo", "key"=>"api_key"}).to_return(:body => {:success => "true", :fileid => 5}.to_json)
7
7
  file = Boundio::AudioFile.new(:convtext => "foo")
8
8
  file.save
data/test/test_helper.rb CHANGED
@@ -7,7 +7,7 @@ class BoundioTest < MiniTest::Unit::TestCase
7
7
  def setup
8
8
  ENV["BOUNDIO_USER_SERIAL_ID"] = "user_serial_id"
9
9
  ENV["BOUNDIO_API_KEY"] = "api_key"
10
- ENV["BOUNDIO_USER_AUTHENTICATION_KEY"] = "user_authentication_key"
10
+ ENV["BOUNDIO_USER_KEY"] = "user_authentication_key"
11
11
  end
12
12
 
13
13
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boundio
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul McMahon
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-13 00:00:00 Z
18
+ date: 2012-03-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: minitest
@@ -128,6 +128,7 @@ files:
128
128
  - .gitignore
129
129
  - .travis.yml
130
130
  - Gemfile
131
+ - LICENSE
131
132
  - README.md
132
133
  - Rakefile
133
134
  - bin/boundio