Module: FreshdeskAPI::Read
- Included in:
- Resource
- Defined in:
- lib/freshdesk_api/actions.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#find(client, options = {}, &block) ⇒ Object
Finds, returning nil if it fails.
-
#find!(client, options = {}) ⇒ Object
Finds a resource by an id and any options passed in.
Class Method Details
.extended(klass) ⇒ Object
13 14 15 |
# File 'lib/freshdesk_api/actions.rb', line 13 def self.extended(klass) klass.send(:include, ResponseHandler) end |
Instance Method Details
#find(client, options = {}, &block) ⇒ Object
Finds, returning nil if it fails
35 36 37 38 39 |
# File 'lib/freshdesk_api/actions.rb', line 35 def find(client, = {}, &block) find!(client, , &block) rescue FreshdeskAPI::Error::ClientError => e nil end |
#find!(client, options = {}) ⇒ Object
Finds a resource by an id and any options passed in
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/freshdesk_api/actions.rb', line 20 def find!(client, = {}) @client = client # so we can use client.logger in rescue raise ArgumentError, 'No :id given' unless [:id] path = api_url() + "/#{[:id]}" response = client.make_request!(path, :get) new(@client).tap do |resource| resource.attributes.merge!() resource.handle_response(response) end end |