class EngagingNetworks::Campaign
Public Instance Methods
create(name:, description:, ajax_enabled: true)
click to toggle source
# File lib/engaging_networks/campaign.rb, line 11 def create(name:, description:, ajax_enabled: true) scrape.create_campaign(name: name, description: description, ajax_enabled: ajax_enabled) end
duplicate(a)
click to toggle source
implements www.e-activist.com/ea-dataservice/import.jsp
# File lib/engaging_networks/campaign.rb, line 16 def duplicate(a) # accept either hashes or objects as input action = if a.is_a?(Hash) DuplicateCampaignAction.new(a) else a end # if the token is blank, default it to the configured private token action.token = client.connection.configuration.options[:private_token] if action.token.blank? if action.valid? response = client.request_with_options(:post, import_path, action.to_params, content_type: 'multipart/form-data') if response.body =~ /uploaded successfully/ action.job_id = /# is (\d*)/.match(response.body)[1] else raise CampaignDuplicationError.new("error while duplicating campaign: #{response.body}") end end action end
get(campaignId)
click to toggle source
# File lib/engaging_networks/campaign.rb, line 6 def get(campaignId) client.get_request(data_path, {service: 'EaCampaignInfo', campaignId: campaignId, token_type: EngagingNetworks::Request::MultiTokenAuthentication::PUBLIC}) end
search(campaign_name)
click to toggle source
# File lib/engaging_networks/campaign.rb, line 39 def search(campaign_name) response = client.get_request(data_path, {service: 'EaCampaignInfo', token_type: EngagingNetworks::Request::MultiTokenAuthentication::PUBLIC}) if response.obj.is_a? EngagingNetworks::Response::Collection response.obj.objects.find { |elem| elem.campaignName == campaign_name } elsif response.obj.is_a? EngagingNetworks::Response::Object response.obj ? response.obj.campaignName == campaign_name : nil else nil end end