Class: Natero::Base
Constant Summary
collapse
- BASE_URI =
'https://api.natero.com'
- VERSION_URI =
'/api/v2'
- REQUIRED_PARAMS =
[]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#serialize, #to_h, #unserialize
Constructor Details
#initialize(params, raw_response = nil) ⇒ Base
Returns a new instance of Base.
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/natero/base.rb', line 41
def initialize(params, raw_response = nil)
missing_params = REQUIRED_PARAMS - params.keys
raise ArgumentError.new("Missing required params #{missing_params.join(', ')}") unless missing_params.empty?
load_model_properties
clean_params(params)
populate_properties(params)
@raw_response = raw_response
end
|
Instance Attribute Details
#raw_response ⇒ Object
Returns the value of attribute raw_response.
12
13
14
|
# File 'lib/natero/base.rb', line 12
def raw_response
@raw_response
end
|
Class Method Details
.endpoint(*params) ⇒ Object
.endpoint_path ⇒ Object
23
24
25
26
27
|
# File 'lib/natero/base.rb', line 23
def self.endpoint_path
raise NotImplementedError.new( 'This method needs to be overridden in a child class. Proper implementation '\
'should return an array where each index contains a different part of the path. For example: '\
'[\'test\', \'best\'] becomes \'/test/best/\'.' )
end
|
.json_data(body) ⇒ Object
29
30
31
|
# File 'lib/natero/base.rb', line 29
def self.json_data(body)
{ body: body, headers: }
end
|
33
34
35
|
# File 'lib/natero/base.rb', line 33
def self.
{ 'Content-Type': 'application/json' }
end
|
Instance Method Details
#to_json ⇒ Object
52
53
54
|
# File 'lib/natero/base.rb', line 52
def to_json
serialize
end
|