lib/voicebase/v2/client.rb in voicebase-client-ruby-1.0.14 vs lib/voicebase/v2/client.rb in voicebase-client-ruby-1.0.15

- old
+ new

@@ -24,11 +24,10 @@ rescue NoMethodError => ex raise VoiceBase::AuthenticationError, response.status_message end def upload_media(args = {}, headers = {}) - media_url = require_media_file_or_url(args) form_args = { 'media' => media_url, 'configuration' => { @@ -58,11 +57,11 @@ ) VoiceBase::Response.new(response, api_version) end - # I presume this method exists for parity with the V1 API however it is not used by the Orders app + # I presume this method exists for parity with the V1 API however we are not using it def get_media(args = {}, headers = {}) raise ArgumentError, "Missing argument :media_id" unless args[:media_id] url = if args[:media_id] uri + "/media/#{args[:media_id]}" elsif args[:external_id] @@ -119,11 +118,11 @@ else get_json_transcript(args, headers) end end - # is this used? + # I presume this method exists for parity with the V1 API however we are not using it def get_media_progress(args = {}, headers = {}) raise ArgumentError, "Missing argument :media_id" unless args[:media_id] VoiceBase::Response.new(self.class.get( uri + "/media/#{args[:media_id]}/progress", headers: default_headers(headers) @@ -145,13 +144,19 @@ VoiceBase::Response.new(response, api_version) end private + def blank?(value) + value.nil? || value.empty? + end + def default_headers(headers = {}) authenticate! unless token - headers = {'Authorization' => "Bearer #{token.token}", - 'User-Agent' => user_agent}.reject {|k, v| v.blank?}.merge(headers) + headers = { + 'Authorization' => "Bearer #{token.token}", + 'User-Agent' => user_agent + }.reject { |k, v| blank?(v) }.merge(headers) puts "> headers\n> #{headers}" if debug headers end def multipart_headers(headers = {})