Class: Mobile::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/mobile/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (_self)

Yield Parameters:



17
18
19
20
21
# File 'lib/mobile/client.rb', line 17

def initialize(&block)
  yield(self)
  self.api_version = '1.0.0' if self.api_version.nil?
  self
end

Instance Attribute Details

#api_versionObject

Returns the value of attribute api_version.



15
16
17
# File 'lib/mobile/client.rb', line 15

def api_version
  @api_version
end

#passwordObject

Returns the value of attribute password.



15
16
17
# File 'lib/mobile/client.rb', line 15

def password
  @password
end

#usernameObject

Returns the value of attribute username.



15
16
17
# File 'lib/mobile/client.rb', line 15

def username
  @username
end

Instance Method Details

#ad(id, options = {}) ⇒ Object



28
29
30
# File 'lib/mobile/client.rb', line 28

def ad(id, options={})
  request('get', "/ad/#{id}", options)['ad']
end

#ads(options = {}) ⇒ Object



24
25
26
# File 'lib/mobile/client.rb', line 24

def ads(options={})
  request('get', '/ad/search', options)['result']
end

#configured?Boolean



32
33
34
35
# File 'lib/mobile/client.rb', line 32

def configured?
  raise Mobile::MissingConfig, "Either username or password is not set in configuration block. Please fix this." unless !username.nil? && !password.nil?
  !username.nil? && !password.nil?
end