Class: EasyPost::Report
- Inherits:
-
Resource
- Object
- EasyPostObject
- Resource
- EasyPost::Report
- Defined in:
- lib/easypost/report.rb
Instance Attribute Summary
Attributes inherited from EasyPostObject
#api_key, #name, #parent, #unsaved_values
Class Method Summary collapse
- .all(filters = {}, api_key = nil) ⇒ Object
- .create(params = {}, api_key = nil) ⇒ Object
- .retrieve(params, api_key = nil) ⇒ Object
Methods inherited from Resource
class_name, #delete, #refresh, #save, url, #url
Methods inherited from EasyPostObject
#[], #[]=, #as_json, construct_from, #each, #id, #id=, #initialize, #inspect, #keys, #refresh_from, #to_hash, #to_json, #to_s, #values
Constructor Details
This class inherits a constructor from EasyPost::EasyPostObject
Class Method Details
.all(filters = {}, api_key = nil) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/easypost/report.rb', line 24 def self.all(filters={}, api_key=nil) url = "#{self.url}/#{filters[:type]}" response, api_key = EasyPost.request(:get, url, api_key, filters) return EasyPost::Util::convert_to_easypost_object(response, api_key) if response end |
.create(params = {}, api_key = nil) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/easypost/report.rb', line 3 def self.create(params={}, api_key=nil) url = "#{self.url}/#{params[:type]}" wrapped_params = {} wrapped_params[class_name.to_sym] = params response, api_key = EasyPost.request(:post, url, api_key, params) return Util.convert_to_easypost_object(response, api_key) end |
.retrieve(params, api_key = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/easypost/report.rb', line 12 def self.retrieve(params, api_key=nil) id = if params.is_a?(String) params else params[:id] end instance = self.new(id, api_key) instance.refresh return instance end |