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.
11
12
13
14
15
16
|
# File 'lib/sendle_api/resources/base.rb', line 11
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
44
45
46
47
48
49
50
|
# File 'lib/sendle_api/resources/base.rb', line 44
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
56
57
58
59
60
61
62
63
64
|
# File 'lib/sendle_api/resources/base.rb', line 56
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
23
24
25
|
# File 'lib/sendle_api/resources/base.rb', line 23
def errors
@errors ||= Errors.new(self)
end
|
#save ⇒ Object
18
19
20
21
|
# File 'lib/sendle_api/resources/base.rb', line 18
def save
self.class.validate_configs
super
end
|