Class: Smtpcom::Sendapi::ApiResource
- Inherits:
-
Object
- Object
- Smtpcom::Sendapi::ApiResource
show all
- Includes:
- Request
- Defined in:
- lib/smtpcom/sendapi/api_resource.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Request
included
Constructor Details
#initialize(attrs = {}) ⇒ ApiResource
Returns a new instance of ApiResource.
6
7
8
9
10
|
# File 'lib/smtpcom/sendapi/api_resource.rb', line 6
def initialize(attrs = {})
self.class::MAPPINGS.keys.each do |k|
instance_variable_set("@#{k}", attrs[k]) if attrs.key? k
end
end
|
Class Method Details
.build_from_response(data) ⇒ Object
12
13
14
|
# File 'lib/smtpcom/sendapi/api_resource.rb', line 12
def self.build_from_response(data)
new Hash[self::MAPPINGS.map { |k, v| [k.to_sym, data[v.to_s]] }] if data
end
|
Instance Method Details
#_get(*attrs) ⇒ Object
16
17
18
|
# File 'lib/smtpcom/sendapi/api_resource.rb', line 16
def _get(*attrs)
self.class._get(*attrs)
end
|
#_get_raw(*attrs) ⇒ Object
20
21
22
|
# File 'lib/smtpcom/sendapi/api_resource.rb', line 20
def _get_raw(*attrs)
self.class._get_raw(*attrs)
end
|
#_post(*attrs) ⇒ Object
24
25
26
|
# File 'lib/smtpcom/sendapi/api_resource.rb', line 24
def _post(*attrs)
self.class._post(*attrs)
end
|
#prepare_params ⇒ Object
28
29
30
|
# File 'lib/smtpcom/sendapi/api_resource.rb', line 28
def prepare_params
Hash[self.class::MAPPINGS.map { |k, v| [v, instance_variable_get("@#{k}")] }]
end
|