Class: SendleAPI::Base
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- SendleAPI::Base
show all
- Defined in:
- lib/sendle_api/resources/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}, persisted = false) ⇒ Base
Returns a new instance of Base.
12
13
14
15
16
17
|
# File 'lib/sendle_api/resources/base.rb', line 12
def initialize(attributes = {}, persisted = false)
if defined?(self.class::DEFAULT_ATTRS)
attributes = self.class::DEFAULT_ATTRS.merge(attributes)
end
super
end
|
Class Method Details
.basic_auth_details ⇒ Object
.set_site ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/sendle_api/resources/base.rb', line 45
def set_site
self.site = if SendleAPI.config.testing?
"https://#{basic_auth_details}@sandbox.sendle.com"
else
"https://#{basic_auth_details}@api.sendle.com"
end
end
|
.validate_configs ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/sendle_api/resources/base.rb', line 57
def validate_configs
unless SendleAPI.config.sendle_id
raise ArgumentError, "SendleAPI sendle_id is missing, please set it in the config and restart."
end
unless SendleAPI.config.api_key
raise ArgumentError, "SendleAPI api_key is missing, please set it in the config and restart."
end
end
|
Instance Method Details
#errors ⇒ Object
24
25
26
|
# File 'lib/sendle_api/resources/base.rb', line 24
def errors
@errors ||= Errors.new(self)
end
|
#save ⇒ Object
19
20
21
22
|
# File 'lib/sendle_api/resources/base.rb', line 19
def save
self.class.validate_configs
super
end
|