Class: Tracksale::DummyClient

Inherits:
Object
  • Object
show all
Defined in:
lib/tracksale/dummy_client.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDummyClient

Returns a new instance of DummyClient.



7
8
9
# File 'lib/tracksale/dummy_client.rb', line 7

def initialize
  puts 'running tracksale dummy client, do not expect real responses.' if $DEBUG
end

Class Attribute Details

.responseObject

Easy way to force a response



4
5
6
# File 'lib/tracksale/dummy_client.rb', line 4

def response
  @response
end

Instance Method Details

#default_response_objectObject



21
22
23
24
25
26
27
28
29
# File 'lib/tracksale/dummy_client.rb', line 21

def default_response_object
  response = {}

  def response.success?
    true
  end

  response
end

#get(_endpoint_path, _extra_headers = {}) ⇒ Object

maintaining the same method signature as the real client



12
13
14
# File 'lib/tracksale/dummy_client.rb', line 12

def get(_endpoint_path, _extra_headers = {})
  response
end

#post(_endpoint_path, _body, _extra_headers = {}) ⇒ Object

maintaining the same method signature as the real client



17
18
19
# File 'lib/tracksale/dummy_client.rb', line 17

def post(_endpoint_path, _body, _extra_headers = {})
  response
end

#responseObject



31
32
33
34
# File 'lib/tracksale/dummy_client.rb', line 31

def response
  # definies a default valid response unless explicity defined.
  self.class.response || default_response_object
end