Class: OsunyApi::Client
- Inherits:
-
Object
- Object
- OsunyApi::Client
- Defined in:
- lib/osuny_api/client.rb
Constant Summary collapse
- LOG_GREEN =
32
- LOG_RED =
31
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #communication ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #post(url, body = {}) ⇒ Object
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( = {}) @host = [:host] @token = [:token] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/osuny_api/client.rb', line 5 def host @host end |
#token ⇒ Object (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
#communication ⇒ Object
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 |