Sha256: 771320b7346521f826517232a987d3c1bf099228cd8cab0416159ed6c8760d0f

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

module Moceansdk

  class Client
    def initialize(obj_auth, options = nil)
      unless obj_auth.is_a? Auth::AbstractAuth
        raise Exceptions::MoceanError, 'auth object must extend AbstractAuth'
      end

      if obj_auth.auth_method.casecmp('basic').zero?
        if Utils.nil_or_empty?(obj_auth.params['mocean-api-key']) || Utils.nil_or_empty?(obj_auth.params['mocean-api-secret'])
          raise Exceptions::RequiredFieldException, "api key and api secret for client object can't be empty"
        end
      else
        raise Exceptions::MoceanError, 'unsupported auth method'
      end

      @transmitter = if options.is_a? Modules::Transmitter
                       options
                     else
                       Modules::Transmitter.new(options)
                     end

      @obj_auth = obj_auth
    end

    def sms
      Modules::Message::Sms.new(@obj_auth, @transmitter)
    end

    def flash_sms
      sms = Modules::Message::Sms.new(@obj_auth, @transmitter)
      sms.mclass = 1
      sms.alt_dcs = 1
      sms
    end

    def pricing
      Modules::Account::Pricing.new(@obj_auth, @transmitter)
    end

    def balance
      Modules::Account::Balance.new(@obj_auth, @transmitter)
    end

    def message_status
      Modules::Message::MessageStatus.new(@obj_auth, @transmitter)
    end

    def verify_request
      Modules::Message::VerifyRequest.new(@obj_auth, @transmitter)
    end

    def verify_validate
      Modules::Message::VerifyValidate.new(@obj_auth, @transmitter)
    end

    def number_lookup
      Modules::NumberLookup::NumberLookup.new(@obj_auth, @transmitter)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moceansdk-1.0.0 lib/moceansdk/client.rb