I'm using adwords API for java but when I try to "mutate" my campaign I get this error:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
faultSubcode: faultString: [EntityNotFound.INVALID_ID #
operations[0].operand; trigger:'CampaignId: 93996448',
EntityNotFound.INVALID_ID # operations[1].operand;
trigger:'CampaignId: *', EntityNotFound.INVALID_ID #
operations[2].operand; trigger:'CampaignId: *',
EntityNotFound.INVALID_ID # operations[3].operand;
trigger:'CampaignId: *', EntityNotFound.INVALID_ID #
operations[4].operand; trigger:'CampaignId: *',
EntityNotFound.INVALID_ID # operations[5].operand;
trigger:'CampaignId: *', EntityNotFound.INVALID_ID #
operations[6].operand; trigger:'CampaignId: *',
EntityNotFound.INVALID_ID # operations[7].operand;
trigger:'CampaignId: *'
I don't understand where is the problem because I've used adwords API with PHP and there never still have been problem.
I create a linkedList of "CampaignCriterionOperation"
operations2.add(new CampaignCriterionOperation(Operator.ADD, campaignCriterionType, new CampaignCriterion(campaign.getId(), location, campaignCriterionType)));
then I mutate the campaing
CampaignCriterionOperation[] operations = new CampaignCriterionOperation[operations2.size()];
CampaignCriterionReturnValue result = campaignServiceOperation.mutate(operations2.toArray(operations));
The error indicates that the CampaignId you are using in the CampaignCriterion object's isn't valid. Double check that you are using the correct IDs.
Related
I installed react-rails since I want to use rails on my Rails 5.2.4 application.
When I installed it, I basically got the following order on my app/javascripts/ directory:
components [directory]
---.keep file
packs [directory]
---applicationCache.js
---hello_react.jsx
---server_rendering.jsx
Inside my components directory I've added a file called appointments.jsx inside app\javascripts\components\' which I link to my Appointments controller and views via<%= react_component 'Appointments' %>here is the content of theappointments.jsx` file:
const Appointments = () => {
return (
<div>
<h1>Hello Appointments</h1>
</div>
);
};
Since I already link this to my index view via <%= react_component 'Appointments' %> I expected this to display an h1 tag with the text Hello Appointments on it on my root (i already set this up on my routes.rb file) instead I got the ff errors on my console:
Hello World from Webpacker
fromRequireContextWithGlobalFallback.js:21 Error: Cannot find module './Appointments'
at webpackContextResolve (.*$:13)
at webpackContext (.*$:8)
at fromRequireContext.js:13
at Object.getConstructor (fromRequireContextWithGlobalFallback.js:15)
at Object.mountComponents (index.js:89)
at HTMLDocument../node_modules/react_ujs/react_ujs/index.js.ReactRailsUJS.handleMount (index.js:149)
at Object.e.dispatch (turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6)
at r.notifyApplicationAfterPageLoad (turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7)
at r.pageLoaded (turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7)
at turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6
(anonymous) # fromRequireContextWithGlobalFallback.js:21
mountComponents # index.js:89
./node_modules/react_ujs/react_ujs/index.js.ReactRailsUJS.handleMount # index.js:149
e.dispatch # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6
r.notifyApplicationAfterPageLoad # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7
r.pageLoaded # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7
(anonymous) # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6
fromRequireContextWithGlobalFallback.js:22 ReferenceError: Appointments is not defined
at eval (eval at ./node_modules/react_ujs/react_ujs/src/getConstructor/fromGlobal.js.module.exports (fromGlobal.js:12), <anonymous>:1:1)
at ./node_modules/react_ujs/react_ujs/src/getConstructor/fromGlobal.js.module.exports (fromGlobal.js:12)
at Object.getConstructor (fromRequireContextWithGlobalFallback.js:19)
at Object.mountComponents (index.js:89)
at HTMLDocument../node_modules/react_ujs/react_ujs/index.js.ReactRailsUJS.handleMount (index.js:149)
at Object.e.dispatch (turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6)
at r.notifyApplicationAfterPageLoad (turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7)
at r.pageLoaded (turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7)
at turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6
(anonymous) # fromRequireContextWithGlobalFallback.js:22
mountComponents # index.js:89
./node_modules/react_ujs/react_ujs/index.js.ReactRailsUJS.handleMount # index.js:149
e.dispatch # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6
r.notifyApplicationAfterPageLoad # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7
r.pageLoaded # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7
(anonymous) # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6
index.js:100 [react-rails] Cannot find component: 'Appointments' for element <div data-react-class="Appointments" data-react-props="{}" data-react-cache-id="Appointments-0"></div>
index.js:103 Uncaught Error: Cannot find component: 'Appointments'. Make sure your component is available to render.
at Object.mountComponents (index.js:103)
at HTMLDocument../node_modules/react_ujs/react_ujs/index.js.ReactRailsUJS.handleMount (index.js:149)
at Object.e.dispatch (turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6)
at r.notifyApplicationAfterPageLoad (turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7)
at r.pageLoaded (turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7)
at turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6
mountComponents # index.js:103
./node_modules/react_ujs/react_ujs/index.js.ReactRailsUJS.handleMount # index.js:149
e.dispatch # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6
r.notifyApplicationAfterPageLoad # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7
r.pageLoaded # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:7
(anonymous) # turbolinks.self-569ee74eaa15c1e2019317ff770b8769b1ec033a0f572a485f64c82ddc8f989e.js?body=1:6
For the record here's the content of my application.js file under app/packs/ directory:
console.log('Hello World from Webpacker')
// Support component names relative to this directory:
var componentRequireContext = require.context("components", true);
var ReactRailsUJS = require("react_ujs");
ReactRailsUJS.useContext(componentRequireContext);
Any idea what am I doing wrong here? Why does the text not showing up on view?
Did you export your component? I.e. export default Appointments;.
Also it could be a case sensitivity issue, i.e. you are calling it with upper case react_component 'Appointments' and have appointments.jsx.
I have integrated Ahoy into our platform and it works great for tracking events etc. I am now trying to extend the functionality with enabling geocoding. The issue I am running into is as soon as I uncomment the
after_validation :geocode
line, visits stop recording in the database.
What am I doing wrong here?
visit.rb
class Ahoy::Visit < ActiveRecord::Base
self.table_name = "ahoy_visits"
# ahoy_visit
geocoded_by :ip
# after_validation :geocode
has_many :events, class_name: "Ahoy::Event"
belongs_to :user
end
ahoy.rb (note the short visit duration for testing):
class Ahoy::Store < Ahoy::DatabaseStore
end
# set to true for JavaScript tracking
Ahoy.api = true
# better user agent parsing
Ahoy.user_agent_parser = :device_detector
Ahoy.geocode = true
# Ahoy.server_side_visits = :when_needed
Ahoy.visit_duration = 10.seconds
# Ahoy.visit_duration = Rails.application.secrets.visit_duration
Ahoy.quiet = false
geocoder.rb
Geocoder.configure(
# Geocoding options
timeout: 15, # geocoding service timeout (secs)
lookup: :google, # name of geocoding service (symbol)
:ip_lookup => :maxmind, # IP address geocoding service (see below for supported options):
language: :en, # ISO-639 language code
use_https: true, # use HTTPS for lookup requests? (if supported)
# http_proxy: nil, # HTTP proxy server (user:pass#host:port)
# https_proxy: nil, # HTTPS proxy server (user:pass#host:port)
api_key: Rails.application.secrets.google_server_api_key, # API key for geocoding service
# cache: nil, # cache object (must respond to #[], #[]=, and #keys)
# cache_prefix: 'geocoder:', # prefix (string) to use for all cache keys
# Exceptions that should not be rescued by default
# (if you want to implement custom error handling);
# supports SocketError and Timeout::Error
# always_raise: [],
# Calculation options
units: :km, # :km for kilometers or :mi for miles
# distances: :linear # :spherical or :linear
)
To re-iterate, when I comment out the geocoding line visits are recorded properly and ahoy works as expected.
Thanks.
EDIT
I am certain there is an exception being thrown but it is not bubbling up in the logs and I have debug logging enabled. Ahoy just states that "[ahoy] Event excluded since visit not created:" yet on the UI we can see that a visit is being started via these log statements from ahoy:
Visit started
ahoy.self-01ef77de70801670c1f7f2f12fea979d59ba70488a77db75270b57ec5b1a2f8e.js?body=1:175
{visit_token: "4c7e0bcb-7afb-48cd-91ed-1bdf0d614767", visitor_token:
"374bf981-d843-45c3-953d-0f0b8fd5a6a7", platform: "Web", landing_page:
"http://localhost:3000/", screen_width: 1680, …}
ahoy.self-01ef77de70801670c1f7f2f12fea979d59ba70488a77db75270b57ec5b1a2f8e.js?body=1:175
{name: "$click", properties: {…}, time: 1533656941.084, id:
"c967b67f-96f7-4f18-a9a8-df3735fdc1c2", js: true}
I'm trying to call the AWS API gateway resource /apikeys to get a list of my api keys. This isn't a part of the sdk yet so I'm trying to do the web service call in Ruby and I'm getting a 400. What I've read indicates I'm not setting up the headers and body correctly. Any help would be appreciated. I'm using the aws4 gem for signing the headers and the faraday gem to make the GET call. Here's the code & output.
#! /home/sburke/.rvm/rubies/ruby-2.2.3/bin/ruby
require 'aws4'
require 'pp'
require 'faraday'
require 'json'
require 'time'
# create a signer
signer = AWS4::Signer.new(
access_key: ENV['AWS_ACCESS_KEY_ID'],
secret_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: "us-east-1"
)
# build request
headers = {
"Date" => Time.now.httpdate,
"Content-Type" => "application/x-amz-json-1.0",
"host" => "https://apigateway.us-east-1.amazonaws.com"
}
body="{}"
# sign headers
uri = URI("https://apigateway.us-east-1.amazonaws.com/apikeys")
headers_signed = signer.sign("GET", uri, headers, body)
pp headers_signed
conn = Faraday.new(:url => "https://apigateway.us-east-1.amazonaws.com")
resp = conn.get do |req|
req.url '/apikeys'
req.headers = headers_signed
end
pp resp.status
Here's the output of the code.
sburke#sburke-laptop:~/sandbox/aws_rest_ruby$ ./test.rb
Digest::Digest is deprecated; use Digest
Digest::Digest is deprecated; use Digest
Digest::Digest is deprecated; use Digest
Digest::Digest is deprecated; use Digest
Digest::Digest is deprecated; use Digest
{"Date"=>"Sun, 11 Oct 2015 02:14:13 GMT",
"Content-Type"=>"application/x-amz-json-1.0",
"host"=>"https://apigateway.us-east-1.amazonaws.com",
"Authorization"=>
"AWS4-HMAC-SHA256 Credential=AKIAI2P7SWBU6FBHPMOA/20151011/us-east-1/apigateway/aws4_request, SignedHeaders=content-type;date;host, Signature=85536b2084c11492d7b1af612b4f0a83752bb921e8534155dfbebeaefde6a73d"}
400
Here's the output of the headers and the body is empty. I don't get any more info from the faraday response object aside from the 400 and headers.
pp resp.headers
pp resp.body
{"transfer-encoding"=>"chunked",
"date"=>"Wed, 14 Oct 2015 17:27:25 GMT",
"connection"=>"close"}
""
I want to make a simple change to the Guard Cucumber Notification Formatter to pass a priority, a bit like Guard Rspec does, so that growl styling can be improved. Small thing really.
I have tried this as a monkey patch in an initializer file but it won't work. I've tried all kinds of things but for whatever reason I cannot get it to recognize my monkey-patch when running the tests. No change I make in the patch seems to make a difference. I've tried all kinds of variants on the namespacing in case I'm making an error there - and I think that's most likely. Here's what I'm trying to apply:
initializers/guard_cucumber_patch.rb
require 'guard'
require 'guard/notifier'
require 'cucumber/formatter/console'
require 'cucumber/formatter/io'
module Guard
class Cucumber
class NotificationFormatter
def step_name(keyword, step_match, status, source_indent, background, file_colon_line)
if [:failed, :pending, :undefined].index(status)
#rerun = true
step_name = step_match.format_args(lambda { |param| "*#{ param }*" })
::Guard::Notifier.notify(step_name,
:title => #feature_name,
:image => icon_for(status),
:priority => priority(icon_for(status)))
end
end
# Just stolen from the guard/rspec/formatter code
def priority(image)
{ :failed => 2,
:pending => -1,
:success => -2
}[image]
end
end
end
end
The original guard/cucumber/notification_formatter.rb file is as follows:
require 'guard'
require 'guard/notifier'
require 'cucumber/formatter/console'
require 'cucumber/formatter/io'
module Guard
class Cucumber
# The notification formatter is a Cucumber formatter that Guard::Cucumber
# passes to the Cucumber binary. It writes the `rerun.txt` file with the failed features
# an creates system notifications.
#
# #see https://github.com/cucumber/cucumber/wiki/Custom-Formatters
#
class NotificationFormatter
include ::Cucumber::Formatter::Console
attr_reader :step_mother
# Initialize the formatter.
#
# #param [Cucumber::Runtime] step_mother the step mother
# #param [String, IO] path_or_io the path or IO to the feature file
# #param [Hash] options the options
#
def initialize(step_mother, path_or_io, options)
#options = options
#file_names = []
#step_mother = step_mother
end
# Notification after all features have completed.
#
# #param [Array[Cucumber::Ast::Feature]] features the ran features
#
def after_features(features)
notify_summary
write_rerun_features if !#file_names.empty?
end
# Before a feature gets run.
#
# #param [Cucumber::Ast::FeatureElement] feature_element
#
def before_feature_element(feature_element)
#rerun = false
#feature_name = feature_element.name
end
# After a feature gets run.
#
# #param [Cucumber::Ast::FeatureElement] feature_element
#
def after_feature_element(feature_element)
if #rerun
#file_names << feature_element.file_colon_line
#rerun = false
end
end
# Gets called when a step is done.
#
# #param [String] keyword the keyword
# #param [Cucumber::StepMatch] step_match the step match
# #param [Symbol] status the status of the step
# #param [Integer] source_indent the source indentation
# #param [Cucumber::Ast::Background] background the feature background
# #param [String] file name and line number describing where the step is used
#
def step_name(keyword, step_match, status, source_indent, background, file_colon_line)
if [:failed, :pending, :undefined].index(status)
#rerun = true
step_name = step_match.format_args(lambda { |param| "*#{ param }*" })
::Guard::Notifier.notify step_name, :title => #feature_name, :image => icon_for(status)
end
end
private
# Notify the user with a system notification about the
# result of the feature tests.
#
def notify_summary
icon, messages = nil, []
[:failed, :skipped, :undefined, :pending, :passed].reverse.each do |status|
if step_mother.steps(status).any?
step_icon = icon_for(status)
icon = step_icon if step_icon
messages << dump_count(step_mother.steps(status).length, 'step', status.to_s)
end
end
::Guard::Notifier.notify messages.reverse.join(', '), :title => 'Cucumber Results', :image => icon
end
# Writes the `rerun.txt` file containing all failed features.
#
def write_rerun_features
File.open('rerun.txt', 'w') do |f|
f.puts #file_names.join(' ')
end
end
# Gives the icon name to use for the status.
#
# #param [Symbol] status the cucumber status
# #return [Symbol] the Guard notification symbol
#
def icon_for(status)
case status
when :passed
:success
when :pending, :undefined, :skipped
:pending
when :failed
:failed
else
nil
end
end
end
end
end
EDIT: I am using jruby-head if that makes a difference to monkey business.
Guard::Cucumber makes a system call to start Cucumber in a subshell and your monkey patch is not loaded in that environment. You need to tell Cucumber to require your patch on start like the notification formatter is required.
I'm not actively developing Guard::Cucumber at the moment because I have no project with Cucumber, but I still do maintain it and I'll happily merge that improvement if you make a pull request. I think your improvement would be useful for other users as well.
try to put this file in spec/support dir (create if not exists)
this dir contents are usually included in spec/spec_helper.rb just before running any tests
LocationLabs and Loc-Aid are location aggregation services that expose REST APIs. They currently offer Java, .NET and PHP SDKs. The API is not complex but, still, as a learning tool, it would be nice to have a Ruby tutorial or example to play with, extent, etc.
After further analysis, I built my application on Loc-Aid's infrastructure. Since there weren't many Ruby examples I could find, I'm sharing a snippet from my app.
# Get SAVON soap client locaid location services
# Parameters:
# - none
# Returns: SOAP client for locaid location services
def get_location_client
Savon::Client.new do
wsdl.document = LOCAID_CONFIG['use_local_wsdl'] ?
File.expand_path(LOCAID_CONFIG['get_location_wsdl'].to_s, ::Rails.root.to_s) :
LOCAID_CONFIG['get_location_wsdl'].to_s
wsdl.endpoint = LOCAID_CONFIG['get_location_endpoint'].to_s
end
end
# Strip the return result from locaid response as a hash
# Parameters:
# - raw_response: Raw response XMLfrom locaid services
# - response_name: Response name which wrap the response return result in locaid response XML
# Returns: Hash corresponding to the key "return" in locaid soap response hash.
# Sample Raw Response:
# {:subscribe_phone_response=>{:return=>{:error=>{:error_code=>"00001", :error_message=>"Invalid or inactive user"}, :transaction_id=>"14028251"},
# :"#xmlns:ns2"=>"http://webservice.portico.locaid.net/"}}
def strip_locaid_return(raw_response, response_name)
unless raw_response.to_hash.has_key?(response_name)
raise TropoExceptions::ExternalError
end
raw_response[response_name][:return]
end
# Get location from locaid by the caller id
# Parameters:
# - #caller_id: Caller id get from scope value
# Returns: none
def location_from_locaid
client = get_location_client
client.http.read_timeout = LOCAID_CONFIG['get_location_timeout'].to_i
# Call locaider service to get location
response = client.request :wsdl, :get_locations_x do |soap|
soap.body = {
:login => LOCAID_CONFIG['login'],
:password => LOCAID_CONFIG['password'],
:class_id => LOCAID_CONFIG['class_id'],
:msisdn_list => ["1#{#caller_id}"],
:coor_type => "DECIMAL",
:location_method => LOCAID_CONFIG['location_method'],
:sync_type => "SYN",
:overage => "1"
}
end
result_hash = strip_locaid_return(response, :get_locations_x_response)
if result_hash.has_key?(:error)
raise TropoExceptions::ExternalError
end
yield result_hash[:location_response].is_a?(Array) ?
result_hash[:location_response][0] :
result_hash[:location_response]
rescue Savon::Error, Timeout::Error => e
logger.error e
yield nil
end
end