Class: SmsBroker::Client::OpenMarket

Inherits:
Base
  • Object
show all
Defined in:
lib/sms_broker/client/open_market.rb

Instance Attribute Summary

Attributes inherited from Base

#client, #name, #phone_number, #sender_id

Instance Method Summary collapse

Methods inherited from Base

#serialize_to_number

Constructor Details

#initialize(options) ⇒ OpenMarket

Returns a new instance of OpenMarket.



4
5
6
7
8
9
10
11
# File 'lib/sms_broker/client/open_market.rb', line 4

def initialize(options)
  client = ::OpenMarket::SMS::Client.new(
    account_id: options[:account_id],
    account_password: options[:account_password]
  )

  super :open_market, client, options
end

Instance Method Details

#message_status(params) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/sms_broker/client/open_market.rb', line 34

def message_status(params)
  response = client.message_status \
    ticket_id: params[:message_id]

  if success_response?(response)
    Response::OpenMarket::MessageStatusSuccess.new(response)
  else
    Response::OpenMarket::Error.new(response)
  end
end

#send_message(message) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sms_broker/client/open_market.rb', line 13

def send_message(message)
  response = client.send_message \
    text: message[:text],
    from: message[:from],
    to: message[:to]

  if success_response?(response)
    Response::OpenMarket::SendMessageSuccess.new(response)
  else
    Response::OpenMarket::Error.new(response)
  end
end

#send_voice_message(_message) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/sms_broker/client/open_market.rb', line 26

def send_voice_message(_message)
  message = 'openmarket voice message is not implemented'
  exception = \
    Exceptions::NotImplemented.new(message)

  raise exception
end