Sha256: 054b6c39ece3eefe3984a0d9d7eae9cdcc07f59167585378c95b2b38bd9744b0

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module MooMoo
  class Command
    # Constructor
    #
    # ==== Required
    #  * <tt>:action</tt> - action of the command
    #  * <tt>:object</tt> - object the command operates on
    #  * <tt>:params</tt> - additional parameters for the command
    #
    # ==== Optional
    #  * <tt>:cookie</tt> - a cookie for the domain if the command requires it
    def initialize(action, object, params = {}, cookie = nil)
      @action = action
      @object = object
      @params = params
      @cookie = cookie
    end

    # Runs the command against OpenSRS server
    #
    # ==== Required
    #  * <tt>:host</tt> - host of the OpenSRS server
    #  * <tt>:key</tt> - private key for the account
    #  * <tt>:user</tt> - username for the account
    #  * <tt>:port</tt> - port to connect to
    def run(host, key, user, port)
      @returned_parameters = Faraday.new(:url => "https://#{host}:#{port}", :ssl => {:verify => true}) do |c|
        c.request :open_srs_xml_builder, @action, @object, @cookie, @params, key, user
        c.response :parse_open_srs
        c.response :open_srs_errors
        c.adapter :net_http
      end.post.body
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moo_moo-0.2.0 lib/moo_moo/command.rb