Class: SmsAero2::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sms_aero2.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(login:, token:, logger: nil) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
# File 'lib/sms_aero2.rb', line 14

def initialize(login:, token:, logger: nil)
  @login = 
  @token = token
  @logger = logger
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



12
13
14
# File 'lib/sms_aero2.rb', line 12

def logger
  @logger
end

#loginObject

Returns the value of attribute login.



12
13
14
# File 'lib/sms_aero2.rb', line 12

def 
  @login
end

#tokenObject

Returns the value of attribute token.



12
13
14
# File 'lib/sms_aero2.rb', line 12

def token
  @token
end

Instance Method Details

#hlr(phone:) ⇒ Object



43
44
45
# File 'lib/sms_aero2.rb', line 43

def hlr(phone:)
  SmsAero2::HlrOperation.new(request, 'hlr/check', number: phone).call
end

#hlr_status(id:) ⇒ Object



39
40
41
# File 'lib/sms_aero2.rb', line 39

def hlr_status(id:)
  SmsAero2::HlrOperation.new(request, 'hlr/status',  id: id).call
end

#send_sms(to:, from:, text:, channel:, **options) ⇒ Object

channel values: ‘info’ Info signature for all operators ‘digital’ Digital channel sending (only permitted transaction flow) ‘international’ International delivery (Operators of Russia, Kazakhstan, Ukraine and Belarus) ‘direct’ Advertising channel send message free letter signature. ‘service’ Service channel for sending service SMS according to the approved template with a paid signature of the sender.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sms_aero2.rb', line 27

def send_sms(to:, from:, text:, channel:, **options)
  path = options[:testsend] ? 'sms/testsend' : 'sms/send'
  if %w[info digital international direct service].include?(channel.to_s)
    SmsAero2::Operation.new(
        request, path,
        number: to, sign: from, text: text, channel: channel.upcase, **options
    ).call
  else
    raise ArgumentError, "invalid channel value, see documentation"
  end
end