Class: Tazworks::Applicant

Inherits:
Model
  • Object
show all
Defined in:
lib/tazworks/applicant.rb

Overview

Tazworks Applicants Model

Instance Attribute Summary

Attributes inherited from Model

#attributes, #attributes_loaded, #ids

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#attributes_loaded?, #clientGuid, find, #initialize, initialize_from_response, #load_attributes, #loaded_attributes, #reload

Constructor Details

This class inherits a constructor from Tazworks::Model

Class Method Details

.all(clientGuid, params = {}) ⇒ Object



30
31
32
33
# File 'lib/tazworks/applicant.rb', line 30

def self.all(clientGuid, params = {})
  raw_response = RestClient.get("/v1/clients/#{clientGuid}/applicants", { params: })
  ApplicantPagedResponse.new(raw_response, { clientGuid: })
end

.create(clientGuid, params) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tazworks/applicant.rb', line 12

def self.create(clientGuid, params)
  required_params = %w[firstName lastName email]
  required_params.each do |rp|
    raise ArgumentError, "#{rp} is missing in params hash." unless params.key?(rp.to_sym)
  end

  response = RestClient.post("/v1/clients/#{clientGuid}/applicants", params)

  applicant = Applicant.initialize_from_response({ clientGuid: }, response)
  applicant.ids[:applicantGuid] = applicant.attributes[:applicantGuid]
  applicant
end

.get(ids) ⇒ Object



7
8
9
# File 'lib/tazworks/applicant.rb', line 7

def self.get(ids)
  RestClient.get("/v1/clients/#{ids[:clientGuid]}/applicants/#{ids[:applicantGuid]}")
end

.submit_order(params) ⇒ Object



25
26
27
# File 'lib/tazworks/applicant.rb', line 25

def self.submit_order(params)
  Tazworks::Order.create(clientGuid, params)
end

Instance Method Details

#applicantGuidObject



35
36
37
# File 'lib/tazworks/applicant.rb', line 35

def applicantGuid
  @ids[:applicantGuid]
end