Method: Happyscribe::Transcript#create_export

Defined in:
lib/happyscribe.rb

#create_export(id, format = "txt", timestamps = false, speakers = false, comments = false, highlights = false) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/happyscribe.rb', line 70

def create_export(id,format="txt",timestamps=false,speakers=false,comments=false,highlights=false)
  uri = URI.parse("#{@base}/exports")
  request = Net::HTTP::Post.new(uri)
  request.content_type = "application/json"
  request["Authorization"] = @auth
  request.body = JSON.dump({
    "export" => {
      "format" => format,
      "show_timestamps" => timestamps,
      "show_speakers" => speakers,
      "show_comments" => comments,
      "show_highlights" => highlights,
      "transcription_ids" => [
        id
      ]
    }
  })

  req_options = {
    use_ssl: uri.scheme == "https",
  }

  response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
    http.request(request)
  end
  return JSON.parse response.body
end