Class: ThreeTapsAPI::Reference
- Inherits:
-
Base
- Object
- Base
- ThreeTapsAPI::Reference
show all
- Defined in:
- lib/three_taps_api/reference.rb
Instance Attribute Summary
Attributes inherited from Base
#results
Instance Method Summary
collapse
Methods inherited from Base
api_key, #auth_token_hash
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/three_taps_api/reference.rb', line 19
def method_missing(name, *args, &block)
p "#{name} is not a valid parameter." and return if ThreeTapsAPI.invalid_parameter? name
uri = self.class.base_uri + "/#{name.to_s}"
@results = self.class.get uri, { query: auth_token_hash }
begin
parsed_response = ThreeTapsAPI.rec_hash_to_openstruct @results.parsed_response
@reference = parsed_response.send "#{name.to_s}" if parsed_response.success
rescue TypeError
p "ThreeTapsAPI::Reference.locations #{name.to_s}: rec_hash_to_openstruct not passed a hash"
end
end
|
Instance Method Details
#locations(level) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/three_taps_api/reference.rb', line 7
def locations(level)
uri = self.class.base_uri + '/locations'
@results = self.class.get uri, { query: auth_token_hash.merge({ level: level }) }
begin
parsed_response = ThreeTapsAPI.rec_hash_to_openstruct @results.parsed_response
@reference = parsed_response.send "#{level.to_s}" if parsed_response.success
rescue TypeError
p "ThreeTapsAPI::Reference.locations #{level.to_s}: rec_hash_to_openstruct not passed a hash"
end
end
|