class Whats::Api

Attributes

base_path[R]

Public Class Methods

new() click to toggle source
# File lib/whats/api.rb, line 9
def initialize
  @base_path = Whats.configuration.base_path
end

Public Instance Methods

check_contact(number) click to toggle source
# File lib/whats/api.rb, line 17
def check_contact(number)
  response = check_contacts([number])

  if response["errors"]
    raise Whats::Errors::RequestError.new("WhatsApp error.", response)
  end

  result = \
    response["contacts"].reduce({}) do |temp, hash|
      temp.merge(hash["input"] => hash)
    end

  result[number]
end
check_contacts(numbers) click to toggle source
# File lib/whats/api.rb, line 13
def check_contacts(numbers)
  Actions::CheckContacts.new(client, numbers).call
end
send_hsm_message(username, namespace, element_name, language, params) click to toggle source
# File lib/whats/api.rb, line 36
def send_hsm_message(username, namespace, element_name, language, params)
  Actions::SendHsmMessage.new(
    client,
    username,
    namespace,
    element_name,
    language,
    params
  ).call
end
send_message(username, body) click to toggle source
# File lib/whats/api.rb, line 32
def send_message(username, body)
  Actions::SendMessage.new(client, username, body).call
end

Private Instance Methods

client() click to toggle source
# File lib/whats/api.rb, line 51
def client
  @client ||= Whats::Client.new
end