Sha256: 27fa169402b597548eaca18db3092968cd5207e9e8ac39d7b2eddb4702adaf32

Contents?: true

Size: 709 Bytes

Versions: 1

Compression:

Stored size: 709 Bytes

Contents

# frozen_string_literal: true

# Version
require 'ctm_sms/version'
# Constants
require 'ctm_sms/constants'
# Client
require 'ctm_sms/ctm_client'
# Utils
require 'ctm_sms/errors'
require 'ctm_sms/session'

module CtmSms
  class SendSms
    attr_reader :message, :to, :client

    def initialize(message, to)
      @message = message
      @to = to
      @client = CtmSms::CtmClient.new
    end

    def send_sms
      client.send_sms params
    end

    private

    def params
      {
        username: ENV.fetch('CTM_API_USERNAME'),
        password: ENV.fetch('CTM_API_PASSWORD'),
        from: ENV.fetch('CTM_FROM'),
        to: to,
        locale: 'utf-8',
        text: message
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ctm_sms-0.1.0 lib/ctm_sms.rb