Class: IletiMerkezi::Sms

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

Overview

Sms

Constant Summary collapse

PATH =
'/send-sms'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Sms



10
11
12
13
# File 'lib/ileti_merkezi/sms.rb', line 10

def initialize(args)
  @args   = args
  @sender = args[:sender] || IletiMerkezi.configuration.sender
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/ileti_merkezi/sms.rb', line 6

def args
  @args
end

#senderObject (readonly)

Returns the value of attribute sender.



6
7
8
# File 'lib/ileti_merkezi/sms.rb', line 6

def sender
  @sender
end

Instance Method Details

#messagesObject



15
16
17
18
# File 'lib/ileti_merkezi/sms.rb', line 15

def messages
  messages = args.fetch(:messages, [args])
  messages.map { |msg| Message.new(msg[:phones], msg[:text]) }
end

#sendObject



24
25
26
27
# File 'lib/ileti_merkezi/sms.rb', line 24

def send
  request = Request.new(content: content, path: PATH)
  request.call
end

#send_datetimeObject



20
21
22
# File 'lib/ileti_merkezi/sms.rb', line 20

def send_datetime
  args.fetch(:send_datetime, Time.now.strftime('%d/%m/%Y %H:%M'))
end