class BaseCRM::VisitOutcomesService

Public Class Methods

new(client) click to toggle source
# File lib/basecrm/services/visit_outcomes_service.rb, line 5
def initialize(client)
  @client = client
end

Public Instance Methods

all() click to toggle source

Retrieve visit outcomes

get '/visit_outcomes'

If you want to use filtering or sorting (see where). @return [Enumerable] Paginated resource you can use to iterate over all the resources.

# File lib/basecrm/services/visit_outcomes_service.rb, line 15
def all
  PaginatedResource.new(self)
end
where(options = {}) click to toggle source

Retrieve visit outcomes

get '/visit_outcomes'

Returns Visit Outcomes, according to the parameters provided

@param options [Hash] Search options @option options [Integer] :page (1) Page number to start from. Page numbering starts at 1, and omitting the `page` parameter will return the first page. @option options [Integer] :per_page (25) Number of records to return per page. The default limit is 25 and the maximum number that can be returned at one time is 100. @return [Array<VisitOutcome>] The list of VisitOutcomes for the first page, unless otherwise specified.

# File lib/basecrm/services/visit_outcomes_service.rb, line 29
def where(options = {})
  _, _, root = @client.get("/visit_outcomes", options)

  root[:items].map{ |item| VisitOutcome.new(item[:data]) }
end

Private Instance Methods

extract_params!(visit_outcome, *args) click to toggle source
# File lib/basecrm/services/visit_outcomes_service.rb, line 41
def extract_params!(visit_outcome, *args)
  params = visit_outcome.to_h.select{ |k, _| args.include?(k) }
  raise ArgumentError, "one of required attributes is missing. Expected: #{args.join(',')}" if params.count != args.length
  params
end
validate_type!(visit_outcome) click to toggle source
# File lib/basecrm/services/visit_outcomes_service.rb, line 37
def validate_type!(visit_outcome)
  raise TypeError unless visit_outcome.is_a?(VisitOutcome) || visit_outcome.is_a?(Hash)
end