class DTK::Client::Operation

Abstract class that holds classes and methods for xecuting commands by make calls to server and performing client side operations

Constants

TYPES

Private Class Methods

raise_error_if_notok_response(&block) click to toggle source

This is used so can fail on not ok rest responses without needing to do explicit response.ok? checks in many places

# File lib/client/operation.rb, line 57
def self.raise_error_if_notok_response(&block)
  response = block.call
  if response.ok?
    response
  else
    # if errors = response['errors']
      # error_message = errors.first['message']
      # raise Error::Server.new(error_message)
    # else
      raise Error::ServerNotOkResponse.new(response)
    # end
  end
end
rest_get(route, query_string_hash = {}) click to toggle source
# File lib/client/operation.rb, line 40
def self.rest_get(route, query_string_hash = {})
  raise_error_if_notok_response do
    Session.rest_get(route, query_string_hash)
  end
end
rest_post(route, post_body = {}) click to toggle source

delegate rest calls to Session

# File lib/client/operation.rb, line 31
def self.rest_post(route, post_body = {})
  raise_error_if_notok_response do
    Session.rest_post(route, post_body)
  end
end
wrap_operation(args = Args.new, &block) click to toggle source
# File lib/client/operation.rb, line 49
def self.wrap_operation(args = Args.new, &block)
  Response.wrap_as_response do
    block.call(Args.convert(args))
  end
end

Private Instance Methods

rest_get(route, query_string_hash = {}) click to toggle source
# File lib/client/operation.rb, line 45
def rest_get(route, query_string_hash = {})
  self.class.rest_get(route, query_string_hash)
end
rest_post(route, post_body = {}) click to toggle source
# File lib/client/operation.rb, line 36
def rest_post(route, post_body = {})
  self.class.rest_post(route, post_body)
end