Class: KrakenClient::Requests::Base

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
lib/kraken_client/requests/base.rb

Direct Known Subclasses

Get, Post

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, type) ⇒ Base



11
12
13
14
15
# File 'lib/kraken_client/requests/base.rb', line 11

def initialize(config, type)
  @config = config
  @type = type
  add_observer(config.limiter_interface)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/kraken_client/requests/base.rb', line 9

def config
  @config
end

#endpoint_nameObject (readonly)

Returns the value of attribute endpoint_name.



9
10
11
# File 'lib/kraken_client/requests/base.rb', line 9

def endpoint_name
  @endpoint_name
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/kraken_client/requests/base.rb', line 9

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/kraken_client/requests/base.rb', line 9

def url
  @url
end

Class Method Details

.build(config, type) ⇒ Object



17
18
19
20
21
# File 'lib/kraken_client/requests/base.rb', line 17

def self.build(config, type)
  type = self.type(type)

  "KrakenClient::Requests::#{type}".constantize.new(config, type)
end

.type(given_type) ⇒ Object



28
29
30
# File 'lib/kraken_client/requests/base.rb', line 28

def self.type(given_type)
  given_type == 'Public' ? 'Get' : 'Post'
end

Instance Method Details

#call(url, _endpoint_name, _options = nil) ⇒ Object



23
24
25
26
# File 'lib/kraken_client/requests/base.rb', line 23

def call(url, _endpoint_name, _options = nil)
  changed
  notify_observers(url.split('/').last)
end