Class: HotPepper::Client

Inherits:
Object
  • Object
show all
Includes:
Endpoints, Query
Defined in:
lib/hot_pepper/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Query

#generate_query

Methods included from Endpoints::Gourmet

#gourmet

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hot_pepper/client.rb', line 18

def initialize(options = {})
  HotPepper::Config::ATTRIBUTES.each do |key|
    send("#{key}=", options.fetch(key, HotPepper.config.send(key)))
  end
  @api_key ||= HotPepper.config.api_key
  @client = Faraday.new(url: endpoint) do |conn|
    conn.request :json
    conn.response :json, content_type: /\bjson$/
    conn.response :encoding
    conn.adapter Faraday.default_adapter
  end
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



16
17
18
# File 'lib/hot_pepper/client.rb', line 16

def api_key
  @api_key
end

#clientObject

Returns the value of attribute client.



16
17
18
# File 'lib/hot_pepper/client.rb', line 16

def client
  @client
end

#default_max_retriesObject

Returns the value of attribute default_max_retries.



16
17
18
# File 'lib/hot_pepper/client.rb', line 16

def default_max_retries
  @default_max_retries
end

#endpointObject

Returns the value of attribute endpoint.



16
17
18
# File 'lib/hot_pepper/client.rb', line 16

def endpoint
  @endpoint
end

Class Method Details

.configObject



43
44
45
# File 'lib/hot_pepper/client.rb', line 43

def config
  Config
end

.configureObject



39
40
41
# File 'lib/hot_pepper/client.rb', line 39

def configure
  block_given? ? yield(Config) : Config
end