Class: MTProto::RPC::GetContacts

Inherits:
Object
  • Object
show all
Defined in:
lib/mtproto/rpc/get_contacts.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ GetContacts

Returns a new instance of GetContacts.



9
10
11
# File 'lib/mtproto/rpc/get_contacts.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#call(hash: 0) ⇒ Object



13
14
15
16
17
18
# File 'lib/mtproto/rpc/get_contacts.rb', line 13

def call(hash: 0)
  raise 'Auth key not generated' unless @client.auth_key

  query = Type::RPC::Contacts::GetContacts.build(hash: hash)
  @client.rpc.call(query)
end

#call_sync(hash: 0) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/mtproto/rpc/get_contacts.rb', line 20

def call_sync(hash: 0)
  raise 'Auth key not generated' unless @client.auth_key

  query = Type::RPC::Contacts::GetContacts.build(hash: hash)
  response = @client.rpc.call_sync(query)
  Type::RPC::Contacts::Contacts.parse(response)
end