Sha256: c86b634b72811ced9aa6ed0173e998fd8055720ac186dee2cdd924406b159cba

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require File.expand_path('../common_request', __FILE__)
module Gateway
  module Requests
    #
    # Request to send message via gateway
    #
    class SendMessageRequest < Gateway::Requests::CommonRequest

      TRANSPORT_WA       = 'whatsapp' # transport whatsapp
      TRANSPORT_VIBER    = 'viber' # transport viber
      TRANSPORT_TG       = 'telegram' # transport telegram
      TRANSPORT_SMS      = 'modem' # transport modem
      TRANSPORT_FACEBOOK = 'facebook' # transport facebook
      TRANSPORT_VK = 'vk' # transport vk
      TRANSPORT_EXTERNAL = 'external' # transport external
      TRANSPORT_WIDGET   = 'widget' # transport widget

      attr_accessor :phone, :devicePhone, :body, :image, :transport, :plannedDate, :messageId, :pdf

      #
      # Possible transports
      #
      def self.possible_transports
        [TRANSPORT_WA, TRANSPORT_VIBER, TRANSPORT_TG, TRANSPORT_SMS, TRANSPORT_FACEBOOK, TRANSPORT_VK, TRANSPORT_EXTERNAL, TRANSPORT_WIDGET]
      end

      def transport=(transport)
        unless self.class.possible_transports.include? transport
          raise Gateway::ArgumentError.new("transport #{transport} is not supported, use: #{self.class.possible_transports.join(', ')}")
        end
        @transport = transport
      end

    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gateway-sdk-1.2.5 lib/gateway/requests/send_message_request.rb
gateway-sdk-1.2.4 lib/gateway/requests/send_message_request.rb