Skip to content

ha number feature#371

Merged
Narayana Shanbhog Plivo (narayana-plivo) merged 2 commits intomasterfrom
ha-number
Jan 21, 2026
Merged

ha number feature#371
Narayana Shanbhog Plivo (narayana-plivo) merged 2 commits intomasterfrom
ha-number

Conversation

@narayana-plivo
Copy link
Copy Markdown
Contributor

@narayana-plivo Narayana Shanbhog Plivo (narayana-plivo) commented Jan 21, 2026

Summary by CodeRabbit

  • New Features

    • Optional haEnabled parameter added to phone number purchase flows
    • fallbackNumber field added to phone number purchase responses
  • Chores

    • Version bumped to v4.75.6

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

Adds an optional haEnable parameter to phone number purchase methods, includes ha_enable in request payloads, exposes a new fallbackNumber field on BuyNumberResponse, and bumps package version to 4.75.6.

Changes

Cohort / File(s) Summary
Version & Changelog
CHANGELOG.md, package.json
Bumped version to v4.75.6 and added changelog entry describing haEnable parameter and fallbackNumber field.
Phone Number API Implementation
lib/resources/numbers.js
Extended buy method signatures (PhoneNumber.buy, PhoneNumberInterface.buy, NumberInterface.buy) to accept haEnable; include ha_enable in request payload when provided; added fallbackNumber to BuyNumberResponse constructor.
Type Definitions
types/resources/numbers.d.ts
Added fallbackNumber?: string to BuyNumberResponse; updated constructors and buy-related method signatures to include cnamLookup?: string and haEnable?: boolean; normalized several Promise return type spacings/formatting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibbled the code, added a flag so neat,
haEnable hopped in, making purchases complete,
fallbackNumber tucked in, safe and bright,
Version bumped — I bound home in delight,
Tail twitching, I celebrate this tiny feat.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'ha number feature' is vague and generic, using an undefined abbreviation ('ha') without clear context about what feature is being added. Revise the title to be more descriptive, e.g., 'Add haEnable parameter and fallbackNumber field to phone number buying' to clearly convey the main changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
types/resources/numbers.d.ts (1)

1-7: Make fallbackNumber optional in BuyNumberResponse.

The runtime code assigns it directly from the API response without validation, meaning it can be undefined if not present. The TypeScript type should reflect this possibility:

Suggested change
export class BuyNumberResponse {
	constructor(params: object);
	apiId: string;
	numbers: object;
	status: string;
-	fallbackNumber: string;
+	fallbackNumber?: string;
}
🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Around line 2-5: Replace the bolded feature descriptor "**Feature - HA Number
support**" with a proper markdown heading (e.g., "### Feature - HA Number
support" or the project's existing changelog heading level) so it is not treated
as emphasis-as-heading (MD036); update the line in CHANGELOG.md where the
feature block appears and keep the rest of the list items unchanged.

In `@types/resources/numbers.d.ts`:
- Around line 46-55: The TypeScript declaration for PhoneNumber.buy is missing
the mandatory leading phone number parameter; update the signature in the
numbers.d.ts declaration for PhoneNumber.buy to include the first parameter
(e.g., phoneNumber: string) and make it required so it matches the runtime and
the other interfaces (PhoneNumberInterface.buy and NumberInterface.buy),
preserving the existing cnamLookup?: string and haEnabled?: boolean and
returning Promise<any>.

Comment thread CHANGELOG.md
Comment on lines +2 to +5
## [v4.75.6](https://github.com/plivo/plivo-node/tree/v4.75.6) (2026-01-21)
**Feature - HA Number support**
- Added `haEnabled` optional parameter to phone number `buy` method
- Added `fallbackNumber` field to `BuyNumberResponse`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use a heading instead of bold text (MD036).
markdownlint flags emphasis-as-heading for the feature line.

🔧 Proposed markdown tweak
-**Feature - HA Number support**
+### Feature - HA Number support
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## [v4.75.6](https://github.com/plivo/plivo-node/tree/v4.75.6) (2026-01-21)
**Feature - HA Number support**
- Added `haEnabled` optional parameter to phone number `buy` method
- Added `fallbackNumber` field to `BuyNumberResponse`
## [v4.75.6](https://github.com/plivo/plivo-node/tree/v4.75.6) (2026-01-21)
### Feature - HA Number support
- Added `haEnabled` optional parameter to phone number `buy` method
- Added `fallbackNumber` field to `BuyNumberResponse`
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

