Sha256: b011777a12d14d52601fd131f5c119e62c02e07ac35f982457d3a1e4b345d91b

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

Contents

module Bixby

# Wraps a JSON Request
#
# @attr [String] operation  Name of operation
# @attr [Array] params  Array of paramters; must be valid JSON types
class JsonRequest

  include Jsonify
  include HttpClient

  attr_accessor :operation, :params

  # Create a new JsonRequest
  #
  # @param [String] operation  Name of operation
  # @param [Array] params  Array of parameters; must ve valid JSON types
  def initialize(operation, params)
    @operation = operation
    @params = params
  end

  # Convert object to String, useful for debugging
  #
  # @return [String]
  def to_s # :nocov:
    s = []
    s << "JsonRequest:#{self.object_id}"
    s << "  operation:  #{self.operation}"
    s << "  params:     " + MultiJson.dump(self.params)
    s.join("\n")
  end # :nocov:

  def to_wire
    MultiJson.dump(self)
  end

  # Test if this object is equal to some other object
  #
  # @param [JsonRequest] other
  #
  # @return [Boolean]
  def ==(other)
    operation == other.operation && params == other.params
  end

end # JsonRequest
end # Bixby

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
bixby-common-0.6.3 lib/bixby-common/api/json_request.rb
bixby-common-0.6.2 lib/bixby-common/api/json_request.rb
bixby-common-0.6.1 lib/bixby-common/api/json_request.rb
bixby-common-0.6.0 lib/bixby-common/api/json_request.rb
bixby-common-0.5.0 lib/bixby-common/api/json_request.rb
bixby-common-0.4.13 lib/bixby-common/api/json_request.rb
bixby-common-0.4.12 lib/bixby-common/api/json_request.rb
bixby-common-0.4.11 lib/bixby-common/api/json_request.rb
bixby-common-0.4.10 lib/bixby-common/api/json_request.rb
bixby-common-0.4.9 lib/bixby-common/api/json_request.rb
bixby-common-0.4.8 lib/bixby-common/api/json_request.rb
bixby-common-0.4.7 lib/bixby-common/api/json_request.rb
bixby-common-0.4.6 lib/bixby-common/api/json_request.rb
bixby-common-0.4.5 lib/bixby-common/api/json_request.rb