transcribeme 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 617a97dd3dbf3606b2fdff37f48c040c25ade8ee
4
+ data.tar.gz: 0038ad97d7466081fa1be3155e99441bb9638719
5
+ SHA512:
6
+ metadata.gz: 8277614f960e31d80009ee1dfc21c470f9fbe7fbb65284021778d6c5dc833fdf98e9a324c43742e3309a1f9928930c7804af46c2007daadb255f4628f4c8abd2
7
+ data.tar.gz: 00a829a9c64ea49f7b658b321d8f0172fa2237fb5cd05d43e8836c765402358810f0a8ece9cb1909cdbf194b3f56da7f95dfa1319574d6a124934ff7ccbc532c
@@ -0,0 +1,18 @@
1
+ .DS_Store
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in transcribeme-api.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Caleb Tutty
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,31 @@
1
+ # TranscribeMe gem
2
+
3
+ [![Dependency Status](https://gemnasium.com/tuttinator/transcribeme.png)](https://gemnasium.com/tuttinator/transcribeme)
4
+
5
+ This gem is a Ruby wrapper for the TranscribeMe SOAP API, built on Savon
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'transcribeme'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install transcribeme
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,29 @@
1
+ module TranscribeMe
2
+ module API
3
+ class CheckTranscriptionReady
4
+ def initialize(session_id, recording_id, client)
5
+ @session_id, @recording_id, @client = session_id, recording_id, client
6
+ end
7
+
8
+ def check!
9
+ response = @client.call :check_transcription_ready, xml: xml
10
+ response.body[:check_transcription_ready_response][:check_transcription_ready_result]
11
+ end
12
+
13
+ private
14
+
15
+ def xml
16
+ xml = Builder::XmlMarkup.new.tag!(*SOAP_ENVELOPE) do |xml|
17
+ xml.tag!("soapenv:Body") do |xml|
18
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:CheckTranscriptionReady") do |xml|
19
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:sessionID") { |xml| xml.text! @session_id }
20
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:recId") { |xml| xml.text! @recording_id }
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,57 @@
1
+ module TranscribeMe
2
+ module API
3
+
4
+ class Client
5
+
6
+ attr_reader :client
7
+
8
+ def initialize
9
+ @client = Savon.client(wsdl: WSDL, endpoint: ENDPOINT, namespace: NAMESPACE, namespace_identifier: NAMESPACE_IDENTIFIER)
10
+ initialize_session!
11
+ end
12
+
13
+
14
+ def initialize_session!
15
+ @session = Session.new(@client)
16
+ @session.create_on_server!
17
+ end
18
+
19
+ def login_with(username, password)
20
+ initialize_session! unless @session.try :valid?
21
+ @customer_login_id = CustomerLogin.new(@session.session_id, username, password, @client).login_on_server!
22
+ end
23
+
24
+ def get_recordings
25
+ raise "Login first!" unless @customer_login_id
26
+ @recordings = Recordings.new(@session.session_id, @client).get_list!
27
+ end
28
+
29
+ def submit_recording(recording)
30
+ initialize_session! unless @session.try :valid?
31
+ Submission.new(@session.session_id, recording, @client).submit!
32
+ end
33
+
34
+ def submit_recording_with_promocode(recording, promocode)
35
+ initialize_session! unless @session.try :valid?
36
+ SubmissionWithPromocode.new(@session.session_id, recording, promocode, @client).submit!
37
+ end
38
+
39
+ def get_status(recording_id)
40
+ raise "Login first!" unless @customer_login_id
41
+ CheckTranscriptionReady.new(@session.session_id, recording_id, @client).check!
42
+ end
43
+
44
+ def get_upload_url
45
+ raise "Login first!" unless @customer_login_id
46
+ UploadUrl.new(@session.session_id, @client).retrieve!
47
+ end
48
+
49
+ def logout!
50
+ raise "Login first!" unless @customer_login_id
51
+ FinalizeSession.new(@session.session_id, @client).submit!
52
+ end
53
+
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,33 @@
1
+ module TranscribeMe
2
+ module API
3
+
4
+ class CustomerLogin
5
+
6
+ attr_reader :customer_id
7
+
8
+ def initialize(session_id, username, password, client)
9
+ @session_id, @username, @password, @client = session_id, username, password, client
10
+ end
11
+
12
+ def login_on_server!
13
+ response = @client.call :sign_in, xml: xml
14
+ @customer_id = response.body[:sign_in_response][:sign_in_result]
15
+ end
16
+
17
+ private
18
+
19
+ def xml
20
+ xml = Builder::XmlMarkup.new.tag!(*SOAP_ENVELOPE) do |xml|
21
+ xml.tag!("soapenv:Body") do |xml|
22
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:SignIn") do |xml|
23
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:sessionID") { |xml| xml.text! @session_id }
24
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:username") { |xml| xml.text! @username }
25
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:password") { |xml| xml.text! @password }
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ module TranscribeMe
2
+ module API
3
+
4
+ class FinalizeSession
5
+
6
+ def initialize(session_id, client)
7
+ @session_id, @client = session_id, client
8
+ end
9
+
10
+ def submit!
11
+ response = @client.call :finalize_session, xml: xml
12
+ response.body[:finalize_session_response][:finalize_session_result]
13
+ end
14
+
15
+ private
16
+
17
+ def xml
18
+ xml = Builder::XmlMarkup.new.tag!(*SOAP_ENVELOPE) do |xml|
19
+ xml.tag!("soapenv:Body") do |xml|
20
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:FinalizeSession") do |xml|
21
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:sessionID") { |xml| xml.text! @session_id }
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,32 @@
1
+ module TranscribeMe
2
+ module API
3
+
4
+ class Recordings
5
+
6
+ attr_reader :list
7
+
8
+ def initialize(session_id, client)
9
+ @session_id, @client = session_id, client
10
+ end
11
+
12
+ def get_list!
13
+ response = @client.call :get_customer_recordings, xml: xml
14
+ @list = response.body[:get_customer_recordings_response][:get_customer_recordings_result][:recording_info]
15
+ end
16
+
17
+ private
18
+
19
+ def xml
20
+ xml = Builder::XmlMarkup.new.tag!(*SOAP_ENVELOPE) do |xml|
21
+ xml.tag!("soapenv:Body") do |xml|
22
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:GetCustomerRecordings") do |xml|
23
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:sessionID") { |xml| xml.text! @session_id }
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ module TranscribeMe
2
+ module API
3
+
4
+ class Session
5
+
6
+ attr_reader :session_id
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def create_on_server!
13
+ response = @client.call :initialize_session, xml: xml
14
+ @session_expiry_time = 1.hour.from_now
15
+ @session_id = response.body[:initialize_session_response][:initialize_session_result]
16
+ end
17
+
18
+ def valid?
19
+ Time.now < @session_expiry_time
20
+ end
21
+
22
+ private
23
+
24
+ def xml
25
+ xml = Builder::XmlMarkup.new.tag!(*SOAP_ENVELOPE) do |xml|
26
+ xml.tag!("soapenv:Body") do |xml|
27
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:InitializeSession")
28
+ end
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,31 @@
1
+ module TranscribeMe
2
+ module API
3
+
4
+ class Submission
5
+
6
+ def initialize(session_id, recording_id, client)
7
+ @session_id, @recording_id, @client = session_id, recording_id, client
8
+ end
9
+
10
+ def submit!
11
+ response = @client.call :transcribe_recording, xml: xml
12
+ response.body[:transcribe_recording_response][:transcribe_recording_result]
13
+ end
14
+
15
+ private
16
+
17
+ def xml
18
+ xml = Builder::XmlMarkup.new.tag!(*SOAP_ENVELOPE) do |xml|
19
+ xml.tag!("soapenv:Body") do |xml|
20
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:TranscribeRecording") do |xml|
21
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:sessionID") { |xml| xml.text! @session_id }
22
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:recordingID") { |xml| xml.text! @recording_id }
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ module TranscribeMe
2
+ module API
3
+
4
+ class SubmissionWithPromocode
5
+
6
+ def initialize(session_id, recording_id, promocode, client)
7
+ @session_id, @recording_id, @promocode, @client = session_id, recording_id, promocode, client
8
+ end
9
+
10
+ def submit!
11
+ response = @client.call :transcribe_recording, xml: xml
12
+ response.body[:transcribe_recording_response][:transcribe_recording_result]
13
+ end
14
+
15
+ private
16
+
17
+ def xml
18
+ xml = Builder::XmlMarkup.new.tag!(*SOAP_ENVELOPE) do |xml|
19
+ xml.tag!("soapenv:Body") do |xml|
20
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:TranscribeRecording") do |xml|
21
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:sessionID") { |xml| xml.text! @session_id }
22
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:recordingID") { |xml| xml.text! @recording_id }
23
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:promocode") { |xml| xml.text! @promocode }
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+ module TranscribeMe
2
+ module API
3
+
4
+ class UploadUrl
5
+
6
+ def initialize(session_id, client)
7
+ @session_id, @client = session_id, client
8
+ end
9
+
10
+ def retrieve!
11
+ response = @client.call :get_upload_url, xml: xml
12
+ @list = response.body[:get_upload_url_response][:get_upload_url_result]
13
+ end
14
+
15
+ private
16
+
17
+ def xml
18
+ xml = Builder::XmlMarkup.new.tag!(*SOAP_ENVELOPE) do |xml|
19
+ xml.tag!("soapenv:Body") do |xml|
20
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:GetUploadUrl") do |xml|
21
+ xml.tag!("#{NAMESPACE_IDENTIFIER}:sessionID") { |xml| xml.text! @session_id }
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ require 'transcribeme/version'
2
+
3
+ module TranscribeMe
4
+ module API
5
+
6
+ WSDL = "http://transcribeme-api.cloudapp.net/PortalAPI.svc?wsdl=wsdl0"
7
+ ENDPOINT = "http://transcribeme-api.cloudapp.net/PortalAPI.svc"
8
+ NAMESPACE = "http://TranscribeMe.API.Web"
9
+ NAMESPACE_IDENTIFIER = :tns # any indentifier can be used
10
+
11
+ SOAP_ENVELOPE = ["soapenv:Envelope", { "xmlns:soapenv" => "http://schemas.xmlsoap.org/soap/envelope/", "xmlns:#{NAMESPACE_IDENTIFIER}" => NAMESPACE }]
12
+
13
+ end
14
+ end
15
+
16
+
17
+ require 'transcribeme/api/customer_login'
18
+ require 'transcribeme/api/session'
19
+ require 'transcribeme/api/recordings'
20
+ require 'transcribeme/api/submission'
21
+ require 'transcribeme/api/submission_with_promocode'
22
+ require 'transcribeme/api/check_transcription_ready'
23
+ require 'transcribeme/api/upload_url'
@@ -0,0 +1,3 @@
1
+ module TranscribeMe
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'transcribeme/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "transcribeme"
8
+ spec.version = TranscribeMe::VERSION
9
+ spec.authors = ["Tuttinator"]
10
+ spec.email = ["caleb@prettymint.co.nz"]
11
+ spec.description = %q{This gem is a Ruby wrapper for the TranscribeMe SOAP API, built on Savon}
12
+ spec.summary = %q{Ruby wrapper around the TranscribeMe SOAP API}
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_runtime_dependency 'savon', '~> 2.2'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "yard"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "vcr"
28
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: transcribeme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tuttinator
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: savon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.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.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: yard
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: rspec
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
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: This gem is a Ruby wrapper for the TranscribeMe SOAP API, built on Savon
98
+ email:
99
+ - caleb@prettymint.co.nz
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .rspec
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - lib/transcribeme/api/check_transcription_ready.rb
111
+ - lib/transcribeme/api/client.rb
112
+ - lib/transcribeme/api/customer_login.rb
113
+ - lib/transcribeme/api/finalize_session.rb
114
+ - lib/transcribeme/api/recordings.rb
115
+ - lib/transcribeme/api/session.rb
116
+ - lib/transcribeme/api/submission.rb
117
+ - lib/transcribeme/api/submission_with_promocode.rb
118
+ - lib/transcribeme/api/upload_url.rb
119
+ - lib/transcribeme/transcribeme.rb
120
+ - lib/transcribeme/version.rb
121
+ - spec/spec_helper.rb
122
+ - transcribeme.gemspec
123
+ homepage: ''
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.0.3
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Ruby wrapper around the TranscribeMe SOAP API
147
+ test_files:
148
+ - spec/spec_helper.rb
149
+ has_rdoc: