Class: Wiq::Commands::Prospects
- Defined in:
- lib/wiq/commands/prospects.rb
Constant Summary collapse
- STAGES =
%w[inquiry trial_scheduled trialing trial_complete converted didnt_join archived].freeze
- ATTENTION_MODES =
%w[needs_attention handled].freeze
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#list ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/wiq/commands/prospects.rb', line 52 def list params = { "per_page" => 50 } if [:query] params["query"] = [:query] else params["attention_mode"] = [:attention] if [:attention] params["stage"] = [:stage] if [:stage] if [:assigned_to_me] params["assigned_to"] = "me" elsif [:assigned_coach] params["assigned_coach_id"] = [:assigned_coach] end end records, total = fetch_index("/api/v1/prospects", params, key: "prospects") render_index(records, total: total, summary: "Listed #{records.size} prospects.", breadcrumbs: ) end |
#show(id) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/wiq/commands/prospects.rb', line 83 def show(id) prospect = client.get("/api/v1/prospects/#{id}") render(prospect, summary: "Prospect #{prospect["id"]} — #{prospect["child_first_name"]} #{prospect["child_last_name"]} (stage=#{prospect["stage"]}).", breadcrumbs: [ { "cmd" => "wiq prospect_families show #{prospect["prospect_family_id"]}", "description" => "Family this prospect belongs to" }, { "cmd" => "wiq prospect_families notes #{prospect["prospect_family_id"]}", "description" => "Contact log for the family" } ]) end |
#summary ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/wiq/commands/prospects.rb', line 119 def summary params = {} if [:start_date] && [:end_date] params["start_date"] = [:start_date] params["end_date"] = [:end_date] elsif [:start_date] || [:end_date] raise Wiq::Error.new("--start-date and --end-date must be passed together.", code: "missing_cohort_dates") end params["conversion_days"] = [:conversion_days] if [:conversion_days] data = client.get("/api/v1/prospects/summary", params) render(data, summary: "Prospect pipeline: #{data["needs_action_count"]} need action, " \ "#{data["active_trials_count"]} active trials, " \ "conversion=#{data["conversion_rate"]}%.", breadcrumbs: [ { "cmd" => "wiq prospects list --attention needs_attention", "description" => "Drill into leads needing action" }, { "cmd" => "wiq prospect_families list --sort oldest_followup", "description" => "Queue of families ordered by stalest follow-up" } ]) end |