Class: Sendly::BusinessUpgradeResource
- Inherits:
-
Object
- Object
- Sendly::BusinessUpgradeResource
- Defined in:
- lib/sendly/business_upgrade_resource.rb
Overview
Business Upgrade resource — Entity-Upgrade (“fork-with-new-number”)
Manages the toll-free business entity upgrade flow: when a customer forms a new legal entity (e.g. an LLC), this resource lets them reserve a new toll-free number under the new entity, submit it for carrier review, and atomically swap to it on approval — without disrupting outbound SMS during the 1-2 week review window.
Constant Summary collapse
- ENTITY_TYPES =
Entity types accepted by the carrier
%w[ SOLE_PROPRIETOR PRIVATE_PROFIT PUBLIC_PROFIT NON_PROFIT GOVERNMENT ].freeze
- BRN_TYPES =
Business Registration Number types
%w[EIN SSN DUNS CRA VAT LEI OTHER].freeze
- DISPOSITIONS =
Disposition options for the old toll-free number after approval
%w[moved released].freeze
Instance Method Summary collapse
-
#best_prefill ⇒ Hash
Get a “best-of” prefill across all the caller’s verified workspaces.
-
#cancel(workspace_id) ⇒ Hash
Cancel a pending entity upgrade for the given workspace.
-
#initialize(client) ⇒ BusinessUpgradeResource
constructor
A new instance of BusinessUpgradeResource.
-
#preflight(business_name: nil, brn: nil, brn_type: nil, brn_country: nil, entity_type: nil, doing_business_as: nil, website: nil, address1: nil, address2: nil, city: nil, state: nil, zip: nil, address_country: nil, contact_first_name: nil, contact_last_name: nil, contact_email: nil, contact_phone: nil, monthly_volume: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, privacy_url: nil, terms_url: nil, additional_information: nil, age_gated_content: nil) ⇒ Hash
Validate a candidate entity upgrade payload before submission.
-
#resubmit(workspace_id, business_name: nil, brn: nil, brn_type: nil, brn_country: nil, entity_type: nil, doing_business_as: nil, website: nil, address1: nil, address2: nil, city: nil, state: nil, zip: nil, address_country: nil, contact_first_name: nil, contact_last_name: nil, contact_email: nil, contact_phone: nil, monthly_volume: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, privacy_url: nil, terms_url: nil, additional_information: nil, age_gated_content: nil, ein_doc_path: nil, ein_doc: nil, ein_doc_filename: nil, ein_doc_content_type: nil) ⇒ Hash
Resubmit a rejected (or waiting-for-customer) entity upgrade with updated fields and optionally a new EIN document.
-
#set_disposition(workspace_id, disposition:, target_workspace_id: nil) ⇒ Hash
After a successful entity-upgrade approval, choose what happens to the old toll-free number:.
-
#start(workspace_id, business_name:, brn:, brn_type:, brn_country:, entity_type:, doing_business_as: nil, website: nil, address1: nil, address2: nil, city: nil, state: nil, zip: nil, address_country: nil, contact_first_name: nil, contact_last_name: nil, contact_email: nil, contact_phone: nil, monthly_volume: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, privacy_url: nil, terms_url: nil, additional_information: nil, age_gated_content: nil, ein_doc_path: nil, ein_doc: nil, ein_doc_filename: nil, ein_doc_content_type: nil) ⇒ Hash
Start an entity upgrade for the given workspace.
-
#status(workspace_id) ⇒ Hash
Check whether the given workspace has a pending entity upgrade.
Constructor Details
#initialize(client) ⇒ BusinessUpgradeResource
Returns a new instance of BusinessUpgradeResource.
54 55 56 |
# File 'lib/sendly/business_upgrade_resource.rb', line 54 def initialize(client) @client = client end |
Instance Method Details
#best_prefill ⇒ Hash
Get a “best-of” prefill across all the caller’s verified workspaces. Returns most-recent non-empty values per messaging field. Use this to pre-populate the upgrade form for users whose current workspace has incomplete data.
126 127 128 |
# File 'lib/sendly/business_upgrade_resource.rb', line 126 def best_prefill @client.get("/verification/best-prefill") end |
#cancel(workspace_id) ⇒ Hash
Cancel a pending entity upgrade for the given workspace. Releases the reserved toll-free number, deletes the new messaging profile, and removes the stored EIN document. Idempotent.
208 209 210 211 212 |
# File 'lib/sendly/business_upgrade_resource.rb', line 208 def cancel(workspace_id) raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty? @client.post("/workspaces/#{url_escape(workspace_id)}/upgrade/cancel", {}) end |
#preflight(business_name: nil, brn: nil, brn_type: nil, brn_country: nil, entity_type: nil, doing_business_as: nil, website: nil, address1: nil, address2: nil, city: nil, state: nil, zip: nil, address_country: nil, contact_first_name: nil, contact_last_name: nil, contact_email: nil, contact_phone: nil, monthly_volume: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, privacy_url: nil, terms_url: nil, additional_information: nil, age_gated_content: nil) ⇒ Hash
Validate a candidate entity upgrade payload before submission. Returns issues + proposed auto-fixes. No writes — purely advisory.
Accepts the same fields as start. Returns a hash with verdict (+“ready”+, “warnings”, “blocked”), issues, and proposedFixes.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/sendly/business_upgrade_resource.rb', line 92 def preflight(business_name: nil, brn: nil, brn_type: nil, brn_country: nil, entity_type: nil, doing_business_as: nil, website: nil, address1: nil, address2: nil, city: nil, state: nil, zip: nil, address_country: nil, contact_first_name: nil, contact_last_name: nil, contact_email: nil, contact_phone: nil, monthly_volume: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, privacy_url: nil, terms_url: nil, additional_information: nil, age_gated_content: nil) body = build_upgrade_body( business_name: business_name, brn: brn, brn_type: brn_type, brn_country: brn_country, entity_type: entity_type, doing_business_as: doing_business_as, website: website, address1: address1, address2: address2, city: city, state: state, zip: zip, address_country: address_country, contact_first_name: contact_first_name, contact_last_name: contact_last_name, contact_email: contact_email, contact_phone: contact_phone, monthly_volume: monthly_volume, use_case: use_case, use_case_summary: use_case_summary, sample_messages: , opt_in_workflow: opt_in_workflow, privacy_url: privacy_url, terms_url: terms_url, additional_information: additional_information, age_gated_content: age_gated_content ) @client.post("/verification/preflight", body) end |
#resubmit(workspace_id, business_name: nil, brn: nil, brn_type: nil, brn_country: nil, entity_type: nil, doing_business_as: nil, website: nil, address1: nil, address2: nil, city: nil, state: nil, zip: nil, address_country: nil, contact_first_name: nil, contact_last_name: nil, contact_email: nil, contact_phone: nil, monthly_volume: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, privacy_url: nil, terms_url: nil, additional_information: nil, age_gated_content: nil, ein_doc_path: nil, ein_doc: nil, ein_doc_filename: nil, ein_doc_content_type: nil) ⇒ Hash
Resubmit a rejected (or waiting-for-customer) entity upgrade with updated fields and optionally a new EIN document. All fields are optional — only the ones you pass are sent.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/sendly/business_upgrade_resource.rb', line 220 def resubmit(workspace_id, business_name: nil, brn: nil, brn_type: nil, brn_country: nil, entity_type: nil, doing_business_as: nil, website: nil, address1: nil, address2: nil, city: nil, state: nil, zip: nil, address_country: nil, contact_first_name: nil, contact_last_name: nil, contact_email: nil, contact_phone: nil, monthly_volume: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, privacy_url: nil, terms_url: nil, additional_information: nil, age_gated_content: nil, ein_doc_path: nil, ein_doc: nil, ein_doc_filename: nil, ein_doc_content_type: nil) raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty? fields = build_upgrade_body( business_name: business_name, brn: brn, brn_type: brn_type, brn_country: brn_country, entity_type: entity_type, doing_business_as: doing_business_as, website: website, address1: address1, address2: address2, city: city, state: state, zip: zip, address_country: address_country, contact_first_name: contact_first_name, contact_last_name: contact_last_name, contact_email: contact_email, contact_phone: contact_phone, monthly_volume: monthly_volume, use_case: use_case, use_case_summary: use_case_summary, sample_messages: , opt_in_workflow: opt_in_workflow, privacy_url: privacy_url, terms_url: terms_url, additional_information: additional_information, age_gated_content: age_gated_content ) post_multipart_with_fields( "/workspaces/#{url_escape(workspace_id)}/upgrade/resubmit", fields, ein_doc_path: ein_doc_path, ein_doc: ein_doc, ein_doc_filename: ein_doc_filename, ein_doc_content_type: ein_doc_content_type ) end |
#set_disposition(workspace_id, disposition:, target_workspace_id: nil) ⇒ Hash
After a successful entity-upgrade approval, choose what happens to the old toll-free number:
-
“moved”: keep it active under another workspace owned by the same user (requires
target_workspace_id) -
“released”: return it to the carrier pool
270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/sendly/business_upgrade_resource.rb', line 270 def set_disposition(workspace_id, disposition:, target_workspace_id: nil) raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty? unless DISPOSITIONS.include?(disposition) raise ArgumentError, "disposition must be one of: #{DISPOSITIONS.join(", ")}" end if disposition == "moved" && (target_workspace_id.nil? || target_workspace_id.empty?) raise ArgumentError, "target_workspace_id is required when disposition is 'moved'" end body = { disposition: disposition } body[:targetOrgId] = target_workspace_id if target_workspace_id @client.post("/workspaces/#{url_escape(workspace_id)}/upgrade/disposition", body) end |
#start(workspace_id, business_name:, brn:, brn_type:, brn_country:, entity_type:, doing_business_as: nil, website: nil, address1: nil, address2: nil, city: nil, state: nil, zip: nil, address_country: nil, contact_first_name: nil, contact_last_name: nil, contact_email: nil, contact_phone: nil, monthly_volume: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, privacy_url: nil, terms_url: nil, additional_information: nil, age_gated_content: nil, ein_doc_path: nil, ein_doc: nil, ein_doc_filename: nil, ein_doc_content_type: nil) ⇒ Hash
Start an entity upgrade for the given workspace. Auto-provisions a new toll-free number + messaging profile and submits to the carrier for review. Returns the pending verification details.
The current toll-free number continues sending throughout the 1-2 week carrier review; on approval, an atomic swap promotes the new number.
The EIN document (when supplied) is uploaded as multipart form-data under the einDoc field. Provide either ein_doc_path (a path on disk) or ein_doc (raw bytes / IO) — not both.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/sendly/business_upgrade_resource.rb', line 153 def start(workspace_id, business_name:, brn:, brn_type:, brn_country:, entity_type:, doing_business_as: nil, website: nil, address1: nil, address2: nil, city: nil, state: nil, zip: nil, address_country: nil, contact_first_name: nil, contact_last_name: nil, contact_email: nil, contact_phone: nil, monthly_volume: nil, use_case: nil, use_case_summary: nil, sample_messages: nil, opt_in_workflow: nil, privacy_url: nil, terms_url: nil, additional_information: nil, age_gated_content: nil, ein_doc_path: nil, ein_doc: nil, ein_doc_filename: nil, ein_doc_content_type: nil) raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty? fields = build_upgrade_body( business_name: business_name, brn: brn, brn_type: brn_type, brn_country: brn_country, entity_type: entity_type, doing_business_as: doing_business_as, website: website, address1: address1, address2: address2, city: city, state: state, zip: zip, address_country: address_country, contact_first_name: contact_first_name, contact_last_name: contact_last_name, contact_email: contact_email, contact_phone: contact_phone, monthly_volume: monthly_volume, use_case: use_case, use_case_summary: use_case_summary, sample_messages: , opt_in_workflow: opt_in_workflow, privacy_url: privacy_url, terms_url: terms_url, additional_information: additional_information, age_gated_content: age_gated_content ) post_multipart_with_fields( "/workspaces/#{url_escape(workspace_id)}/upgrade", fields, ein_doc_path: ein_doc_path, ein_doc: ein_doc, ein_doc_filename: ein_doc_filename, ein_doc_content_type: ein_doc_content_type ) end |
#status(workspace_id) ⇒ Hash
Check whether the given workspace has a pending entity upgrade. Returns { “pending” => nil } when no upgrade is in flight.
196 197 198 199 200 |
# File 'lib/sendly/business_upgrade_resource.rb', line 196 def status(workspace_id) raise ArgumentError, "Workspace ID is required" if workspace_id.nil? || workspace_id.empty? @client.get("/workspaces/#{url_escape(workspace_id)}/upgrade/status") end |