Class: OsunyApi::Client

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

Constant Summary collapse

LOG_GREEN =
32
LOG_RED =
31

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



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

def initialize(options = {})
  @host = options[:host]
  @token = options[:token]
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/osuny_api/client.rb', line 5

def host
  @host
end

#tokenObject (readonly)

Returns the value of attribute token.



5
6
7
# File 'lib/osuny_api/client.rb', line 5

def token
  @token
end

Instance Method Details

#communicationObject



15
16
17
18
19
20
# File 'lib/osuny_api/client.rb', line 15

def communication
  @communication ||= OsunyApi::Communication.new(
    client: self,
    parent: OsunyApi::Resource.new(client: self)
  )
end

#post(url, body = {}) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/osuny_api/client.rb', line 22

def post(url, body = {})
  log "[POST] #{url}", LOG_GREEN
  response = HTTParty.post  url,
  body: body,
  headers: headers
  log response.code
end