Class Clickatell::API::Command
In: lib/clickatell/api/command.rb
Parent: Object

Represents a Clickatell HTTP gateway command in the form of a complete URL (the raw, low-level request).

Methods

Constants

API_SERVICE_HOST = 'api.clickatell.com'

Public Class methods

[Source]

# File lib/clickatell/api/command.rb, line 10
      def initialize(command_name, service = 'http', opts={})
        @command_name = command_name
        @service = service
        @options = { :secure => false }.merge(opts)
      end

Public Instance methods

Returns a URL for the given parameters (a hash).

[Source]

# File lib/clickatell/api/command.rb, line 17
      def with_params(param_hash)
        param_string = '?' + param_hash.map { |key, value| "#{::CGI.escape(key.to_s)}=#{::CGI.escape(value.to_s)}" }.sort.join('&')
        return URI.parse(File.join(api_service_uri, @command_name + param_string))
      end

Protected Instance methods

[Source]

# File lib/clickatell/api/command.rb, line 23
        def api_service_uri
          protocol = @options[:secure] ? 'https' : 'http'
          api_service_host = ((Clickatell::API.api_service_host.nil? || Clickatell::API.api_service_host.empty?) ? API_SERVICE_HOST : Clickatell::API.api_service_host)
          return "#{protocol}://#{api_service_host}/#{@service}/"
        end

[Validate]