Class: Moceansdk::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/moceansdk/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj_auth, options = nil) ⇒ Client

Returns a new instance of Client.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/moceansdk/client.rb', line 4

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

Instance Method Details

#balanceObject



41
42
43
# File 'lib/moceansdk/client.rb', line 41

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

#commandObject



65
66
67
# File 'lib/moceansdk/client.rb', line 65

def command
  Modules::Command::Command.new(@obj_auth, @transmitter)
end

#flash_smsObject



30
31
32
33
34
35
# File 'lib/moceansdk/client.rb', line 30

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

#message_statusObject



45
46
47
# File 'lib/moceansdk/client.rb', line 45

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

#number_lookupObject



57
58
59
# File 'lib/moceansdk/client.rb', line 57

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

#pricingObject



37
38
39
# File 'lib/moceansdk/client.rb', line 37

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

#smsObject



26
27
28
# File 'lib/moceansdk/client.rb', line 26

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

#verify_requestObject



49
50
51
# File 'lib/moceansdk/client.rb', line 49

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

#verify_validateObject



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

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

#voiceObject



61
62
63
# File 'lib/moceansdk/client.rb', line 61

def voice
  Modules::Voice::Voice.new(@obj_auth, @transmitter)
end