Class: MultiInfo::API
- Inherits:
-
Object
- Object
- MultiInfo::API
- Defined in:
- lib/multiinfo/api.rb,
lib/multiinfo/api/error.rb,
lib/multiinfo/api/command.rb,
lib/multiinfo/api/executor.rb,
lib/multiinfo/api/response.rb
Overview
This module provides the core implementation of the Clickatell HTTP service.
Defined Under Namespace
Classes: Command, Error, Executor, FakeHttpResponse, Response
Constant Summary collapse
- DEFAULT_CONFIG_PATH =
Defaults for config file location
File.join(ENV['HOME'], 'multiinfo')
- DEFAULT_CONFIG_FILE =
'multiinfo.yml'
- API_SERVICE_HOST =
'https://www.multiinfo.plus.pl/'
- API_NAME =
'smsapi4'
- API_SCRIPT_TYPE =
'aspx'
- DEFAULT_CERT_FILE =
'multiinfo.crt'
- DEFAULT_KEY_FILE =
'multiinfo.pem'
Class Attribute Summary collapse
-
.debug_mode ⇒ Object
Set to true to enable debugging (off by default).
-
.test_mode ⇒ Object
Set to true to test message sending; this will not actually send messages but will collect sent messages in a testable collection.
Instance Attribute Summary collapse
-
#auth_options ⇒ Object
Returns the value of attribute auth_options.
Class Method Summary collapse
-
.load_auth_options(config_location = nil) ⇒ Object
Load credentials from config file.
Instance Method Summary collapse
-
#cancel_message(sms_id) ⇒ Object
Returns the status of a message.
- #get_message(opts = {}) ⇒ Object
-
#initialize(auth_options = nil) ⇒ API
constructor
Creates a new API instance using the specified
auth_options
. -
#message_info(sms_id) ⇒ Object
Returns the status of a message.
-
#package_info(package_id) ⇒ Object
Returns the status of a package of messages.
-
#send_message(recipient, message_text, opts = {}) ⇒ Object
Sends a message
message_text
torecipient
. -
#send_package ⇒ Object
Sends a package of messages.
-
#sms_requests ⇒ Object
:nodoc:.
Constructor Details
#initialize(auth_options = nil) ⇒ API
Creates a new API instance using the specified auth_options
. auth_options
is a hash containing :username, :password, :service_id and optionally :client_cert, :client_key
36 37 38 |
# File 'lib/multiinfo/api.rb', line 36 def initialize( = nil) @auth_options = || self.class. end |
Class Attribute Details
.debug_mode ⇒ Object
Set to true to enable debugging (off by default)
13 14 15 |
# File 'lib/multiinfo/api.rb', line 13 def debug_mode @debug_mode end |
.test_mode ⇒ Object
Set to true to test message sending; this will not actually send messages but will collect sent messages in a testable collection. (off by default)
18 19 20 |
# File 'lib/multiinfo/api.rb', line 18 def test_mode @test_mode end |
Instance Attribute Details
#auth_options ⇒ Object
Returns the value of attribute auth_options.
9 10 11 |
# File 'lib/multiinfo/api.rb', line 9 def @auth_options end |
Class Method Details
.load_auth_options(config_location = nil) ⇒ Object
Load credentials from config file
21 22 23 24 25 26 |
# File 'lib/multiinfo/api.rb', line 21 def (config_location = nil) config_file = File.open(config_location || File.join(DEFAULT_CONFIG_PATH, DEFAULT_CONFIG_FILE)) = YAML.load(config_file).symbolize_keys raise MultiInfo::API::Error.new(-9999, 'Missing config params') if .only(:login, :password, :service_id).size != 3 end |
Instance Method Details
#cancel_message(sms_id) ⇒ Object
Returns the status of a message. Use sms ID returned from original send_message call.
72 73 74 75 |
# File 'lib/multiinfo/api.rb', line 72 def (sms_id) response = execute_command('cancelsms', :sms_id => sms_id) parse_response(response) end |
#get_message(opts = {}) ⇒ Object
77 78 79 80 81 |
# File 'lib/multiinfo/api.rb', line 77 def (opts={}) = opts.only(:timeout).merge(service_id) response = execute_command('getsms', ) parse_response(response) end |
#message_info(sms_id) ⇒ Object
Returns the status of a message. Use sms ID returned from original send_message call.
58 59 60 61 |
# File 'lib/multiinfo/api.rb', line 58 def (sms_id) response = execute_command('infosms', :sms_id => sms_id) parse_response(response) end |
#package_info(package_id) ⇒ Object
Returns the status of a package of messages. Use package id returned from original send_package call.
65 66 67 68 |
# File 'lib/multiinfo/api.rb', line 65 def package_info(package_id) response = execute_command('packageinfo', :package_id => package_id) parse_response(response) end |
#send_message(recipient, message_text, opts = {}) ⇒ Object
Sends a message message_text
to recipient
. Recipient number should have an international dialing prefix
42 43 44 45 46 |
# File 'lib/multiinfo/api.rb', line 42 def (recipient, , opts={}) = opts.only(:valid_to, :deliv_notif_request).merge(service_id) response = execute_command( 'sendsms', {:text => , :dest => recipient}.merge() ) parse_response(response) end |
#send_package ⇒ Object
Sends a package of messages. Recipient number should have an international dialing prefix
51 52 53 |
# File 'lib/multiinfo/api.rb', line 51 def send_package # todo end |
#sms_requests ⇒ Object
:nodoc:
83 84 85 |
# File 'lib/multiinfo/api.rb', line 83 def sms_requests #:nodoc: @sms_requests ||= [] end |