Module: IletiMerkezi

Defined in:
lib/ileti_merkezi.rb,
lib/ileti_merkezi/error.rb,
lib/ileti_merkezi/status.rb,
lib/ileti_merkezi/message.rb,
lib/ileti_merkezi/version.rb,
lib/ileti_merkezi/response.rb,
lib/ileti_merkezi/actions/sms.rb,
lib/ileti_merkezi/utils/request.rb,
lib/ileti_merkezi/actions/cancel.rb,
lib/ileti_merkezi/actions/report.rb,
lib/ileti_merkezi/actions/account.rb,
lib/ileti_merkezi/actions/balance.rb,
lib/ileti_merkezi/utils/xml_builder.rb,
lib/ileti_merkezi/utils/configuration.rb,
lib/ileti_merkezi/utils/authentication.rb

Overview

IletiMerkezi

Defined Under Namespace

Modules: Authentication, Balance, XmlBuilder Classes: Account, Cancel, Configuration, CredentialMissingError, InvalidMessageError, Message, Report, Request, Response, Sms, Status

Constant Summary collapse

VERSION =
'1.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



27
28
29
# File 'lib/ileti_merkezi.rb', line 27

def configuration
  @configuration ||= Configuration.new
end

Class Method Details

.balanceIletiMerkezi::Response

Get balance information



42
43
44
# File 'lib/ileti_merkezi.rb', line 42

def balance
  Balance.query
end

.cancel(order_id) ⇒ IletiMerkezi::Response

Sms order cancellation

Parameters:

  • order_id (Integer)

    Sms order id

Returns:



53
54
55
# File 'lib/ileti_merkezi.rb', line 53

def cancel(order_id)
  Cancel.new(order_id).confirm
end

.code(code_id) ⇒ IletiMerkezi::Status

Find status with code id

Parameters:

  • code_id (Integer)

    Http status code

Returns:



64
65
66
# File 'lib/ileti_merkezi.rb', line 64

def code(code_id)
  Status.find(code_id)
end

.configure {|configuration| ... } ⇒ Object

Yields:



31
32
33
# File 'lib/ileti_merkezi.rb', line 31

def configure
  yield(configuration)
end

.infoHash

Get account information

name_surname: 'name-surname',
tc_number: nil,
title: nil,
email: 'email',
gsm: 'phone',
password: 'password',
commercial_title: nil,
gsm2: nil,
phone_number: nil,
fax_number: nil,
bill_address: nil,
zone: nil,
city: nil,
zip: nil,
charge_home: nil,
charge_number: nil

Returns:

  • (Hash)


91
92
93
94
# File 'lib/ileti_merkezi.rb', line 91

def info
  response = Account.info
  response.to_h.fetch(:userInfo, {})
end

.report(order_id, page: 1, row_count: 1000) ⇒ IletiMerkezi::Response

Get Sms order report

Parameters:

  • order_id (Integer)

    , page [Integer], row_count [Integer]

Returns:



103
104
105
106
107
# File 'lib/ileti_merkezi.rb', line 103

def report(order_id, page: 1, row_count: 1000)
  Report.new(order_id,
             page: page,
             row_count: row_count).query
end

.send(args) ⇒ IletiMerkezi::Response

Sms send method

Example:

args1 =

send_datetime: '15/01/2017 12:00' # Opsiyonel
sender: 'TEST' # Opsiyonel
phones: ['0555 555 00 01', '0555 555 00 02']
text: 'Test Message'

args2 = {

send_datetime: '15/01/2017 12:00' # Opsiyonel
sender: 'TEST' # Opsiyonel
messages: [
  {
    text: 'First Test Message',
    phones: ['0555 555 00 01', '0555 555 00 02'],
  },
  {
    text: 'Second Test Message',
    phones: ['0555 555 00 03', '0555 555 00 04'],
  }
]

}

response = IletiMerkezi.send(args1) or response = IletiMerkezi.send(args2)

Parameters:

  • args (Hash)

Returns:



144
145
146
# File 'lib/ileti_merkezi.rb', line 144

def send(args)
  Sms.new(args).send
end

.sendersHash

Get senders

Returns:

  • (Hash)


153
154
155
156
# File 'lib/ileti_merkezi.rb', line 153

def senders
  response = Account.senders
  response.to_h.fetch(:smsHeaderInfo, {})
end

.statusBoolean

Get Service Status

Returns:

  • (Boolean)


163
164
165
# File 'lib/ileti_merkezi.rb', line 163

def status
  balance.code == 200
end