Class: Hurriyet::Service::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/hurriyet/service/base.rb

Direct Known Subclasses

Article

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Base

Returns a new instance of Base.



7
8
9
10
# File 'lib/hurriyet/service/base.rb', line 7

def initialize(client)
  @client = client
  @conn = Faraday.new(url: 'https://api.hurriyet.com.tr', headers: { apikey: @client.apikey })
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



5
6
7
# File 'lib/hurriyet/service/base.rb', line 5

def client
  @client
end

Instance Method Details

#execute(endpoint) ⇒ Object



12
13
14
15
16
# File 'lib/hurriyet/service/base.rb', line 12

def execute(endpoint)
  p @conn
  p "/#{version}/#{endpoint}"
  @conn.get("/#{version}/#{endpoint}").body
end

#versionObject



18
19
20
# File 'lib/hurriyet/service/base.rb', line 18

def version
  'v1'
end