Method: WeebSh::Client#initialize

Defined in:
lib/weeb/interfaces/client.rb

#initialize(auth, user_agent = nil, api_url: 'https://api.weeb.sh') ⇒ Client

Groups all interfaces into one.

Parameters:

  • auth (String)

    the authentication required to use weeb.sh.

  • user_agent (String, Hash) (defaults to: nil)

    the user agent to use with requests.

  • api_url (String) (defaults to: 'https://api.weeb.sh')

    the URL to use when using the weeb.sh API.

Raises:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/weeb/interfaces/client.rb', line 41

def initialize(auth, user_agent = nil, api_url: 'https://api.weeb.sh')
  @user_agent = WeebSh::API.format_user_agent(user_agent)
  @auth = auth
  @api_url = api_url

  raise WeebSh::Err::BadAuth, 'Authorization is empty!' if auth.empty?
  puts '[WeebSh::Client] Your User Agent is empty. Please consider adding a user agent to help identify issues easier.' if user_agent.nil?
  puts '[WeebSh::Client] Your User Agent is not ideal. Please consider adding a user agent to help identify issues easier.' if !user_agent.nil? && user_agent.split('/').count < 2

  @toph = WeebSh::Toph.new(auth, user_agent, api_url: api_url, client: self)
  @korra = WeebSh::Korra.new(auth, user_agent, api_url: api_url, client: self)
  @shimakaze = WeebSh::Shimakaze.new(auth, user_agent, api_url: api_url, client: self)
  @tama = WeebSh::Tama.new(auth, user_agent, api_url: api_url, client: self)
end