BetterVideo API
This commit is contained in:
parent
87bf720236
commit
21490ba03f
@ -38,15 +38,26 @@ class CampaignsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
notice = 'Campaign was saved for later use. It is not published yet.'
|
||||||
|
|
||||||
if @campaign.update(campaign_params)
|
if @campaign.update(campaign_params)
|
||||||
if params[:send]
|
if params[:send]
|
||||||
|
client = BetterVideo.new(:url => "xxx")
|
||||||
|
bv_response = client.addVideo(campaign: @campaign)
|
||||||
|
if bv_response[:success]
|
||||||
|
notice = bv_response[:message]
|
||||||
@campaign.update({sent: true})
|
@campaign.update({sent: true})
|
||||||
end
|
return redirect_to campaign_path(@campaign.listingcode), notice: notice
|
||||||
redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign was successfully updated.'
|
|
||||||
else
|
else
|
||||||
show_errors('edit')
|
flash.now[:alert] = bv_response[:message]
|
||||||
|
return show_errors('edit')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
return show_errors('edit')
|
||||||
|
end
|
||||||
|
redirect_to campaign_path(@campaign.listingcode), notice: notice
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@campaign.destroy
|
@campaign.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 :websiteurl, presence: true
|
||||||
validates :description, presence: true
|
validates :description, presence: true
|
||||||
validates :productsandservices, presence: true
|
validates :productsandservices, presence: true
|
||||||
after_save :send_to_better_video
|
# after_save :send_to_better_video
|
||||||
validate :has_at_least_one_videolisting
|
validate :has_at_least_one_videolisting
|
||||||
after_initialize :set_defaults
|
after_initialize :set_defaults
|
||||||
def set_defaults
|
def set_defaults
|
||||||
@ -23,10 +23,10 @@ class Campaign < ActiveRecord::Base
|
|||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_to_better_video
|
# def send_to_better_video
|
||||||
if self.sent_changed? && self.sent? == true
|
# if self.sent_changed? && self.sent? == true
|
||||||
#TODO Make API Calls
|
#
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -26,6 +26,7 @@ module Vidpush
|
|||||||
generate.test_framework :rspec
|
generate.test_framework :rspec
|
||||||
generate.view_specs false
|
generate.view_specs false
|
||||||
end
|
end
|
||||||
|
config.autoload_paths += %W(#{config.root}/lib)
|
||||||
|
|
||||||
# Settings in config/environments/* take precedence over those specified here.
|
# Settings in config/environments/* take precedence over those specified here.
|
||||||
# Application configuration should go into files in config/initializers
|
# 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_controller.action_on_unpermitted_parameters = :raise
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
config.action_mailer.default_url_options = { host: 'localhost:3000' }
|
config.action_mailer.default_url_options = { host: 'localhost:3000' }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user