class EasyPost::Services::Report
Public Instance Methods
Source
# File lib/easypost/services/report.rb, line 27 def all(params = {}) unless params[:type] raise ArgumentError, "Missing 'type' parameter in params" # TODO: replace the error in the error-handling overhaul PR end type = params.delete(:type) filters = { key: 'reports', type: type, } url = "reports/#{type}" response = get_all_helper(url, MODEL_CLASS, params, filters) response.define_singleton_method(:type) { type } response end
Retrieve all Report
objects
Source
# File lib/easypost/services/report.rb, line 7 def create(params = {}) unless params[:type] raise ArgumentError, "Missing 'type' parameter in params" # TODO: replace the error in the error-handling overhaul PR end type = params.delete(:type) url = "reports/#{type}" response = @client.make_request(:post, url, params) EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end
Create a Report
Source
# File lib/easypost/services/report.rb, line 45 def get_next_page(collection, page_size = nil) raise EasyPost::Errors::EndOfPaginationError.new unless more_pages?(collection) params = { before_id: collection.reports.last.id } params[:page_size] = page_size unless page_size.nil? params.merge!(collection[EasyPost::InternalUtilities::Constants::FILTERS_KEY]).delete(:key) all(params) end
Get next page of Report
objects
Source
# File lib/easypost/services/report.rb, line 20 def retrieve(id) response = @client.make_request(:get, "reports/#{id}") EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS) end
Retrieve a Report