3-3: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🤖 Prompt for AI Agents
In `@CHANGELOG.md` around lines 2 - 5, Replace the bolded feature descriptor
"**Feature - HA Number support**" with a proper markdown heading (e.g., "###
Feature - HA Number support" or the project's existing changelog heading level)
so it is not treated as emphasis-as-heading (MD036); update the line in
CHANGELOG.md where the feature block appears and keep the rest of the list items
unchanged.

Comment thread types/resources/numbers.d.ts
@narayana-plivo Narayana Shanbhog Plivo (narayana-plivo) merged commit 5059498 into master Jan 21, 2026
7 of 18 checks passed
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@types/resources/numbers.d.ts`:
- Line 93: Update the unrent method signatures in types/resources/numbers.d.ts
from Promise<any> to Promise<boolean> to reflect runtime behavior and JSDoc;
locate the two unrent declarations (the one at the earlier occurrence and the
second at the later occurrence) and change their return types to
Promise<boolean> so consumers get correct boolean typing.
- Line 125: The TypeScript declaration for addOwnNumber requires optionalParams
even though runtime uses optionalParams || {}, so update the method signature in
types/resources/numbers.d.ts by making the last parameter optional (change
optionalParams: object to optionalParams?: object) so the typings match runtime
behavior for addOwnNumber.
🧹 Nitpick comments (1)
lib/resources/numbers.js (1)

120-130: Consider preserving explicit false for cnamLookup.
if (cnamLookup) drops false. If the API distinguishes false from “unset,” align with the haEnable check.

♻️ Proposed tweak
-        if (cnamLookup) {
-            params.cnam_lookup = cnamLookup;
-        }
+        if (cnamLookup !== undefined) {
+            params.cnam_lookup = cnamLookup;
+        }

* @fail {Error} return Error
*/
unrent(number: string): Promise < any > ;
unrent(number: string): Promise<any>;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, locate and examine the TypeScript definition file
find . -name "numbers.d.ts" -type f

Repository: plivo/plivo-node

Length of output: 90


🏁 Script executed:

# Once found, check the content around lines 93 and 158
if [ -f "types/resources/numbers.d.ts" ]; then
  echo "=== Line 93 context ===" && sed -n '85,100p' types/resources/numbers.d.ts
  echo ""
  echo "=== Line 158 context ===" && sed -n '150,165p' types/resources/numbers.d.ts
fi

Repository: plivo/plivo-node

Length of output: 827


🏁 Script executed:

# Search for the actual implementation or documentation of unrent
rg -i "unrent" -B 2 -A 5 --type js --type ts

Repository: plivo/plivo-node

Length of output: 9196


Change unrent return type to Promise<boolean> to match runtime behavior and documentation.

The method's JSDoc already specifies @promise {boolean}, the implementation resolves true on success, and tests assert the return value is true. The current Promise<any> type annotation loses this type safety.

Suggested typing fix
-	unrent(number: string): Promise<any>;
+	unrent(number: string): Promise<boolean>;

Also applies to: 158-158

🤖 Prompt for AI Agents
In `@types/resources/numbers.d.ts` at line 93, Update the unrent method signatures
in types/resources/numbers.d.ts from Promise<any> to Promise<boolean> to reflect
runtime behavior and JSDoc; locate the two unrent declarations (the one at the
earlier occurrence and the second at the later occurrence) and change their
return types to Promise<boolean> so consumers get correct boolean typing.

* @fail {Error} return Error
*/
addOwnNumber(numbers: string, carrier: string, region: string, optionalParams: object): Promise < UpdateNumberResponse > ;
addOwnNumber(numbers: string, carrier: string, region: string, optionalParams: object): Promise<UpdateNumberResponse>;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Locate the types file and read relevant lines
find . -name "numbers.d.ts" -type f

Repository: plivo/plivo-node

Length of output: 90


🏁 Script executed:

# Also search for the implementation to understand runtime behavior
find . -name "*.js" -o -name "*.ts" | grep -E "(numbers|resources)" | grep -v "\.d\.ts" | head -20

Repository: plivo/plivo-node

Length of output: 681


🏁 Script executed:

# Search more specifically for numbers implementation
find . -path "*/lib/resources/numbers.js" -o -path "*/resources/numbers.js" | grep -v ".d.ts"

Repository: plivo/plivo-node

Length of output: 86


🏁 Script executed:

# Read the types file to see current state
cat -n ./types/resources/numbers.d.ts

Repository: plivo/plivo-node

Length of output: 6237


🏁 Script executed:

# Read the implementation to verify runtime behavior
cat -n ./lib/resources/numbers.js | head -300

Repository: plivo/plivo-node

Length of output: 10988


🏁 Script executed:

# Continue reading to see the search and update methods
cat -n ./lib/resources/numbers.js | tail -n +300

Repository: plivo/plivo-node

Length of output: 3053


Make optional params truly optional in typings.

Runtime treats these as optional (line 293 uses optionalParams || {}, line 330 uses optionalParams || {}, and update params are conditionally accessed), but the type definitions currently require them. Update the method signatures to match the actual runtime behavior.

🔧 Suggested typing fix
-	addOwnNumber(numbers: string, carrier: string, region: string, optionalParams: object): Promise<UpdateNumberResponse>;
+	addOwnNumber(numbers: string, carrier: string, region: string, optionalParams?: object): Promise<UpdateNumberResponse>;
...
-	search(countryISO: string, optionalParams: object): Promise<SearchNumberResponse[]>;
+	search(countryISO: string, optionalParams?: object): Promise<SearchNumberResponse[]>;
...
-	update(number: string, params: {
-		appId: string;
-		subAccount: string;
-		alias: string;
-	}): Promise<UpdateNumberResponse>;
+	update(number: string, params: {
+		appId?: string;
+		subAccount?: string;
+		alias?: string;
+	}): Promise<UpdateNumberResponse>;
🤖 Prompt for AI Agents
In `@types/resources/numbers.d.ts` at line 125, The TypeScript declaration for
addOwnNumber requires optionalParams even though runtime uses optionalParams ||
{}, so update the method signature in types/resources/numbers.d.ts by making the
last parameter optional (change optionalParams: object to optionalParams?:
object) so the typings match runtime behavior for addOwnNumber.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants