class Gupshup::Client

Attributes

apikey[R]

Init @gupshup = Gupshup::Client.new(“APIKEY HERE”,“APPNAME”)

Example:

>> response=@gupshup.sendWhatsAppText(from:"917834811114",to:"94778845700",body:"This is to remind you that {{1}} is due by {{2}}.")
{:code=>200, :body=>{"status"=>"submitted", "messageId"=>"45c63e36-2e30-4116-aa85-66a3de6f35fa"}}

Arguments:

apikey: (String) ShoutOUT Apikey
from: (String) sender ID
to: (Array) receivers phone numbers
body: (String) message body
appName[R]

Init @gupshup = Gupshup::Client.new(“APIKEY HERE”,“APPNAME”)

Example:

>> response=@gupshup.sendWhatsAppText(from:"917834811114",to:"94778845700",body:"This is to remind you that {{1}} is due by {{2}}.")
{:code=>200, :body=>{"status"=>"submitted", "messageId"=>"45c63e36-2e30-4116-aa85-66a3de6f35fa"}}

Arguments:

apikey: (String) ShoutOUT Apikey
from: (String) sender ID
to: (Array) receivers phone numbers
body: (String) message body

Public Class Methods

new(apikey,appName) click to toggle source
# File lib/gupshup-sdk.rb, line 19
def initialize(apikey,appName)
  @apikey=apikey
  @appName=appName
end

Public Instance Methods

sendWhatsApp(from:,to:,body:) click to toggle source
# File lib/gupshup-sdk.rb, line 24
def sendWhatsApp(from:,to:,body:)
  return WhatspApp.send(self.apikey,from,to,JSON.generate(body),self.appName)
end
sendWhatsAppImage(from:,to:,imageUrl:,previewUrl: nil,caption: nil, filename: nil) click to toggle source
# File lib/gupshup-sdk.rb, line 37
def sendWhatsAppImage(from:,to:,imageUrl:,previewUrl: nil,caption: nil, filename: nil)
  params={
    "type": "image",
    "originalUrl": imageUrl
  }
  params[:previewUrl]=previewUrl|| imageUrl
  params[:caption]=caption if caption!=nil
  params[:filename]=filename if filename!=nil
  return sendWhatsApp(from:from,to:to,body:params)
end
sendWhatsAppText(from:,to:,body:) click to toggle source
# File lib/gupshup-sdk.rb, line 28
def sendWhatsAppText(from:,to:,body:)
  params={
    "isHSM":"true",
    "type": "text",
    "text": body
  }
    return sendWhatsApp(from:from,to:to,body:params)
end