Class: EasyPost::Services::ScanForm

Inherits:
Service
  • Object
show all
Defined in:
lib/easypost/services/scan_form.rb

Constant Summary collapse

MODEL_CLASS =
EasyPost::Models::ScanForm

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from EasyPost::Services::Service

Instance Method Details

#all(params = {}) ⇒ Object

Retrieve a list of ScanForms



21
22
23
24
25
# File 'lib/easypost/services/scan_form.rb', line 21

def all(params = {})
  filters = { key: 'scan_forms' }

  get_all_helper('scan_forms', MODEL_CLASS, params, filters)
end

#create(params = {}) ⇒ Object

Create a ScanForm.



7
8
9
10
11
# File 'lib/easypost/services/scan_form.rb', line 7

def create(params = {})
  response = @client.make_request(:post, 'scan_forms', params)

  EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
end

#get_next_page(collection, page_size = nil) ⇒ Object

Get the next page of ScanForms.



28
29
30
31
32
33
34
35
# File 'lib/easypost/services/scan_form.rb', line 28

def get_next_page(collection, page_size = nil)
  raise EasyPost::Errors::EndOfPaginationError.new unless more_pages?(collection)

  params = { before_id: collection.scan_forms.last.id }
  params[:page_size] = page_size unless page_size.nil?

  all(params)
end

#retrieve(id) ⇒ Object

Retrieve a ScanForm.



14
15
16
17
18
# File 'lib/easypost/services/scan_form.rb', line 14

def retrieve(id)
  response = @client.make_request(:get, "scan_forms/#{id}")

  EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
end