Class: OngairRuby::ClientV2

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

Instance Method Summary collapse

Constructor Details

#initialize(token, base_url = 'https://ongair.im') ⇒ ClientV2

Returns a new instance of ClientV2.



31
32
33
34
# File 'lib/ongair_ruby.rb', line 31

def initialize token, base_url='https://ongair.im'
	@token = token
   @base_url = base_url
end

Instance Method Details

#send_chain(external_id, messages, thread = true) ⇒ Object

Send a chain of messages including options

messages=[{ text: ‘Hi’}, { text: ‘Question?’, options: [“1,2”]} ]



50
51
52
# File 'lib/ongair_ruby.rb', line 50

def send_chain(external_id, messages, thread=true)
  HTTParty.post("#{@base_url}/api/v1/base/send_chain", body: {token: @token, external_id: external_id, messages: messages, thread: thread })
end

#send_image(external_id, image_url, content_type, caption = nil, options = nil, thread = true) ⇒ Object



40
41
42
# File 'lib/ongair_ruby.rb', line 40

def send_image(external_id, image_url, content_type, caption=nil, options=nil, thread=true)
  HTTParty.post("#{@base_url}/api/v1/base/send_image", body: {token: @token, external_id: external_id, caption: caption, image: image_url, thread: thread, options: options })
end

#send_location_prompt(external_id, text, thread = true) ⇒ Object



58
59
60
# File 'lib/ongair_ruby.rb', line 58

def send_location_prompt(external_id, text, thread=true)
  HTTParty.post("#{@base_url}/api/v1/base/send_location_prompt", body: {token: @token, external_id: external_id, text: text, thread: thread })
end

#send_message(external_id, message, options = nil, thread = true) ⇒ Object



36
37
38
# File 'lib/ongair_ruby.rb', line 36

def send_message(external_id, message, options=nil, thread=true)
  HTTParty.post("#{@base_url}/api/v1/base/send", body: {token: @token, external_id: external_id, text: message, thread: thread, options: options })
end

#send_telephone_prompt(external_id, text, thread = true) ⇒ Object



54
55
56
# File 'lib/ongair_ruby.rb', line 54

def send_telephone_prompt(external_id, text, thread=true)
  HTTParty.post("#{@base_url}/api/v1/base/send_telephone_prompt", body: {token: @token, external_id: external_id, text: text, thread: thread })
end