Sha256: 749b054e62412d6ad86f9d967bde1419426cec2a9be51001c42bd367598313c7

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

module Moceansdk
  module Modules
    module Command

      class Command < Moceansdk::Modules::AbstractClient
        def initialize(obj_auth, transmitter)
          super(obj_auth, transmitter)
          @required_fields = ['mocean-api-key', 'mocean-api-secret','mocean-command']
        end

        def event_url=(param)
          @params['mocean-event-url'] = param
        end

        def mocean_command=(param)
          if param.is_a? McBuilder
            @params['mocean-command'] = JSON.generate(param.build)
          elsif param.is_a? McObject::AbstractMc
            @params['mocean-command'] = JSON.generate([param.get_request_data])
          elsif param.is_a? Array
            @params['mocean-command'] = JSON.generate(param)
          else
            @params['mocean-command'] = param
          end
        end


        def execute(params = {})
          sym_params = Moceansdk::Utils.convert_to_symbol_hash(params)

          unless sym_params[:'mocean-command'].nil?
            mc = sym_params[:'mocean-command']
            sym_params.delete(:'mocean-command')
            self.mocean_command = mc
          end

          create(sym_params)
          create_final_params
          required_field_set?

          # @sym_params[:'mocean-command'] = JSON.generate(@sym_params[:'mocean-command'].build)
          @transmitter.post('/send-message', @params)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moceansdk-1.1.1 lib/moceansdk/modules/command/command.rb