Skip to content

Commit

Permalink
feat: use new TBA connection for Netuite
Browse files Browse the repository at this point in the history
  • Loading branch information
ansmonjol committed Jul 2, 2024
1 parent 90ea3aa commit a5f25b0
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 15 deletions.
4 changes: 4 additions & 0 deletions ditto/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@
"text_661ff6e56ef7e1b7c542b311": "payments",
"text_661ff6e56ef7e1b7c542b31e": "sales orders",
"text_661ff6e56ef7e1b7c542b326": "Connect to NetSuite",
"text_6683cd0bab4ac0007e913af7": "NetSuite Token Id",
"text_6683cd1bb93b060070e9a596": "Type your NetSuite Token Id",
"text_6683cd29cfb79500e588ee47": "NetSuite Token Secret",
"text_6683cd3f33ac8f005b67345c": "Type your NetSuite Token Secret",
"text_661ff6e56ef7e1b7c542b1e6": "NetSuite • Accounting",
"text_661ff6e56ef7e1b7c542b200": "Items",
"text_661ff6e56ef7e1b7c542b20a": "Map items",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"@mui/styled-engine": "5.14.18",
"@mui/styled-engine-sc": "5.14.12",
"@mui/x-date-pickers": "6.20.0",
"@nangohq/frontend": "^0.39.18",
"@nangohq/frontend": "0.40.8",
"@sentry/react": "7.108.0",
"@sentry/tracing": "7.108.0",
"apollo-link-timeout": "4.0.0",
Expand Down
27 changes: 25 additions & 2 deletions src/components/settings/integrations/AddNetsuiteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ gql`
syncInvoices
syncPayments
syncSalesOrders
tokenId
tokenSecret
}
mutation createNetsuiteIntegration($input: CreateNetsuiteIntegrationInput!) {
Expand Down Expand Up @@ -113,6 +115,8 @@ export const AddNetsuiteDialog = forwardRef<AddNetsuiteDialogRef>((_, ref) => {
accountId: netsuiteProvider?.accountId || '',
clientId: netsuiteProvider?.clientId || '',
clientSecret: netsuiteProvider?.clientSecret || '',
tokenId: netsuiteProvider?.tokenId || '',
tokenSecret: netsuiteProvider?.tokenSecret || '',
scriptEndpointUrl: netsuiteProvider?.scriptEndpointUrl || '',
syncCreditNotes: !!netsuiteProvider?.syncCreditNotes,
syncInvoices: !!netsuiteProvider?.syncInvoices,
Expand All @@ -125,6 +129,8 @@ export const AddNetsuiteDialog = forwardRef<AddNetsuiteDialogRef>((_, ref) => {
accountId: string().required(''),
clientId: string().required(''),
clientSecret: string().required(''),
tokenId: string().required(''),
tokenSecret: string().required(''),
scriptEndpointUrl: string().url('').required(''),
syncCreditNotes: boolean(),
syncInvoices: boolean(),
Expand Down Expand Up @@ -163,13 +169,16 @@ export const AddNetsuiteDialog = forwardRef<AddNetsuiteDialogRef>((_, ref) => {
return handleError(res.errors)
}
} else {
const connectionId = `netsuite-${componentId.replaceAll(':', '')}-${Date.now()}`
const connectionId = `netsuite-tba-${componentId.replaceAll(':', '')}-${Date.now()}`

const nango = new Nango({ publicKey: nangoPublicKey })

try {
const nangoAuthResult = await nango.auth('netsuite', connectionId, {
const nangoAuthResult = await nango.auth('netsuite-tba', connectionId, {
params: { accountId: values.accountId },
credentials: {
token_id: values.tokenId,
token_secret: values.tokenSecret,
oauth_client_id_override: values.clientId,
oauth_client_secret_override: values.clientSecret,
},
Expand Down Expand Up @@ -305,6 +314,20 @@ export const AddNetsuiteDialog = forwardRef<AddNetsuiteDialogRef>((_, ref) => {
placeholder={translate('text_661ff6e56ef7e1b7c542b251')}
formikProps={formikProps}
/>
<TextInputField
name="tokenId"
disabled={isEdition}
label={translate('text_6683cd0bab4ac0007e913af7')}
placeholder={translate('text_6683cd1bb93b060070e9a596')}
formikProps={formikProps}
/>
<TextInputField
name="tokenSecret"
disabled={isEdition}
label={translate('text_6683cd29cfb79500e588ee47')}
placeholder={translate('text_6683cd3f33ac8f005b67345c')}
formikProps={formikProps}
/>
</Stack>

<Stack spacing={6}>
Expand Down
24 changes: 16 additions & 8 deletions src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,8 @@ export type CreateNetsuiteIntegrationInput = {
syncInvoices?: InputMaybe<Scalars['Boolean']['input']>;
syncPayments?: InputMaybe<Scalars['Boolean']['input']>;
syncSalesOrders?: InputMaybe<Scalars['Boolean']['input']>;
tokenId: Scalars['String']['input'];
tokenSecret: Scalars['String']['input'];
};

/** Autogenerated input type of CreateOktaIntegration */
Expand Down Expand Up @@ -3353,6 +3355,8 @@ export type NetsuiteIntegration = {
syncInvoices?: Maybe<Scalars['Boolean']['output']>;
syncPayments?: Maybe<Scalars['Boolean']['output']>;
syncSalesOrders?: Maybe<Scalars['Boolean']['output']>;
tokenId?: Maybe<Scalars['String']['output']>;
tokenSecret?: Maybe<Scalars['String']['output']>;
};

/** Accept Invite with Okta Oauth input arguments */
Expand Down Expand Up @@ -4833,6 +4837,8 @@ export type UpdateNetsuiteIntegrationInput = {
syncInvoices?: InputMaybe<Scalars['Boolean']['input']>;
syncPayments?: InputMaybe<Scalars['Boolean']['input']>;
syncSalesOrders?: InputMaybe<Scalars['Boolean']['input']>;
tokenId?: InputMaybe<Scalars['String']['input']>;
tokenSecret?: InputMaybe<Scalars['String']['input']>;
};

/** Autogenerated input type of UpdateOktaIntegration */
Expand Down Expand Up @@ -6030,21 +6036,21 @@ export type UpdateOrgaForLagoTaxManagementMutationVariables = Exact<{

export type UpdateOrgaForLagoTaxManagementMutation = { __typename?: 'Mutation', updateOrganization?: { __typename?: 'CurrentOrganization', id: string } | null };

export type NetsuiteForCreateDialogDialogFragment = { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null };
export type NetsuiteForCreateDialogDialogFragment = { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null };

export type CreateNetsuiteIntegrationMutationVariables = Exact<{
input: CreateNetsuiteIntegrationInput;
}>;


export type CreateNetsuiteIntegrationMutation = { __typename?: 'Mutation', createNetsuiteIntegration?: { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null } | null };
export type CreateNetsuiteIntegrationMutation = { __typename?: 'Mutation', createNetsuiteIntegration?: { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null } | null };

export type UpdateNetsuiteIntegrationMutationVariables = Exact<{
input: UpdateNetsuiteIntegrationInput;
}>;


export type UpdateNetsuiteIntegrationMutation = { __typename?: 'Mutation', updateNetsuiteIntegration?: { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null } | null };
export type UpdateNetsuiteIntegrationMutation = { __typename?: 'Mutation', updateNetsuiteIntegration?: { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null } | null };

export type AddStripeProviderDialogFragment = { __typename?: 'StripeProvider', id: string, name: string, code: string, secretKey?: string | null };

Expand Down Expand Up @@ -6335,7 +6341,7 @@ export type GetNetsuiteIntegrationsSettingsQueryVariables = Exact<{
}>;


export type GetNetsuiteIntegrationsSettingsQuery = { __typename?: 'Query', integration?: { __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, hasMappingsConfigured?: boolean | null, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' } | null, integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null };
export type GetNetsuiteIntegrationsSettingsQuery = { __typename?: 'Query', integration?: { __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, hasMappingsConfigured?: boolean | null, name: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' } | null, integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null };

export type XeroIntegrationItemsFragment = { __typename?: 'XeroIntegration', id: string };

Expand Down Expand Up @@ -7349,7 +7355,7 @@ export type GetMembersQueryVariables = Exact<{

export type GetMembersQuery = { __typename?: 'Query', memberships: { __typename?: 'MembershipCollection', metadata: { __typename?: 'Metadata', currentPage: number, totalPages: number, totalCount: number, adminCount: number }, collection: Array<{ __typename?: 'Membership', id: string, role: MembershipRole, user: { __typename?: 'User', id: string, email?: string | null }, permissions: { __typename?: 'Permissions', addonsCreate: boolean, addonsDelete: boolean, addonsUpdate: boolean, addonsView: boolean, analyticsView: boolean, billableMetricsCreate: boolean, billableMetricsDelete: boolean, billableMetricsUpdate: boolean, billableMetricsView: boolean, couponsAttach: boolean, couponsCreate: boolean, couponsDelete: boolean, couponsDetach: boolean, couponsUpdate: boolean, couponsView: boolean, creditNotesCreate: boolean, creditNotesView: boolean, creditNotesVoid: boolean, customerSettingsUpdateGracePeriod: boolean, customerSettingsUpdateLang: boolean, customerSettingsUpdatePaymentTerms: boolean, customerSettingsUpdateTaxRates: boolean, customerSettingsView: boolean, customersCreate: boolean, customersDelete: boolean, customersUpdate: boolean, customersView: boolean, developersKeysManage: boolean, developersManage: boolean, draftInvoicesUpdate: boolean, invoicesCreate: boolean, invoicesSend: boolean, invoicesUpdate: boolean, invoicesView: boolean, invoicesVoid: boolean, organizationEmailsUpdate: boolean, organizationEmailsView: boolean, organizationIntegrationsCreate: boolean, organizationIntegrationsDelete: boolean, organizationIntegrationsUpdate: boolean, organizationIntegrationsView: boolean, organizationInvoicesUpdate: boolean, organizationInvoicesView: boolean, organizationMembersCreate: boolean, organizationMembersDelete: boolean, organizationMembersUpdate: boolean, organizationMembersView: boolean, organizationTaxesUpdate: boolean, organizationTaxesView: boolean, organizationUpdate: boolean, organizationView: boolean, plansCreate: boolean, plansDelete: boolean, plansUpdate: boolean, plansView: boolean, subscriptionsCreate: boolean, subscriptionsUpdate: boolean, subscriptionsView: boolean, walletsCreate: boolean, walletsTerminate: boolean, walletsTopUp: boolean, walletsUpdate: boolean } }> } };

export type NetsuiteIntegrationDetailsFragment = { __typename?: 'NetsuiteIntegration', id: string, name: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null };
export type NetsuiteIntegrationDetailsFragment = { __typename?: 'NetsuiteIntegration', id: string, name: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null };

export type GetNetsuiteIntegrationsDetailsQueryVariables = Exact<{
id: Scalars['ID']['input'];
Expand All @@ -7358,17 +7364,17 @@ export type GetNetsuiteIntegrationsDetailsQueryVariables = Exact<{
}>;


export type GetNetsuiteIntegrationsDetailsQuery = { __typename?: 'Query', integration?: { __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, name: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' } | null, integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null };
export type GetNetsuiteIntegrationsDetailsQuery = { __typename?: 'Query', integration?: { __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, name: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, code: string, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' } | null, integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null };

export type NetsuiteIntegrationsFragment = { __typename?: 'NetsuiteIntegration', id: string, name: string, code: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null };
export type NetsuiteIntegrationsFragment = { __typename?: 'NetsuiteIntegration', id: string, name: string, code: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null };

export type GetNetsuiteIntegrationsListQueryVariables = Exact<{
limit?: InputMaybe<Scalars['Int']['input']>;
type?: InputMaybe<IntegrationTypeEnum>;
}>;


export type GetNetsuiteIntegrationsListQuery = { __typename?: 'Query', integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, name: string, code: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null };
export type GetNetsuiteIntegrationsListQuery = { __typename?: 'Query', integrations?: { __typename?: 'IntegrationCollection', collection: Array<{ __typename?: 'AnrokIntegration' } | { __typename?: 'NetsuiteIntegration', id: string, name: string, code: string, accountId?: string | null, clientId?: string | null, clientSecret?: string | null, scriptEndpointUrl: string, syncCreditNotes?: boolean | null, syncInvoices?: boolean | null, syncPayments?: boolean | null, syncSalesOrders?: boolean | null, tokenId?: string | null, tokenSecret?: string | null } | { __typename?: 'OktaIntegration' } | { __typename?: 'XeroIntegration' }> } | null };

export type OrganizationInformationsFragment = { __typename?: 'CurrentOrganization', id: string, logoUrl?: string | null, name: string, legalName?: string | null, legalNumber?: string | null, taxIdentificationNumber?: string | null, email?: string | null, addressLine1?: string | null, addressLine2?: string | null, zipcode?: string | null, city?: string | null, state?: string | null, country?: CountryCode | null, timezone?: TimezoneEnum | null };

Expand Down Expand Up @@ -9914,6 +9920,8 @@ export const NetsuiteForCreateDialogDialogFragmentDoc = gql`
syncInvoices
syncPayments
syncSalesOrders
tokenId
tokenSecret
}
`;
export const NetsuiteIntegrationItemsFragmentDoc = gql`
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2267,10 +2267,10 @@
prop-types "^15.8.1"
react-transition-group "^4.4.5"

"@nangohq/frontend@^0.39.18":
version "0.39.18"
resolved "https://registry.yarnpkg.com/@nangohq/frontend/-/frontend-0.39.18.tgz#2800c97ab6434a9ca4719b27b918388114192b95"
integrity sha512-pqpLUkzC6zCwc9hNtXTE2IgSP+biuR7U2ySPtK+k67E4kuJQdY4ifqRhw/IlpyHvstZ9MJPVsq8namZNkNE85g==
"@nangohq/frontend@0.40.8":
version "0.40.8"
resolved "https://registry.yarnpkg.com/@nangohq/frontend/-/frontend-0.40.8.tgz#c7e2fc9b902466839ed7765cc8e39756c7287ff2"
integrity sha512-dNRgSDVa/RWNMrAIjC6adZmB4BPc9gntk3VdHDDSeHXV0EPTxKOugIutzSMyYYSIeqT8DWr5c4IAnZaoxd2MnQ==

"@nodelib/[email protected]":
version "2.1.5"
Expand Down

0 comments on commit a5f25b0

Please sign in to comment.