better video api implemented

This commit is contained in:
Tyrel Souza 2014-04-30 14:41:57 -04:00
parent 6e06426db7
commit 1c6c7e02c4
3 changed files with 7 additions and 9 deletions

View File

@ -9,7 +9,7 @@ class BetterVideo
def addVideo(campaign) def addVideo(campaign)
uri = URI.parse(@addvideo_url) uri = URI.parse(@addvideo_url)
header = {}#'Content-Type' => 'text/json'} header = {}
http = Net::HTTP.new(uri.host, uri.port) http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, header) request = Net::HTTP::Post.new(uri.request_uri, header)
@ -19,14 +19,15 @@ class BetterVideo
resp = JSON.parse(response.body) resp = JSON.parse(response.body)
puts resp puts resp
if resp["success"] if resp["errorcode"] == 0
resp[:success] = true resp[:success] = true
resp[:message] = "Successfully submitted to BetterVideo, Please wait." resp[:message] = "Successfully submitted to BetterVideo, Please wait."
else else
resp[:message] = resp["errormessage"] resp[:message] = "Error Code #{resp["errorcode"]}: #{resp["errormessage"]}"
if resp["errorcode"] == 1
resp[:message] += "Please Contact Dev"
end
end end
# "{\"errorcode\":1,\"errormessage\":\"There was an error parsing the supplied JSON.\",\"listingcode\":null,\"success\":false,\"videocode\":null}"
resp resp
end end

View File

@ -8,7 +8,7 @@
<div class="error_explanation"> <div class="error_explanation">
<ul> <ul>
<% @campaign.errors.full_messages.each do |msg| %> <% @campaign.errors.full_messages.each do |msg| %>
<li class="alert alert-danger"><%= msg %></li> <li class="alert alert-danger"><%= msg.html_safe %></li>
<% end %> <% end %>
</ul> </ul>
</div> </div>

View File

@ -20,8 +20,5 @@
</div> </div>
<% end %> <% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %> <%= link_to "Back", :back %>