Class: KHL::HTTP::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/khl/http/client.rb

Overview

Client for the KHL HTTP API client = KHL::HTTP::Client.new(token: “bot_token”) client.guild.list # Call guild/list API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Client

Returns a new instance of Client.

Parameters:

  • config (Hash) (defaults to: {})

    Config

Options Hash (config):

  • :token (String)

    Bot token (required)

  • :token_type (String)

    Token type

  • :language (String)

    Language

Raises:

  • (ArgumentError)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/khl/http/client.rb', line 52

def initialize(config = {})
  raise ArgumentError, "missing token" unless config[:token]
  config[:token_type] ||= "Bot"
  config[:language] ||= "zh-cn"

  @asset = Asset.new(config)
  @badge = Badge.new(config)
  @blacklist = Blacklist.new(config)
  @channel = Channel.new(config)
  @channel_role = ChannelRole.new(config)
  @channel_user = ChannelUser.new(config)
  @direct_message = DirectMessage.new(config)
  @game = Game.new(config)
  @gateway = Gateway.new(config)
  @guild = Guild.new(config)
  @guild_emoji = GuildEmoji.new(config)
  @guild_mute = GuildMute.new(config)
  @guild_role = GuildRole.new(config)
  @intimacy = Intimacy.new(config)
  @invite = Invite.new(config)
  @message = Message.new(config)
  @user = User.new(config)
  @user_chat = UserChat.new(config)
end

Instance Attribute Details

#assetObject (readonly)

Returns the value of attribute asset.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def asset
  @asset
end

#badgeObject (readonly)

Returns the value of attribute badge.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def badge
  @badge
end

#blacklistObject (readonly)

Returns the value of attribute blacklist.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def blacklist
  @blacklist
end

#channelObject (readonly)

Returns the value of attribute channel.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def channel
  @channel
end

#channel_roleObject (readonly)

Returns the value of attribute channel_role.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def channel_role
  @channel_role
end

#channel_userObject (readonly)

Returns the value of attribute channel_user.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def channel_user
  @channel_user
end

#direct_messageObject (readonly)

Returns the value of attribute direct_message.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def direct_message
  @direct_message
end

#gameObject (readonly)

Returns the value of attribute game.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def game
  @game
end

#gatewayObject (readonly)

Returns the value of attribute gateway.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def gateway
  @gateway
end

#guildObject (readonly)

Returns the value of attribute guild.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def guild
  @guild
end

#guild_emojiObject (readonly)

Returns the value of attribute guild_emoji.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def guild_emoji
  @guild_emoji
end

#guild_muteObject (readonly)

Returns the value of attribute guild_mute.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def guild_mute
  @guild_mute
end

#guild_roleObject (readonly)

Returns the value of attribute guild_role.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def guild_role
  @guild_role
end

#intimacyObject (readonly)

Returns the value of attribute intimacy.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def intimacy
  @intimacy
end

#inviteObject (readonly)

Returns the value of attribute invite.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def invite
  @invite
end

#messageObject (readonly)

Returns the value of attribute message.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def message
  @message
end

#userObject (readonly)

Returns the value of attribute user.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def user
  @user
end

#user_chatObject (readonly)

Returns the value of attribute user_chat.



29
30
31
# File 'lib/khl/http/client.rb', line 29

def user_chat
  @user_chat
end