Module: ChartMogul::API::Actions::Retrieve::ClassMethods

Defined in:
lib/chartmogul/api/actions/retrieve.rb

Instance Method Summary collapse

Instance Method Details

#retrieve(uuid, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chartmogul/api/actions/retrieve.rb', line 12

def retrieve(uuid, options = {})
  path = "#{resource_path.apply(options)}/#{uuid}"
  path_param_keys = resource_path.named_params.values
  query_params = options.reject { |key| path_param_keys.include?(key) }
  resp = handling_errors do
    connection.get(path) do |req|
      req.headers['Content-Type'] = 'application/json'
      req.params = query_params
    end
  end
  json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: immutable_keys)
  new_from_json(json)
end