Class: MooMoo::OpenSRSXMLBuilder

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/moo_moo/middleware/open_srs_xml_builder.rb

Instance Method Summary (collapse)

Constructor Details

- (OpenSRSXMLBuilder) initialize(app, *args)

Returns a new instance of OpenSRSXMLBuilder



6
7
8
9
10
11
12
13
# File 'lib/moo_moo/middleware/open_srs_xml_builder.rb', line 6

def initialize(app, *args)
  @action = args[0]
  @object = args[1]
  @params = args[2] || {}
  @key    = args[3]
  @user   = args[4]
  super(app)
end

Instance Method Details

- (Object) call(env)



15
16
17
18
19
20
21
22
23
24
# File 'lib/moo_moo/middleware/open_srs_xml_builder.rb', line 15

def call(env)
  env[:body] = build_command.to_s
  env[:request_headers] = {
    'Content-Type' => 'text/xml',
    'X-Username' => @user,
    'X-Signature' => signature(env[:body]),
    'Content-Length' => env[:body].size.to_s
    }.merge(env[:request_headers])
  @app.call(env)
end