BetterVideo API
This commit is contained in:
parent
87bf720236
commit
21490ba03f
@ -38,14 +38,25 @@ class CampaignsController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
notice = 'Campaign was saved for later use. It is not published yet.'
|
||||
|
||||
if @campaign.update(campaign_params)
|
||||
if params[:send]
|
||||
@campaign.update({sent: true})
|
||||
client = BetterVideo.new(:url => "xxx")
|
||||
bv_response = client.addVideo(campaign: @campaign)
|
||||
if bv_response[:success]
|
||||
notice = bv_response[:message]
|
||||
@campaign.update({sent: true})
|
||||
return redirect_to campaign_path(@campaign.listingcode), notice: notice
|
||||
else
|
||||
flash.now[:alert] = bv_response[:message]
|
||||
return show_errors('edit')
|
||||
end
|
||||
end
|
||||
redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign was successfully updated.'
|
||||
else
|
||||
show_errors('edit')
|
||||
return show_errors('edit')
|
||||
end
|
||||
redirect_to campaign_path(@campaign.listingcode), notice: notice
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
12
app/models/better_video.rb
Normal file
12
app/models/better_video.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class BetterVideo
|
||||
def initialize(options={})
|
||||
@addvideo_url = options.fetch(:url, "http://servicestest.bettervideo.com/orders/MDS.OrdersWS.svc/addVideo")
|
||||
end
|
||||
|
||||
def addVideo(campaign)
|
||||
response = Hash.new
|
||||
response[:success] = true
|
||||
response[:message] = "Submitted to better video."
|
||||
response
|
||||
end
|
||||
end
|
@ -6,7 +6,7 @@ class Campaign < ActiveRecord::Base
|
||||
validates :websiteurl, presence: true
|
||||
validates :description, presence: true
|
||||
validates :productsandservices, presence: true
|
||||
after_save :send_to_better_video
|
||||
# after_save :send_to_better_video
|
||||
validate :has_at_least_one_videolisting
|
||||
after_initialize :set_defaults
|
||||
def set_defaults
|
||||
@ -23,10 +23,10 @@ class Campaign < ActiveRecord::Base
|
||||
0
|
||||
end
|
||||
|
||||
def send_to_better_video
|
||||
if self.sent_changed? && self.sent? == true
|
||||
#TODO Make API Calls
|
||||
end
|
||||
end
|
||||
# def send_to_better_video
|
||||
# if self.sent_changed? && self.sent? == true
|
||||
#
|
||||
# end
|
||||
# end
|
||||
|
||||
end
|
||||
|
@ -26,6 +26,7 @@ module Vidpush
|
||||
generate.test_framework :rspec
|
||||
generate.view_specs false
|
||||
end
|
||||
config.autoload_paths += %W(#{config.root}/lib)
|
||||
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
|
@ -32,5 +32,7 @@ Vidpush::Application.configure do
|
||||
config.action_controller.action_on_unpermitted_parameters = :raise
|
||||
|
||||
|
||||
|
||||
config.action_mailer.default_url_options = { host: 'localhost:3000' }
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user