Class: Wiq::Commands::ProspectFamilies

Inherits:
Base
  • Object
show all
Defined in:
lib/wiq/commands/prospect_families.rb

Constant Summary collapse

SORT_OPTIONS =
%w[newest oldest_followup oldest_contact next_trial].freeze

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?

Instance Method Details

#listObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/wiq/commands/prospect_families.rb', line 53

def list
  params = { "per_page" => 50 }
  if options[:query]
    params["query"] = options[:query]
  else
    params["attention_mode"] = options[:attention] if options[:attention]
    params["stage"] = options[:stage] if options[:stage]
    if options[:assigned_to_me]
      params["assigned_to"] = "me"
    elsif options[:assigned_coach]
      params["assigned_coach_id"] = options[:assigned_coach]
    end
    if options[:question_id] && options[:answer_value]
      params["question_id"] = options[:question_id]
      params["answer_value"] = options[:answer_value]
    elsif options[:question_id] || options[:answer_value]
      raise Wiq::Error.new("--question-id and --answer-value must be passed together.",
                           code: "missing_question_pair")
    end
  end
  params["sort"] = options[:sort] if options[:sort]

  records, total = fetch_index("/api/v1/prospect_families", params, key: "prospect_families")
  render_index(
    records, total: total,
    summary: "Listed #{records.size} prospect families.",
    breadcrumbs: [
      { "cmd" => "wiq prospect_families show <id>", "description" => "Drill into one family" },
      { "cmd" => "wiq prospect_families notes <id>", "description" => "See contact log" },
      { "cmd" => "wiq prospects summary", "description" => "Pipeline dashboard" }
    ]
  )
end

#notes(family_id) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/wiq/commands/prospect_families.rb', line 115

def notes(family_id)
  records, total = fetch_index("/api/v1/prospect_families/#{family_id}/notes",
                               { "per_page" => 50 },
                               key: "notes")
  render_index(
    records, total: total,
    summary: "Listed #{records.size} notes for family #{family_id}.",
    breadcrumbs: [
      { "cmd" => "wiq prospect_families show #{family_id}", "description" => "Back to the family" }
    ]
  )
end

#show(id) ⇒ Object



95
96
97
98
99
100
101
102
103
104
# File 'lib/wiq/commands/prospect_families.rb', line 95

def show(id)
  family = client.get("/api/v1/prospect_families/#{id}")
  render(family,
         summary: "Family #{family["id"]}#{family["contact_name"]} (#{family["prospects"].size} prospects).",
         breadcrumbs: [
           { "cmd" => "wiq prospect_families notes #{family["id"]}",
             "description" => "See contact log for this family" },
           { "cmd" => "wiq prospects show <prospect_id>", "description" => "Drill into one kid" }
         ])
end