Class: BankExchangeApi::Response::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bank_exchange_api/response/base.rb

Direct Known Subclasses

Json

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http, root: nil) ⇒ Base

Returns a new instance of Base.



5
6
7
8
# File 'lib/bank_exchange_api/response/base.rb', line 5

def initialize(http, root: nil)
  @http = http
  @root = root
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



3
4
5
# File 'lib/bank_exchange_api/response/base.rb', line 3

def http
  @http
end

#rootObject (readonly)

Returns the value of attribute root.



3
4
5
# File 'lib/bank_exchange_api/response/base.rb', line 3

def root
  @root
end

Instance Method Details

#bodyObject

Response body

Examples:

params: {}, rates: []

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/bank_exchange_api/response/base.rb', line 32

def body
  raise NotImplementedError, __method__
end

#dataObject

Response payload data User root param to access the data

Examples:

rates: [{currency: 'EUR'}, {currency: 'EUR'}]

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/bank_exchange_api/response/base.rb', line 18

def data
  raise NotImplementedError, __method__
end

#next_page_urlObject

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/bank_exchange_api/response/base.rb', line 40

def next_page_url
  raise NotImplementedError, __method__
end

#not_paginatable?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/bank_exchange_api/response/base.rb', line 48

def not_paginatable?
  !paginatable?
end

#paginatable?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/bank_exchange_api/response/base.rb', line 44

def paginatable?
  !next_page_url.nil?
end

#paginationObject

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/bank_exchange_api/response/base.rb', line 36

def pagination
  raise NotImplementedError, __method__
end

#paramsObject

Request params in responce

Examples:

params: {currencies: 'EUR,USD'}

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/bank_exchange_api/response/base.rb', line 25

def params
  raise NotImplementedError, __method__
end

#success?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/bank_exchange_api/response/base.rb', line 10

def success?
  http.code.to_i == 200
end