Class: Emojidex::Client

Inherits:
Object
  • Object
show all
Includes:
API::Categories, API::Emoji, API::Search::Emoji
Defined in:
lib/emojidex/client.rb

Overview

get the data from emojidex.com

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from API::Search::Emoji

#emoji_code_cont

Methods included from API::Emoji

#emoji, #emoji_detailed, #single_emoji, #single_emoji_detailed

Methods included from API::Categories

#categories, #category

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
# File 'lib/emojidex/client.rb', line 18

def initialize(opts = {})
  @api_key = opts[:api_key]
  @api_username = opts[:api_username]
  @host = opts[:host] || 'https://www.emojidex.com/'
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



11
12
13
# File 'lib/emojidex/client.rb', line 11

def api_key
  @api_key
end

#api_usernameObject

Returns the value of attribute api_username.



11
12
13
# File 'lib/emojidex/client.rb', line 11

def api_username
  @api_username
end

#hostObject (readonly)

Returns the value of attribute host.



12
13
14
# File 'lib/emojidex/client.rb', line 12

def host
  @host
end

Instance Method Details

#connection_optionsObject



24
25
26
27
28
29
30
31
32
# File 'lib/emojidex/client.rb', line 24

def connection_options
  @connection_options ||= {
    url: @host,
    headers: {
      accept: 'application/json',
      user_agent: user_agent
    }
  }
end

#get(path, params = {}) ⇒ Object



38
39
40
# File 'lib/emojidex/client.rb', line 38

def get(path, params = {})
  request(:get, path, params)
end

#user_agentObject



34
35
36
# File 'lib/emojidex/client.rb', line 34

def user_agent
  @user_agent ||= 'Emojidex Toolkit Client'
end