Module: Soaspec::RestExchangeFactory

Included in:
RestHandler
Defined in:
lib/soaspec/exchange_handlers/rest_exchanger_factory.rb

Overview

Convenience methods for once off usage of a REST request

Instance Method Summary collapse

Instance Method Details

#delete(params = {}) ⇒ Exchange

Make REST Exchange with ‘delete’ method within this Handler context. If merely a string is passed it will be used as the URL appended to base_url (same as suburl). Otherwise a Hash is expected

Options Hash (params):

  • :name (String)

    Name to appear in traffic logs

  • :suburl (String)

    URL appended to base_url of class

  • :q (Hash)

    Query for REST

  • :params (Hash)

    Extra parameters (E.g. headers)



71
72
73
# File 'lib/soaspec/exchange_handlers/rest_exchanger_factory.rb', line 71

def delete(params = {})
  perform_exchange_with(:delete, params)
end

#get(params = {}) ⇒ Exchange

Make REST Exchange with ‘get’ method within this Handler context. If merely a string is passed it will be used as the URL appended to base_url (same as suburl). Otherwise a Hash is expected

Options Hash (params):

  • :name (String)

    Name to appear in traffic logs

  • :suburl (String)

    URL appended to base_url of class

  • :params (Hash)

    Extra parameters (E.g. headers)

  • :q (Hash)

    Query for REST



59
60
61
# File 'lib/soaspec/exchange_handlers/rest_exchanger_factory.rb', line 59

def get(params = {})
  perform_exchange_with(:get, params)
end

#patch(params) ⇒ Exchange

Make REST Exchange with ‘patch’ method within this Handler context Following are for the body of the request

Options Hash (params):

  • :name (String)

    Name to appear in traffic logs

  • :params (Hash)

    Extra parameters (E.g. headers)

  • suburl (String)

    URL appended to base_url of class

  • :q (Hash)

    Query for REST

  • :body (Hash)

    Hash to be converted to JSON in request body

  • :payload (String)

    String to be passed directly in request body

  • :template_name (String)

    Path to file to be read via ERB and passed in request body



32
33
34
# File 'lib/soaspec/exchange_handlers/rest_exchanger_factory.rb', line 32

def patch(params)
  perform_exchange_with(:patch, params)
end

#post(params = {}) ⇒ Exchange

Make REST Exchange with ‘post’ method within this Handler context Following are for the body of the request

Options Hash (params):

  • :name (String)

    Name to appear in traffic logs

  • :params (Hash)

    Extra parameters (E.g. headers)

  • :suburl (String)

    URL appended to base_url of class

  • :q (Hash)

    Query for REST

  • :body (Hash)

    Hash to be converted to JSON in request body

  • :payload (String)

    String to be passed directly in request body

  • :template_name (String)

    Path to file to be read via ERB and passed in request body



17
18
19
# File 'lib/soaspec/exchange_handlers/rest_exchanger_factory.rb', line 17

def post(params = {})
  perform_exchange_with(:post, params)
end

#put(params = {}) ⇒ Exchange

Make REST Exchange with ‘put’ method within this Handler context Following are for the body of the request

Options Hash (params):

  • :name (String)

    Name to appear in traffic logs

  • :params (Hash)

    Extra parameters (E.g. headers)

  • :suburl (String)

    URL appended to base_url of class

  • :q (Hash)

    Query for REST

  • :body (Hash)

    Hash to be converted to JSON in request body

  • :payload (String)

    String to be passed directly in request body

  • :template_name (String)

    Path to file to be read via ERB and passed in request body



47
48
49
# File 'lib/soaspec/exchange_handlers/rest_exchanger_factory.rb', line 47

def put(params = {})
  perform_exchange_with(:put, params)
end