Class: ZoomEye::API

Inherits:
Object
  • Object
show all
Defined in:
lib/zoomeye/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(username: ENV["ZOOMEYE_USERNAME"], password: ENV["ZOOMEYE_PASSWORD"]) ⇒ API

Returns a new instance of API.

Raises:

  • (ArgumentError)

5
6
7
8
9
10
11
# File 'lib/zoomeye/api.rb', line 5

def initialize(username: ENV["ZOOMEYE_USERNAME"], password: ENV["ZOOMEYE_PASSWORD"])
  @username = username
  raise ArgumentError, "No usernamme has been found or provided!" unless @username

  @password = password
  raise ArgumentError, "No password has been found or provided!" unless @password
end

Instance Method Details

#hostObject


21
22
23
# File 'lib/zoomeye/api.rb', line 21

def host
  @host ||= Clients::Host.new(access_token: access_token)
end

#resource_infoObject


25
26
27
# File 'lib/zoomeye/api.rb', line 25

def resource_info
  @resource_info ||= Clients::ResourceInfo.new(access_token: access_token)
end

#userObject


13
14
15
# File 'lib/zoomeye/api.rb', line 13

def user
  @user ||= Clients::User.new(username: @username, password: @password)
end

#webObject


17
18
19
# File 'lib/zoomeye/api.rb', line 17

def web
  @web ||= Clients::Web.new(access_token: access_token)
end