Class: Cb::Responses::RawApiResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/cb/responses/raw_api_response.rb

Direct Known Subclasses

Spot::Retrieve

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_api_response = {}) ⇒ RawApiResponse



7
8
9
10
# File 'lib/cb/responses/raw_api_response.rb', line 7

def initialize(raw_api_response={})
  @raw_api_hash = raw_api_response
  validate_raw_api_response
end

Instance Attribute Details

#raw_api_hashObject

Returns the value of attribute raw_api_hash.



5
6
7
# File 'lib/cb/responses/raw_api_response.rb', line 5

def raw_api_hash
  @raw_api_hash
end

Instance Method Details

#extract_modelsObject

Raises:

  • (NotImplementedError)


18
19
20
21
# File 'lib/cb/responses/raw_api_response.rb', line 18

def extract_models
  # your api hash is considered valid at this point - grab the data you need and turn it into model(s)
  raise NotImplementedError.new(__method__)
end

#validate_raw_api_responseObject

Raises:

  • (NotImplementedError)


12
13
14
15
16
# File 'lib/cb/responses/raw_api_response.rb', line 12

def validate_raw_api_response
  # call #required_response_field in here for each node that you know you'll need - stuff like the root node
  # or the node that contains the data from which your model is built.
  raise NotImplementedError.new(__method__)
end