def endpoint_opts(endpoint, opts = {})
case
when endpoint.is_a?(SQS::Queue)
unless opts[:update_policy] == false
policy = endpoint.policy || SQS::Policy.new
policy.allow(
:principal => :any,
:actions => [:send_message],
:resources => [endpoint]
).where(:source_arn).is(arn)
endpoint.policy = policy
end
{ :protocol => 'sqs', :endpoint => endpoint.arn }
when endpoint =~ /^arn:/
raise ArgumentError, "expected a queue ARN" unless
endpoint =~ /^arn:aws(.*?):sqs:/
{ :protocol => "sqs", :endpoint => endpoint }
when endpoint.kind_of?(URI)
{ :protocol => endpoint.scheme,
:endpoint => endpoint.to_s }
when endpoint =~ /^(https?):/
{ :protocol => $1, :endpoint => endpoint }
when endpoint.include?("@")
{ :protocol => opts[:json] ? "email-json" : "email",
:endpoint => endpoint }
when endpoint.gsub(/\D/,'') =~ /\d{11,15}/
{ :protocol => "sms", :endpoint => endpoint.gsub(/\D/,'') }
else
raise ArgumentError, "could not determine protocol for '#{endpoint}'"
end
end