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:



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

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.



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

def api_version
  @api_version
end

#passwordObject

Returns the value of attribute password.



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

def password
  @password
end

#usernameObject

Returns the value of attribute username.



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

def username
  @username
end

Instance Method Details

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



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

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

#ads(options = {}) ⇒ Object



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

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

#configured?Boolean

Returns:

  • (Boolean)

Raises:



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

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