Class: Gupshup::REST::Api::V1::MessageList
- Inherits:
-
ListResource
- Object
- ListResource
- Gupshup::REST::Api::V1::MessageList
- Defined in:
- lib/gupshup-rb/rest/api/v1/message.rb
Instance Method Summary collapse
- #create(to: nil, from: :unset, body: :unset, media_url: :unset, content_type: :unset, src_name: :unset, api_key: :unset) ⇒ Object
-
#initialize(version, src_name: nil) ⇒ MessageList
constructor
Initialize the MessageList def initialize(version, src_name: nil, content_type, from, apikey).
- #send_text_message(headers, from, to, body, src_name) ⇒ Object
Constructor Details
#initialize(version, src_name: nil) ⇒ MessageList
Initialize the MessageList def initialize(version, src_name: nil, content_type, from, apikey)
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gupshup-rb/rest/api/v1/message.rb', line 12 def initialize(version, src_name: nil) super(version) # Path Solution @solution = {src_name: src_name} @uri = "https://api.gupshup.io/sm/api/v1/msg" @base_url = 'https://api.gupshup.io' @path = '/sm/api/v1/msg' @channel = 'whatsapp' end |
Instance Method Details
#create(to: nil, from: :unset, body: :unset, media_url: :unset, content_type: :unset, src_name: :unset, api_key: :unset) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gupshup-rb/rest/api/v1/message.rb', line 24 def create(to: nil, from: :unset, body: :unset, media_url: :unset, content_type: :unset, src_name: :unset, api_key: :unset) headers = { 'apikey' => api_key} binding.local_variables.each do |var_name| var_value = binding.local_variable_get(var_name) puts "#{var_name}: #{var_value}" end #case message_params[:type] #when 'text' #else (headers, from, to, body, src_name) #end #end end |
#send_text_message(headers, from, to, body, src_name) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gupshup-rb/rest/api/v1/message.rb', line 42 def (headers, from, to, body, src_name) payload = {'type' => 'text', 'text' => body }.to_json data = { 'channel' => @channel, 'destination' => to, 'source' => from, 'src.name' => src_name, 'message' => payload } r = Gupshup::HTTP::Client.new r.request(host = @base_url, port = 443, method = 'POST', url = @path, data = data, headers = headers) end |