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

In AccountingApiCustomersAddRequest type, customer field should not require an id #162

Open
nickiepucel opened this issue Jan 4, 2024 · 0 comments

Comments

@nickiepucel
Copy link

Summary

In the AccountingApiCustomersAddRequest, the customer field is of type Customer, which has a required id property. The endpoint doesn't actually require an id in the payload, so this field should not be required.

Expected

The following code should compile:

const apideck = new Apideck({
  apiKey: 'REPLACE_WITH_API_KEY',
  appId: 'REPLACE_WITH_APP_ID',
  consumerId: 'REPLACE_WITH_CONSUMER_ID'
});

const params = {
  customer: {
    display_id: 'EMP00101',
    display_name: 'Windsurf Shop',
    company_name: 'SpaceX',
    first_name: 'Elon',
    last_name: 'Musk',
    // ... other (optional) fields
  },
};

try {
  const { data } = await apideck.accounting.customersAdd(params);
  console.log('API called successfully', data);
} catch (error) {
  console.error(error);
}

Actual

The above code fails compilation because id is a required field on customer.

Argument of type '{ customer: { display_id: string; display_name: string; company_name: string; first_name: string; last_name: string; }; }' is not assignable to parameter of type 'AccountingApiCustomersAddRequest'.
  Types of property 'customer' are incompatible.
    Property 'id' is missing in type '{ display_id: string; display_name: string; company_name: string; first_name: string; last_name: string; }' but required in type 'Customer'.ts(2345)
Customer.d.ts(32, 14): 'id' is declared here.
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

No branches or pull requests

1 participant