lib/whats/api.rb in whatsapp-0.1.4 vs lib/whats/api.rb in whatsapp-0.1.5
- old
+ new
@@ -4,21 +4,25 @@
require "whats/actions/send_message"
require "whats/actions/send_hsm_message"
module Whats
class Api
- def initialize(base_path)
- @base_path = base_path
+ def initialize
+ @base_path = Whats.configuration.base_path
end
def check_contacts(numbers)
Actions::CheckContacts.new(client, numbers).call
end
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
@@ -42,9 +46,9 @@
private
attr_reader :base_path
def client
- @client ||= Whats::Client.new(base_path)
+ @client ||= Whats::Client.new
end
end
end