Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostaway new action #14825

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Hostaway new action #14825

wants to merge 3 commits into from

Conversation

GTFalcao
Copy link
Collaborator

@GTFalcao GTFalcao commented Dec 4, 2024

Closes #14431

Note: I was only able to successfully create a reservation using channel ID 2000, although the API documentation lists all the ones that are available here.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new module for creating reservations in the Hostaway system.
    • Added a new property for channel identification and a method for creating reservations in the Hostaway app.
  • Version Updates

    • Incremented version numbers for various actions and sources to reflect minor updates.
  • New Constants

    • Added a new constant for communication channel options, enhancing the configuration for integrations.

Copy link

vercel bot commented Dec 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Dec 4, 2024 5:35am
pipedream-docs ⬜️ Ignored (Inspect) Dec 4, 2024 5:35am
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Dec 4, 2024 5:35am

Copy link
Contributor

coderabbitai bot commented Dec 4, 2024

Walkthrough

This pull request introduces a new module for creating reservations in the Hostaway system, along with updates to existing modules and constants. Key changes include a new action for reservation creation, updates to version numbers for several existing actions, and modifications to property keys and constants. The overall structure of the components remains intact, with enhancements primarily focused on the reservation creation functionality and version management.

Changes

File Path Change Summary
components/hostaway/actions/create-reservation/create-reservation.mjs New module for creating reservations; includes properties like channelId, listingMapId, etc.
components/hostaway/actions/create-task/create-task.mjs Version updated from "0.0.1" to "0.0.2"; no logic changes.
components/hostaway/actions/send-message-to-guest/send-message-to-guest.mjs Version updated from "0.0.1" to "0.0.2"; no logic changes.
components/hostaway/actions/update-task/update-task.mjs Version updated from "0.0.1" to "0.0.2"; listingId changed to listingMapId in update logic.
components/hostaway/common/constants.mjs New constant CHANNEL_OPTIONS added for communication channels.
components/hostaway/hostaway.app.mjs New property channelId added; new method createReservation added for reservation creation.
components/hostaway/package.json Version updated from "0.1.1" to "0.2.0"; no other changes.
components/hostaway/sources/new-message-received/new-message-received.mjs Version updated from "0.0.2" to "0.0.3"; no logic changes.
components/hostaway/sources/reservation-created/reservation-created.mjs Version updated from "0.0.2" to "0.0.3"; no logic changes.
components/hostaway/sources/reservation-updated/reservation-updated.mjs Version updated from "0.0.2" to "0.0.3"; no logic changes.

Assessment against linked issues

