Sha256: 708bf5679be4534c12acd68e2b16d906be2258b75df371da971d155400bc469d

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

# === Vendor API Docs
# http://www.example.com/handy_docs
class <%= "#{appname.camelcase}::#{request_class}" %> < Consumer::Request
  
  ### Note: Everything except to_xml is optional (though handy) ###
  
  response_class "<%= response_class %>"
  yaml_defaults "<%= appname %>.yml", "<%= request_base.underscore %>"
  
  # If root is found in a response, code + message will be raised
  error_paths({
    :root    => "//Error",
    :code    => "//ErrorCode",
    :message => "//ErrorDescription"
  })
  
  # Instance variables that must be set before xml sendoff
  def required
    return [
      # :required_attrs_array
    ]
  end
  
  # Lowest priority; overwritten by YAML, then params
  def defaults
    return {
      # :sensible_default => "Value"
    }
  end
  
  def url
    return "www.example.com/testing" if $TESTING
    
    "www.example.com"
  end

  def headers
    {"SoapAction" => ""}
  end
  
  # Called before required vars are checked, too
  def before_to_xml; end
  
  # All this has to do is return xml, and we have a Builder instance to help.
  # Also, defaults, YAML, and the params are accessed via instance variables.
  def to_xml
    b.instruct!
    
    # docs at http://builder.rubyforge.org/classes/Builder/XmlMarkup.html
    # example:
    b.<%= request_class %> {
      b.Hello "World"
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
woahdae-consumer-0.8.1 consumer_generators/request/templates/lib/request.rb
woahdae-consumer-0.8.2 consumer_generators/request/templates/lib/request.rb