Class: Fountain::Papi::Applicant::CreateStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/fountain/papi/applicant/create_status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ CreateStatus

Returns a new instance of CreateStatus.



13
14
15
# File 'lib/fountain/papi/applicant/create_status.rb', line 13

def initialize(params)
  @status = Fountain::Papi::Applicant::Status.new(params)
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



11
12
13
# File 'lib/fountain/papi/applicant/create_status.rb', line 11

def status
  @status
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fountain/papi/applicant/create_status.rb', line 17

def call
  uri = Fountain::Papi.config.base_uri(override_partner_id: status.partner_id)
  response = Client.post(
    "#{uri}/applicants/#{status.applicant_id}/status",
    body: { applicant: { partner_status: status } }.to_json,
    headers: Fountain::Papi.config.headers
  )

  raise Fountain::Papi::Error, response unless response.success?

  created_status(response)
end

#created_status(response) ⇒ Object



30
31
32
33
34
35
# File 'lib/fountain/papi/applicant/create_status.rb', line 30

def created_status(response)
  result_status = response["partner_status"]
                  .merge(applicant_id: status.applicant_id)

  Fountain::Papi::Applicant::Status.new(result_status)
end