Objective Addressed Explanation
Create a Hostaway Reservation (#14431)

Possibly related PRs

Suggested labels

action, User submitted

Suggested reviewers

  • michelle0927

Poem

In the land of Hostaway, where rabbits roam,
A new reservation module finds its home.
With channels and listings, all set to play,
Hopping through code, we celebrate the day! 🐰✨
Let the guests come in, let the bookings flow,
A joyful leap forward, watch our system grow!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ae02097 and fbdca84.

📒 Files selected for processing (3)
  • components/hostaway/actions/create-reservation/create-reservation.mjs (1 hunks)
  • components/hostaway/common/constants.mjs (1 hunks)
  • components/hostaway/hostaway.app.mjs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • components/hostaway/common/constants.mjs
  • components/hostaway/hostaway.app.mjs
  • components/hostaway/actions/create-reservation/create-reservation.mjs

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 3

🧹 Outside diff range and nitpick comments (4)
components/hostaway/common/constants.mjs (1)

45-61: Improve code formatting and structure of CHANNEL_OPTIONS

The channel options are correctly defined but could benefit from better formatting for consistency and readability.

Apply this formatting:

 const CHANNEL_OPTIONS = [
-  { value: 2018, label: "airbnbOfficial", },
-{ value: 2002, label: "homeaway", },
+  {
+    value: 2018,
+    label: "airbnbOfficial",
+  },
+  {
+    value: 2002,
+    label: "homeaway",
+  },
   // ... format other entries similarly
 ];

This matches the formatting style used in the CATEGORIES constant above.

🧰 Tools
🪛 eslint

[error] 46-46: Expected a line break after this opening brace.

(object-curly-newline)


[error] 46-46: Object properties must go on a new line.

(object-property-newline)


[error] 46-46: Unexpected trailing comma.

(comma-dangle)


[error] 46-46: Expected a line break before this closing brace.

(object-curly-newline)


[error] 47-47: Expected a line break after this opening brace.

(object-curly-newline)


[error] 47-47: Expected indentation of 2 spaces but found 0.

(indent)


[error] 47-47: Object properties must go on a new line.

(object-property-newline)


[error] 47-47: Unexpected trailing comma.

(comma-dangle)


[error] 47-47: Expected a line break before this closing brace.

(object-curly-newline)


[error] 48-48: Expected a line break after this opening brace.

(object-curly-newline)


[error] 48-48: Expected indentation of 2 spaces but found 0.

(indent)


[error] 48-48: Object properties must go on a new line.

(object-property-newline)


[error] 48-48: Unexpected trailing comma.

(comma-dangle)


[error] 48-48: Expected a line break before this closing brace.

(object-curly-newline)


[error] 49-49: Expected a line break after this opening brace.

(object-curly-newline)


[error] 49-49: Expected indentation of 2 spaces but found 0.

(indent)


[error] 49-49: Object properties must go on a new line.

(object-property-newline)


[error] 49-49: Unexpected trailing comma.

(comma-dangle)


[error] 49-49: Expected a line break before this closing brace.

(object-curly-newline)


[error] 50-50: Expected a line break after this opening brace.

(object-curly-newline)


[error] 50-50: Expected indentation of 2 spaces but found 0.

(indent)


[error] 50-50: Object properties must go on a new line.

(object-property-newline)


[error] 50-50: Unexpected trailing comma.

(comma-dangle)


[error] 50-50: Expected a line break before this closing brace.

(object-curly-newline)


[error] 51-51: Expected a line break after this opening brace.

(object-curly-newline)


[error] 51-51: Expected indentation of 2 spaces but found 0.

(indent)


[error] 51-51: Object properties must go on a new line.

(object-property-newline)


[error] 51-51: Unexpected trailing comma.

(comma-dangle)


[error] 51-51: Expected a line break before this closing brace.

(object-curly-newline)


[error] 52-52: Expected a line break after this opening brace.

(object-curly-newline)


[error] 52-52: Expected indentation of 2 spaces but found 0.

(indent)


[error] 52-52: Object properties must go on a new line.

(object-property-newline)


[error] 52-52: Unexpected trailing comma.

(comma-dangle)


[error] 52-52: Expected a line break before this closing brace.

(object-curly-newline)


[error] 53-53: Expected a line break after this opening brace.

(object-curly-newline)


[error] 53-53: Expected indentation of 2 spaces but found 0.

(indent)


[error] 53-53: Object properties must go on a new line.

(object-property-newline)


[error] 53-53: Unexpected trailing comma.

(comma-dangle)


[error] 53-53: Expected a line break before this closing brace.

(object-curly-newline)


[error] 54-54: Expected a line break after this opening brace.

(object-curly-newline)


[error] 54-54: Expected indentation of 2 spaces but found 0.

(indent)


[error] 54-54: Object properties must go on a new line.

(object-property-newline)


[error] 54-54: Unexpected trailing comma.

(comma-dangle)


[error] 54-54: Expected a line break before this closing brace.

(object-curly-newline)


[error] 55-55: Expected a line break after this opening brace.

(object-curly-newline)


[error] 55-55: Expected indentation of 2 spaces but found 0.

(indent)


[error] 55-55: Object properties must go on a new line.

(object-property-newline)


[error] 55-55: Unexpected trailing comma.

(comma-dangle)


[error] 55-55: Expected a line break before this closing brace.

(object-curly-newline)


[error] 56-56: Expected a line break after this opening brace.

(object-curly-newline)


[error] 56-56: Expected indentation of 2 spaces but found 0.

(indent)


[error] 56-56: Object properties must go on a new line.

(object-property-newline)


[error] 56-56: Unexpected trailing comma.

(comma-dangle)


[error] 56-56: Expected a line break before this closing brace.

(object-curly-newline)


[error] 57-57: Expected a line break after this opening brace.

(object-curly-newline)


[error] 57-57: Expected indentation of 2 spaces but found 0.

(indent)


[error] 57-57: Object properties must go on a new line.

(object-property-newline)


[error] 57-57: Unexpected trailing comma.

(comma-dangle)


[error] 57-57: Expected a line break before this closing brace.

(object-curly-newline)


[error] 58-58: Expected a line break after this opening brace.

(object-curly-newline)


[error] 58-58: Expected indentation of 2 spaces but found 0.

(indent)


[error] 58-58: Object properties must go on a new line.

(object-property-newline)


[error] 58-58: Unexpected trailing comma.

(comma-dangle)


[error] 58-58: Expected a line break before this closing brace.

(object-curly-newline)


[error] 59-59: Expected a line break after this opening brace.

(object-curly-newline)


[error] 59-59: Expected indentation of 2 spaces but found 0.

(indent)


[error] 59-59: Object properties must go on a new line.

(object-property-newline)


[error] 59-59: Unexpected trailing comma.

(comma-dangle)


[error] 59-59: Expected a line break before this closing brace.

(object-curly-newline)


[error] 60-60: Expected a line break after this opening brace.

(object-curly-newline)


[error] 60-60: Expected indentation of 2 spaces but found 0.

(indent)


[error] 60-60: Object properties must go on a new line.

(object-property-newline)


[error] 60-60: Unexpected trailing comma.

(comma-dangle)


[error] 60-60: Expected a line break before this closing brace.

(object-curly-newline)

🪛 GitHub Check: Lint Code Base

[failure] 46-46:
Expected a line break after this opening brace


[failure] 46-46:
Object properties must go on a new line


[failure] 46-46:
Unexpected trailing comma


[failure] 46-46:
Expected a line break before this closing brace


[failure] 47-47:
Expected a line break after this opening brace


[failure] 47-47:
Expected indentation of 2 spaces but found 0

components/hostaway/actions/create-reservation/create-reservation.mjs (1)

51-56: Document common additional fields

While the documentation link is helpful, consider listing common additional fields in the description.

Update the description to include common fields:

     additionalFields: {
       type: "object",
       label: "Additional Fields",
-      description: "Additional fields to set for the reservation. [See the documentation](https://api.hostaway.com/documentation#reservation-object) for all available fields.",
+      description: "Additional fields to set for the reservation. Common fields include: `guestPhone`, `adults`, `children`, `pets`, `price`, `currency`. [See the documentation](https://api.hostaway.com/documentation#reservation-object) for all available fields.",
       optional: true,
     }
🧰 Tools
🪛 GitHub Check: Lint Code Base

[failure] 56-56:
Missing trailing comma

components/hostaway/actions/update-task/update-task.mjs (1)

Inconsistent property naming found in Hostaway components

The codebase shows inconsistent usage between listingId and listingMapId:

  • In Hostaway components, there's a mix where input props are named listingId but they're being mapped to listingMapId in API calls:
    • components/hostaway/actions/update-task/update-task.mjs
    • components/hostaway/actions/create-task/create-task.mjs
    • components/hostaway/actions/send-message-to-guest/send-message-to-guest.mjs
  • However, components/hostaway/actions/create-reservation/create-reservation.mjs directly uses listingMapId as the prop name

This inconsistency should be standardized to use listingMapId throughout the Hostaway components for clarity and consistency.

🔗 Analysis chain

Line range hint 67-75: Verify consistent use of listingMapId

Let's verify that the rename from listingId to listingMapId is consistent across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining uses of listingId that should be listingMapId
# Expected: No inconsistent usage of these property names

# Search for listingId usage
rg "listingId" --type js --type mjs

# Search for listingMapId usage
rg "listingMapId" --type js --type mjs

Length of output: 130


Script:

#!/bin/bash
# Search for listingId and listingMapId usage with correct file type flags
rg "listingId" -t js
rg "listingMapId" -t js

# Also search without file type restriction to catch .mjs files
rg "listingId"
rg "listingMapId"

Length of output: 6702

components/hostaway/hostaway.app.mjs (1)

220-226: LGTM! Consider adding JSDoc comments.

The implementation follows the established pattern and correctly uses the _makeRequest helper. To improve maintainability, consider adding JSDoc comments describing the expected arguments and return value, similar to the Hostaway API documentation.

+    /**
+     * Creates a new reservation
+     * @param {Object} args - The reservation details
+     * @returns {Promise<Object>} The created reservation
+     */
     createReservation(args = {}) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fe7b4bb and ae02097.

📒 Files selected for processing (10)
  • components/hostaway/actions/create-reservation/create-reservation.mjs (1 hunks)
  • components/hostaway/actions/create-task/create-task.mjs (1 hunks)
  • components/hostaway/actions/send-message-to-guest/send-message-to-guest.mjs (1 hunks)
  • components/hostaway/actions/update-task/update-task.mjs (1 hunks)
  • components/hostaway/common/constants.mjs (1 hunks)
  • components/hostaway/hostaway.app.mjs (2 hunks)
  • components/hostaway/package.json (1 hunks)
  • components/hostaway/sources/new-message-received/new-message-received.mjs (1 hunks)
  • components/hostaway/sources/reservation-created/reservation-created.mjs (1 hunks)
  • components/hostaway/sources/reservation-updated/reservation-updated.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (6)
  • components/hostaway/actions/create-task/create-task.mjs
  • components/hostaway/actions/send-message-to-guest/send-message-to-guest.mjs
  • components/hostaway/sources/new-message-received/new-message-received.mjs
  • components/hostaway/sources/reservation-updated/reservation-updated.mjs
  • components/hostaway/sources/reservation-created/reservation-created.mjs
  • components/hostaway/package.json
🧰 Additional context used
🪛 eslint
components/hostaway/common/constants.mjs

[error] 46-46: Expected a line break after this opening brace.

(object-curly-newline)


[error] 46-46: Object properties must go on a new line.

(object-property-newline)


[error] 46-46: Unexpected trailing comma.

(comma-dangle)


[error] 46-46: Expected a line break before this closing brace.

(object-curly-newline)


[error] 47-47: Expected a line break after this opening brace.

(object-curly-newline)


[error] 47-47: Expected indentation of 2 spaces but found 0.

(indent)


[error] 47-47: Object properties must go on a new line.

(object-property-newline)


[error] 47-47: Unexpected trailing comma.

(comma-dangle)


[error] 47-47: Expected a line break before this closing brace.

(object-curly-newline)


[error] 48-48: Expected a line break after this opening brace.

(object-curly-newline)


[error] 48-48: Expected indentation of 2 spaces but found 0.

(indent)


[error] 48-48: Object properties must go on a new line.

(object-property-newline)


[error] 48-48: Unexpected trailing comma.

(comma-dangle)


[error] 48-48: Expected a line break before this closing brace.

(object-curly-newline)


[error] 49-49: Expected a line break after this opening brace.

(object-curly-newline)


[error] 49-49: Expected indentation of 2 spaces but found 0.

(indent)


[error] 49-49: Object properties must go on a new line.

(object-property-newline)


[error] 49-49: Unexpected trailing comma.

(comma-dangle)


[error] 49-49: Expected a line break before this closing brace.

(object-curly-newline)


[error] 50-50: Expected a line break after this opening brace.

(object-curly-newline)


[error] 50-50: Expected indentation of 2 spaces but found 0.

(indent)


[error] 50-50: Object properties must go on a new line.

(object-property-newline)


[error] 50-50: Unexpected trailing comma.

(comma-dangle)


[error] 50-50: Expected a line break before this closing brace.

(object-curly-newline)


[error] 51-51: Expected a line break after this opening brace.

(object-curly-newline)


[error] 51-51: Expected indentation of 2 spaces but found 0.

(indent)


[error] 51-51: Object properties must go on a new line.

(object-property-newline)


[error] 51-51: Unexpected trailing comma.

(comma-dangle)


[error] 51-51: Expected a line break before this closing brace.

(object-curly-newline)


[error] 52-52: Expected a line break after this opening brace.

(object-curly-newline)


[error] 52-52: Expected indentation of 2 spaces but found 0.

(indent)


[error] 52-52: Object properties must go on a new line.

(object-property-newline)


[error] 52-52: Unexpected trailing comma.

(comma-dangle)


[error] 52-52: Expected a line break before this closing brace.

(object-curly-newline)


[error] 53-53: Expected a line break after this opening brace.

(object-curly-newline)


[error] 53-53: Expected indentation of 2 spaces but found 0.

(indent)


[error] 53-53: Object properties must go on a new line.

(object-property-newline)


[error] 53-53: Unexpected trailing comma.

(comma-dangle)


[error] 53-53: Expected a line break before this closing brace.

(object-curly-newline)


[error] 54-54: Expected a line break after this opening brace.

(object-curly-newline)


[error] 54-54: Expected indentation of 2 spaces but found 0.

(indent)


[error] 54-54: Object properties must go on a new line.

(object-property-newline)


[error] 54-54: Unexpected trailing comma.

(comma-dangle)


[error] 54-54: Expected a line break before this closing brace.

(object-curly-newline)


[error] 55-55: Expected a line break after this opening brace.

(object-curly-newline)


[error] 55-55: Expected indentation of 2 spaces but found 0.

(indent)


[error] 55-55: Object properties must go on a new line.

(object-property-newline)


[error] 55-55: Unexpected trailing comma.

(comma-dangle)


[error] 55-55: Expected a line break before this closing brace.

(object-curly-newline)


[error] 56-56: Expected a line break after this opening brace.

(object-curly-newline)


[error] 56-56: Expected indentation of 2 spaces but found 0.

(indent)


[error] 56-56: Object properties must go on a new line.

(object-property-newline)


[error] 56-56: Unexpected trailing comma.

(comma-dangle)


[error] 56-56: Expected a line break before this closing brace.

(object-curly-newline)


[error] 57-57: Expected a line break after this opening brace.

(object-curly-newline)


[error] 57-57: Expected indentation of 2 spaces but found 0.

(indent)


[error] 57-57: Object properties must go on a new line.

(object-property-newline)


[error] 57-57: Unexpected trailing comma.

(comma-dangle)


[error] 57-57: Expected a line break before this closing brace.

(object-curly-newline)


[error] 58-58: Expected a line break after this opening brace.

(object-curly-newline)


[error] 58-58: Expected indentation of 2 spaces but found 0.

(indent)


[error] 58-58: Object properties must go on a new line.

(object-property-newline)


[error] 58-58: Unexpected trailing comma.

(comma-dangle)


[error] 58-58: Expected a line break before this closing brace.

(object-curly-newline)


[error] 59-59: Expected a line break after this opening brace.

(object-curly-newline)


[error] 59-59: Expected indentation of 2 spaces but found 0.

(indent)


[error] 59-59: Object properties must go on a new line.

(object-property-newline)


[error] 59-59: Unexpected trailing comma.

(comma-dangle)


[error] 59-59: Expected a line break before this closing brace.

(object-curly-newline)


[error] 60-60: Expected a line break after this opening brace.

(object-curly-newline)


[error] 60-60: Expected indentation of 2 spaces but found 0.

(indent)


[error] 60-60: Object properties must go on a new line.

(object-property-newline)


[error] 60-60: Unexpected trailing comma.

(comma-dangle)


[error] 60-60: Expected a line break before this closing brace.

(object-curly-newline)


[error] 61-62: Missing semicolon.

(semi)

components/hostaway/hostaway.app.mjs

[error] 125-126: Missing trailing comma.

(comma-dangle)

components/hostaway/actions/create-reservation/create-reservation.mjs

[error] 56-57: Missing trailing comma.

(comma-dangle)


[error] 59-59: Expected a line break after this opening brace.

(object-curly-newline)


[error] 59-59: Expected a line break before this closing brace.

(object-curly-newline)


[error] 64-65: Missing trailing comma.

(comma-dangle)

🪛 GitHub Check: Lint Code Base
components/hostaway/common/constants.mjs

[failure] 46-46:
Expected a line break after this opening brace


[failure] 46-46:
Object properties must go on a new line


[failure] 46-46:
Unexpected trailing comma


[failure] 46-46:
Expected a line break before this closing brace


[failure] 47-47:
Expected a line break after this opening brace


[failure] 47-47:
Expected indentation of 2 spaces but found 0

components/hostaway/actions/create-reservation/create-reservation.mjs

[failure] 56-56:
Missing trailing comma


[failure] 59-59:
Expected a line break after this opening brace


[failure] 59-59:
Expected a line break before this closing brace


[failure] 64-64:
Missing trailing comma

🔇 Additional comments (2)
components/hostaway/common/constants.mjs (1)

45-61: Verify channel IDs against Hostaway API

Let's verify these channel IDs match the official Hostaway API documentation.

🧰 Tools
🪛 eslint

[error] 46-46: Expected a line break after this opening brace.

(object-curly-newline)


[error] 46-46: Object properties must go on a new line.

(object-property-newline)


[error] 46-46: Unexpected trailing comma.

(comma-dangle)


[error] 46-46: Expected a line break before this closing brace.

(object-curly-newline)


[error] 47-47: Expected a line break after this opening brace.

(object-curly-newline)


[error] 47-47: Expected indentation of 2 spaces but found 0.

(indent)


[error] 47-47: Object properties must go on a new line.

(object-property-newline)


[error] 47-47: Unexpected trailing comma.

(comma-dangle)


[error] 47-47: Expected a line break before this closing brace.

(object-curly-newline)


[error] 48-48: Expected a line break after this opening brace.

(object-curly-newline)


[error] 48-48: Expected indentation of 2 spaces but found 0.

(indent)


[error] 48-48: Object properties must go on a new line.

(object-property-newline)


[error] 48-48: Unexpected trailing comma.

(comma-dangle)


[error] 48-48: Expected a line break before this closing brace.

(object-curly-newline)


[error] 49-49: Expected a line break after this opening brace.

(object-curly-newline)


[error] 49-49: Expected indentation of 2 spaces but found 0.

(indent)


[error] 49-49: Object properties must go on a new line.

(object-property-newline)


[error] 49-49: Unexpected trailing comma.

(comma-dangle)


[error] 49-49: Expected a line break before this closing brace.

(object-curly-newline)


[error] 50-50: Expected a line break after this opening brace.

(object-curly-newline)


[error] 50-50: Expected indentation of 2 spaces but found 0.

(indent)


[error] 50-50: Object properties must go on a new line.

(object-property-newline)


[error] 50-50: Unexpected trailing comma.

(comma-dangle)


[error] 50-50: Expected a line break before this closing brace.

(object-curly-newline)


[error] 51-51: Expected a line break after this opening brace.

(object-curly-newline)


[error] 51-51: Expected indentation of 2 spaces but found 0.

(indent)


[error] 51-51: Object properties must go on a new line.

(object-property-newline)


[error] 51-51: Unexpected trailing comma.

(comma-dangle)


[error] 51-51: Expected a line break before this closing brace.

(object-curly-newline)


[error] 52-52: Expected a line break after this opening brace.

(object-curly-newline)


[error] 52-52: Expected indentation of 2 spaces but found 0.

(indent)


[error] 52-52: Object properties must go on a new line.

(object-property-newline)


[error] 52-52: Unexpected trailing comma.

(comma-dangle)


[error] 52-52: Expected a line break before this closing brace.

(object-curly-newline)


[error] 53-53: Expected a line break after this opening brace.

(object-curly-newline)


[error] 53-53: Expected indentation of 2 spaces but found 0.

(indent)


[error] 53-53: Object properties must go on a new line.

(object-property-newline)


[error] 53-53: Unexpected trailing comma.

(comma-dangle)


[error] 53-53: Expected a line break before this closing brace.

(object-curly-newline)


[error] 54-54: Expected a line break after this opening brace.

(object-curly-newline)


[error] 54-54: Expected indentation of 2 spaces but found 0.

(indent)


[error] 54-54: Object properties must go on a new line.

(object-property-newline)


[error] 54-54: Unexpected trailing comma.

(comma-dangle)


[error] 54-54: Expected a line break before this closing brace.

(object-curly-newline)


[error] 55-55: Expected a line break after this opening brace.

(object-curly-newline)


[error] 55-55: Expected indentation of 2 spaces but found 0.

(indent)


[error] 55-55: Object properties must go on a new line.

(object-property-newline)


[error] 55-55: Unexpected trailing comma.

(comma-dangle)


[error] 55-55: Expected a line break before this closing brace.

(object-curly-newline)


[error] 56-56: Expected a line break after this opening brace.

(object-curly-newline)


[error] 56-56: Expected indentation of 2 spaces but found 0.

(indent)


[error] 56-56: Object properties must go on a new line.

(object-property-newline)


[error] 56-56: Unexpected trailing comma.

(comma-dangle)


[error] 56-56: Expected a line break before this closing brace.

(object-curly-newline)


[error] 57-57: Expected a line break after this opening brace.

(object-curly-newline)


[error] 57-57: Expected indentation of 2 spaces but found 0.

(indent)


[error] 57-57: Object properties must go on a new line.

(object-property-newline)


[error] 57-57: Unexpected trailing comma.

(comma-dangle)


[error] 57-57: Expected a line break before this closing brace.

(object-curly-newline)


[error] 58-58: Expected a line break after this opening brace.

(object-curly-newline)


[error] 58-58: Expected indentation of 2 spaces but found 0.

(indent)


[error] 58-58: Object properties must go on a new line.

(object-property-newline)


[error] 58-58: Unexpected trailing comma.

(comma-dangle)


[error] 58-58: Expected a line break before this closing brace.

(object-curly-newline)


[error] 59-59: Expected a line break after this opening brace.

(object-curly-newline)


[error] 59-59: Expected indentation of 2 spaces but found 0.

(indent)


[error] 59-59: Object properties must go on a new line.

(object-property-newline)


[error] 59-59: Unexpected trailing comma.

(comma-dangle)


[error] 59-59: Expected a line break before this closing brace.

(object-curly-newline)


[error] 60-60: Expected a line break after this opening brace.

(object-curly-newline)


[error] 60-60: Expected indentation of 2 spaces but found 0.

(indent)


[error] 60-60: Object properties must go on a new line.

(object-property-newline)


[error] 60-60: Unexpected trailing comma.

(comma-dangle)


[error] 60-60: Expected a line break before this closing brace.

(object-curly-newline)

🪛 GitHub Check: Lint Code Base

[failure] 46-46:
Expected a line break after this opening brace


[failure] 46-46:
Object properties must go on a new line


[failure] 46-46:
Unexpected trailing comma


[failure] 46-46:
Expected a line break before this closing brace


[failure] 47-47:
Expected a line break after this opening brace


[failure] 47-47:
Expected indentation of 2 spaces but found 0

components/hostaway/actions/update-task/update-task.mjs (1)

9-9: Version bump is appropriate

The version increment from 0.0.1 to 0.0.2 is appropriate for the property rename change.

Comment on lines +23 to +32
arrivalDate: {
type: "string",
label: "Arrival Date",
description: "Arrival date in `YYYY-MM-DD` format, e.g. `2024-08-15`",
},
departureDate: {
type: "string",
label: "Departure Date",
description: "Departure date in `YYYY-MM-DD` format, e.g. `2024-08-19`",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add date validation for arrival and departure dates

While the date format is documented, there's no validation to ensure dates are:

  1. In the correct format
  2. Arrival is before departure
  3. Not in the past

Consider adding validation in the run method:

 async run({ $ }) {
   const { hostaway, additionalFields = {}, ...data } = this;
+  const arrival = new Date(data.arrivalDate);
+  const departure = new Date(data.departureDate);
+  
+  if (isNaN(arrival.getTime()) || isNaN(departure.getTime())) {
+    throw new Error("Invalid date format. Use YYYY-MM-DD");
+  }
+  
+  if (arrival >= departure) {
+    throw new Error("Arrival date must be before departure date");
+  }
+  
+  if (arrival < new Date()) {
+    throw new Error("Arrival date cannot be in the past");
+  }
   
   const { result } = await hostaway.createReservation({

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 58 to 73
async run({ $ }) {
const { hostaway, additionalFields = {}, ...data } = this;
const { result } = await hostaway.createReservation({
$,
data: {
...data,
...additionalFields
},
});

if (result?.id) {
$.export("summary", `Successfully created reservation (ID: ${result.id})`);
}

return result;
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance error handling in run method

The current implementation could benefit from better error handling and validation.

Consider adding try-catch and validation:

 async run({ $ }) {
-  const { hostaway, additionalFields = {}, ...data } = this;
-  const { result } = await hostaway.createReservation({
-    $,
-    data: {
-      ...data,
-      ...additionalFields
-    },
-  });
+  try {
+    const { hostaway, additionalFields = {}, ...data } = this;
+    
+    // Validate required fields
+    if (!data.channelId || !data.listingMapId) {
+      throw new Error("channelId and listingMapId are required");
+    }
+    
+    const { result } = await hostaway.createReservation({
+      $,
+      data: {
+        ...data,
+        ...additionalFields,
+      },
+    });
 
-  if (result?.id) {
-    $.export("summary", `Successfully created reservation (ID: ${result.id})`);
-  }
+    if (!result?.id) {
+      throw new Error("Failed to create reservation: No ID returned");
+    }
+    
+    $.export("summary", `Successfully created reservation (ID: ${result.id})`);
+    return result;
+  } catch (error) {
+    throw new Error(`Failed to create reservation: ${error.message}`);
+  }
-  return result;
 }
📝 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
async run({ $ }) {
const { hostaway, additionalFields = {}, ...data } = this;
const { result } = await hostaway.createReservation({
$,
data: {
...data,
...additionalFields
},
});
if (result?.id) {
$.export("summary", `Successfully created reservation (ID: ${result.id})`);
}
return result;
},
async run({ $ }) {
try {
const { hostaway, additionalFields = {}, ...data } = this;
// Validate required fields
if (!data.channelId || !data.listingMapId) {
throw new Error("channelId and listingMapId are required");
}
const { result } = await hostaway.createReservation({
$,
data: {
...data,
...additionalFields,
},
});
if (!result?.id) {
throw new Error("Failed to create reservation: No ID returned");
}
$.export("summary", `Successfully created reservation (ID: ${result.id})`);
return result;
} catch (error) {
throw new Error(`Failed to create reservation: ${error.message}`);
}
},
🧰 Tools
🪛 eslint

[error] 59-59: Expected a line break after this opening brace.

(object-curly-newline)


[error] 59-59: Expected a line break before this closing brace.

(object-curly-newline)


[error] 64-65: Missing trailing comma.

(comma-dangle)

🪛 GitHub Check: Lint Code Base

[failure] 59-59:
Expected a line break after this opening brace


[failure] 59-59:
Expected a line break before this closing brace


[failure] 64-64:
Missing trailing comma

Comment on lines 121 to 126
channelId: {
type: "integer",
label: "Channel",
description: "Identifier of the channel",
options: constants.CHANNEL_OPTIONS
},
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Add trailing comma for consistency and fix CHANNEL_OPTIONS formatting

The property definition needs a trailing comma, and I noticed the CHANNEL_OPTIONS constant has inconsistent formatting:

    channelId: {
      type: "integer",
      label: "Channel",
      description: "Identifier of the channel",
-     options: constants.CHANNEL_OPTIONS
+     options: constants.CHANNEL_OPTIONS,
    },
  • components/hostaway/common/constants.mjs: Fix inconsistent indentation and trailing commas in CHANNEL_OPTIONS array items. The first item is indented while others aren't.
🔗 Analysis chain

Add trailing comma for consistency.

The property definition looks good, but needs a trailing comma to match the style of other properties in this file.

    channelId: {
      type: "integer",
      label: "Channel",
      description: "Identifier of the channel",
-     options: constants.CHANNEL_OPTIONS
+     options: constants.CHANNEL_OPTIONS,
    },

Let's verify the channel options are properly defined:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if CHANNEL_OPTIONS are defined in constants file
rg "CHANNEL_OPTIONS.*=.*\[" components/hostaway/common/constants.mjs

Length of output: 96


Script:

#!/bin/bash
# Let's check the full definition of CHANNEL_OPTIONS to ensure it's properly populated
rg -A10 "CHANNEL_OPTIONS.*=.*\[" components/hostaway/common/constants.mjs

Length of output: 496

🧰 Tools
🪛 eslint

[error] 125-126: Missing trailing comma.

(comma-dangle)

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.

[ACTION] Create a Hostaway Reservation
1 participant