Class: Monobank::Methods::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/monobank/methods/base.rb

Direct Known Subclasses

Get, Post

Instance Method Summary collapse

Constructor Details

#initialize(auth: nil) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/monobank/methods/base.rb', line 6

def initialize(auth: nil)
  @auth = auth
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
# File 'lib/monobank/methods/base.rb', line 10

def call
  http_response = response
  attributes = http_response.parsed_response
  return define_resources(attributes) if http_response.code == 200

  Monobank::Resources::Error.new(attributes.merge('code' => http_response.code))
end