Sha256: a05c5d03fa40392fceaa3863f0d250b8a2cc5a57d1b8d348038a13409a3a28be

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

module MessagebirdTexter
  module Validator
    class Request
      class ProductTokenMissing < ArgumentError; end
      class EndpointMissing < ArgumentError; end
      class PathMissing < ArgumentError; end
      class ContentTypeMissing < ArgumentError; end

      def initialize
        @endpoint     = MessagebirdTexter.config.endpoint
        @path         = MessagebirdTexter.config.path
        @content_type = MessagebirdTexter.config.content_type
        @api_key      = MessagebirdTexter.config.product_token
        validate
      end

      def validate
        fail EndpointMissing, "Please provide an valid api endpoint.\nIf you leave this config blank, the default will be set to https://rest.sms-service.org  ." if @endpoint.nil? || @endpoint.empty?
        fail ContentTypeMissing, 'Please provide a valid content_type! Defaults to application/json' if @content_type.nil? || @content_type.empty?
        fail PathMissing, "Please provide an valid api path.\nIf you leave this config blank, the default will be set to /message." if @path.nil? || @path.empty?
        fail ProductTokenMissing, "Please provide an valid product key.\nAfter signup at https://www.messagebird.com/, you will find one in your settings." if @api_key.nil?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
messagebird-texter-0.0.2 lib/messagebird_texter/validator/request.rb