Class: Exchanger::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/exchanger/operation.rb

Overview

Abstract class for operations.

Exchange Web Services provides many operations that enable you to access information from the Exchanger store.

msdn.microsoft.com/en-us/library/bb409286.aspx

Defined Under Namespace

Classes: Request, Response, ResponseError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Operation

Returns a new instance of Operation.


11
12
13
# File 'lib/exchanger/operation.rb', line 11

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options


9
10
11
# File 'lib/exchanger/operation.rb', line 9

def options
  @options
end

#requestObject (readonly)

Returns the value of attribute request


9
10
11
# File 'lib/exchanger/operation.rb', line 9

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response


9
10
11
# File 'lib/exchanger/operation.rb', line 9

def response
  @response
end

Class Method Details

.run(options = {}) ⇒ Object

Shortcut for initialize and run.


16
17
18
19
# File 'lib/exchanger/operation.rb', line 16

def self.run(options = {})
  operation = self.new(options)
  operation.run
end

Instance Method Details

#runObject

Returns response


22
23
24
25
26
27
# File 'lib/exchanger/operation.rb', line 22

def run
  @request = self.class::Request.new(options)
  @response = self.class::Response.new(
    Exchanger::Client.new.request(@request.body, @request.headers)
  )
end