Class: CodecFastSms::Client

Inherits:
Core
  • Object
show all
Defined in:
lib/codec_fast_sms/client.rb

Overview

Client

Instance Attribute Summary

Attributes inherited from Core

#attributes, #connection, #message, #profile, #response, #to

Instance Method Summary collapse

Methods inherited from Core

#current_config, #initialize, #perform

Constructor Details

This class inherits a constructor from CodecFastSms::Core

Instance Method Details

#assign_recipient_information(to, message) ⇒ Object



30
31
32
33
# File 'lib/codec_fast_sms/client.rb', line 30

def assign_recipient_information(to, message)
  self.to = to
  self.message = message
end

#deliver(to, message) ⇒ Object



35
36
37
38
# File 'lib/codec_fast_sms/client.rb', line 35

def deliver(to, message)
  assign_recipient_information(to, message)
  perform
end

#generate_optional_parametersObject



40
41
42
43
44
45
# File 'lib/codec_fast_sms/client.rb', line 40

def generate_optional_parameters
  attr = attributes[:optionalParameters]
  return attr.to_json if attr.is_a?(Hash) && !attr.empty?

  attr.to_s
end

#iys_paramsObject



22
23
24
25
26
27
28
# File 'lib/codec_fast_sms/client.rb', line 22

def iys_params
  {
    iysMessageType: (attributes[:iys_message_type] || 'BILGILENDIRME'),
    iysRecipientType: attributes[:iys_recipient_type].to_s,
    iysBrandCode: attributes[:iys_brand_code].to_s
  }
end

#paramsObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/codec_fast_sms/client.rb', line 11

def params
  {
    userName: current_config.username,
    password: current_config.password,
    sender: current_config.sender,
    phone: to, messageContent: message, msgSpecialId: '', isOtn: 'True',
    headerCode: '', responseType: '3',
    optionalParameters: generate_optional_parameters
  }.merge(iys_params)
end

#request_uriObject

Api endpoint.



7
8
9
# File 'lib/codec_fast_sms/client.rb', line 7

def request_uri
  '/Soap.asmx/SendSms'
end