class AsposeImagingCloud::ImagingRequest

Base class for requests with basic operations

Public Instance Methods

to_http_info(config) click to toggle source
# File lib/aspose-imaging-cloud/models/requests/imaging_request.rb, line 31
def to_http_info(config); end

Protected Instance Methods

select_header_accept(accepts) click to toggle source

Return Accept header based on an array of accepts provided. @param [Array] accepts array for Accept @return [String] the Accept header (e.g. application/json)

# File lib/aspose-imaging-cloud/models/requests/imaging_request.rb, line 38
def select_header_accept(accepts)
  return nil if accepts.nil? || accepts.empty?

  # use JSON when present, otherwise use all of the provided
  json_accept = accepts.find { |s| json_mime?(s) }
  json_accept || accepts.join(',')
end
select_header_content_type(content_types) click to toggle source

Return Content-Type header based on an array of content types provided. @param [Array] content_types array for Content-Type @return [String] the Content-Type header (e.g. application/json)

# File lib/aspose-imaging-cloud/models/requests/imaging_request.rb, line 49
def select_header_content_type(content_types)
  # use application/json by default
  return 'application/json' if content_types.nil? || content_types.empty?

  # use JSON when present, otherwise use the first one
  json_content_type = content_types.find { |s| json_mime?(s) }
  json_content_type || content_types.first
end

Private Instance Methods

json_mime?(mime) click to toggle source

Check if the given MIME is a JSON MIME. JSON MIME examples:

application/json
application/json; charset=UTF8
APPLICATION/JSON
*/*

@param [String] mime MIME @return [Boolean] True if the MIME is application/json

# File lib/aspose-imaging-cloud/models/requests/imaging_request.rb, line 68
def json_mime?(mime)
  (mime == '*/*') || !(mime =~ %r{Application/.*json(?!p)(;.*)?}i).nil?
end
object_to_hash(obj) click to toggle source

Convert object(non-array) to hash. @param [Object] obj object to be converted into JSON string @return [String] JSON string representation of the object

# File lib/aspose-imaging-cloud/models/requests/imaging_request.rb, line 90
def object_to_hash(obj)
  if obj.respond_to?(:to_hash)
    obj.to_hash
  else
    obj
  end
end
object_to_http_body(model) click to toggle source

Convert object (array, hash, object, etc) to JSON string. @param [Object] model object to be converted into JSON string @return [String] JSON string representation of the object

# File lib/aspose-imaging-cloud/models/requests/imaging_request.rb, line 75
def object_to_http_body(model)
  return model if model.nil? || model.is_a?(String)

  local_body = nil
  local_body = if model.is_a?(Array)
                 model.map { |m| object_to_hash(m) }
               else
                 object_to_hash(model)
               end
  local_body.to_json
end