Class: V1::SubjectsController

Inherits:
ApiController
  • Object
show all
Defined in:
api/app/api/v1/subjects_controller.rb

Overview

Manage Subjects

Constant Summary collapse

SUBJECT_PARAMS =
%i[head_of_household code preferred_language contact_exclusion_until_date
first_name last_name middle_initial email date_of_birth
phone mobile_phone work_phone notes onboarding_completed_at minor_entry_completed_at
archived_at cid].freeze
FILTER_PARAMS =
[:recruiting_campaign_id, :slice,
:only_quota_qualified,
:search_term, :page, :per, :order_by, :order_dir,
:include_archived, :interaction_rating_threshold, :call_eligible,
:blast_eligible, :opt_outs, :recruiting_blast_id,
:participated, :participated_after, :participated_before,
:date_part, :min_age, :max_age,
:adult_with_minor_date_part, :adult_with_minor_min_age, :adult_with_minor_max_age,
:created_after, :created_before, :has_account,
:consented, :can_call, :can_email,
{ selected_subjects: [], languages: [], location_ids: [], demographic_ids: [], selected_outcomes: [], adult_with_minor_demographic_ids: [] }].freeze

Instance Method Summary collapse

Instance Method Details

#createHash<string, V1::SubjectSerializer>

Create a subject This endpoint allows creation of a subject.

Households

All subjects must have a household, but households can be completely blank. Households with a subject must be provided for children.

Example: Create a subject

  curl --request POST \
    --header "authorization: Bearer $bearer_token" \
    --header "Content-Type: application/json" \
    --data '{
              "code": "P5PG",
              "date_of_birth": "19800101",
              "demographic_ids": [5505, 17837],
              "email": "pan@hotmail.com",
              "first_name": "Pan",
              "head_of_household": true,
              "household": {
                "address": "751 Hope St.",
                "city": "Nederland",
                "country": "US",
                "state": "CO",
                "address": "751 Hope St.",
                "zip": "80466"
              },
              "last_name": "Gillicutty",
              "location_ids": [],
              "middle_initial": "Mc",
              "phone": "4901021011"
            }' \
    https://app.redjade.net/api/v1/subjects/

Returns:

See Also:

#destroyHash<string, V1::SubjectSerializer>

Destroy a subject

Returns:

#exportHash<String, Document>

Export subjects into an excel document

Returns:

#export_paramsObject

#filter_paramsObject

#searchHash<String, Array<V1::SubjectSqlSerializer>>

Search subjects. Unfortunately this one is still a POST because of constraints of a clientside library we used at the time of writing this end point.

Options

  • [Integer] recruiting_campaign_id limits the scope of the query to a specific campaign
    • [String] slice (optional)
      • rank or null - anything in ranked for a given campaign
        • [Integer] recruiting_blast_id modifier - apply a particular recruiting blast's filter
      • scheduled - All subjects that were scheduled
      • qualified - have subject interactions of alternate, qualified_accepted, schedule_conflict
        • [Boolean] only_quota_qualified ensures at least one subject demographic matching a quota
      • terminated - failed the screener
      • unconfirmed - returns subjects who have been unscheduled. When a session moves, people get assigned an unscheduled subject interaction for participants scheduled to that session. So they were once scheduled, but are now tentatively "unconfirmed" until someone contacts them and schedules them again.
      • contacted - anyone interacted with for this campaign
      • ineligible - not qualified, not scheduled not in ranking
  • [Array] selected_subjects a list of subject id

Example: Search for all subjects scheduled to a recruiting campaign

  recruiting_campaign_id=123
  slice=rank
  curl --request POST \
    --header "authorization: Bearer $bearer_token" \
    --header "Content-Type: application/json" \
    --data "{\"recruiting_campaign_id\": $recruiting_campaign_id, \"slice\": $slice }" \
    http://localhost:8083/v1/subjects/search

Returns:

#send_email_paramsObject

#showHash<string, V1::SubjectSerializer>

Get one subject

  curl --request GET \
    --header "authorization: Bearer $bearer_token" \
    https://app.redjade.net/api/v1/subjects/1

Returns:

#updateHash<string, V1::SubjectSerializer>

Update a subject

Returns:

See Also: