Sha256: 95128742009062efbb849dd661355d0190d9efbc7085cdfe63f4f53b6ce95305
Contents?: true
Size: 900 Bytes
Versions: 1
Compression:
Stored size: 900 Bytes
Contents
module Clickatell class API # Represents a Clickatell HTTP gateway command in the form # of a complete URL (the raw, low-level request). class Command API_SERVICE_HOST = 'api.clickatell.com' def initialize(command_name, opts={}) @command_name = command_name @options = { :secure => false }.merge(opts) end # Returns a URL for the given parameters (a hash). def with_params(param_hash) param_string = '?' + param_hash.map { |key, value| "#{key}=#{value}" }.sort.join('&') return URI.parse(File.join(api_service_uri, @command_name + URI.encode(param_string))) end protected def api_service_uri protocol = @options[:secure] ? 'https' : 'http' port = @options[:secure] ? 443 : 80 return "#{protocol}://#{API_SERVICE_HOST}:#{port}/http/" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clickatell-0.4.1 | lib/clickatell/api/command.rb |