Class: InvisibleCollector::Resources::SmsResource
- Inherits:
-
Object
- Object
- InvisibleCollector::Resources::SmsResource
show all
- Includes:
- DefaultHandlers
- Defined in:
- lib/invisible_collector/resources/sms_resource.rb
Instance Method Summary
collapse
#execute, #execute_get, #execute_post, #handle, #handles
Constructor Details
#initialize(options = {}) ⇒ SmsResource
8
9
10
11
12
13
14
15
|
# File 'lib/invisible_collector/resources/sms_resource.rb', line 8
def initialize(options = {})
super(options)
handle(400) { |response| raise InvisibleCollector::InvalidRequest.from_json(response.body) }
handle(403) { |response| raise InvisibleCollector::Forbidden.from_json(response.body) }
handle(404) { |response| raise InvisibleCollector::NotFound.from_json(response.body) }
handle(409) { |response| raise InvisibleCollector::InvalidRequest.from_json(response.body) }
handle(422) { |response| raise InvisibleCollector::InvalidRequest.from_json(response.body) }
end
|
Instance Method Details
#get(id, attrs = {}) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/invisible_collector/resources/sms_resource.rb', line 17
def get(id, attrs = {})
response = @connection.get("sms/#{id}", attrs)
if response.status == 404
nil
else
build_response(response)
end
end
|
#save(sms) ⇒ Object
26
27
28
29
|
# File 'lib/invisible_collector/resources/sms_resource.rb', line 26
def save(sms)
response = execute_post('sms', sms)
build_list_response(response)
end
|