-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Refactor UpdatePolicyConnectionConfiguration to be 1:1:1 (Part 1) #46234
Merged
aldo-expensify
merged 14 commits into
main
from
dangrous-refactorupdatepolicyconnectionconfig1
Aug 13, 2024
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ca23a6c
first draft of new UpdateQuickbooksOnlineEnableNewCategories
dangrous a808c9d
revert changes to gemfile.lock
dangrous fc14079
typescript fixes
dangrous 3d21aad
standardize spelling in code
dangrous 8dadb84
actually change name of file, stupid case insensitive git
dangrous f04c888
add updateQuickbooksOnlineAutoCreateVendor
dangrous 0886e93
add updateQuickbooksOnlineReimbursableExpensesAccount
dangrous 58c4030
rename the params type correctly
dangrous 6e93f8d
fix types
dangrous 98eceb0
add new types in list
dangrous 81e6b69
only use one type for all commands
dangrous a93c1f5
Merge branch 'main' into dangrous-refactorupdatepolicyconnectionconfig1
dangrous 11ad948
remove unused import
dangrous e6e0042
Merge branch 'main' into dangrous-refactorupdatepolicyconnectionconfig1
dangrous File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/libs/API/parameters/UpdateQuickbooksOnlineEnableNewCategoriesParams.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type UpdateQuickbooksOnlineEnableNewCategoriesParams = { | ||
policyID: string; | ||
settingValue: string; | ||
idempotencyKey: string; | ||
}; | ||
|
||
export default UpdateQuickbooksOnlineEnableNewCategoriesParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import type {OnyxUpdate} from 'react-native-onyx'; | ||
import Onyx from 'react-native-onyx'; | ||
import * as API from '@libs/API'; | ||
import type {ConnectPolicyToAccountingIntegrationParams} from '@libs/API/parameters'; | ||
import type UpdateQuickbooksOnlineEnableNewCategoriesParams from '@libs/API/parameters/UpdateQuickbooksOnlineEnableNewCategoriesParams'; | ||
import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; | ||
import {getCommandURL} from '@libs/ApiUtils'; | ||
import * as ErrorUtils from '@libs/ErrorUtils'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
|
||
function getQuickbooksOnlineSetupLink(policyID: string) { | ||
const params: ConnectPolicyToAccountingIntegrationParams = {policyID}; | ||
const commandURL = getCommandURL({ | ||
command: READ_COMMANDS.CONNECT_POLICY_TO_QUICKBOOKS_ONLINE, | ||
shouldSkipWebProxy: true, | ||
}); | ||
return commandURL + new URLSearchParams(params).toString(); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From here down is new |
||
function updateQuickbooksOnlineEnableNewCategories(policyID: string, settingValue: boolean) { | ||
const optimisticData: OnyxUpdate[] = [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, | ||
value: { | ||
connections: { | ||
[CONST.POLICY.CONNECTIONS.NAME.QBO]: { | ||
config: { | ||
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: settingValue ?? null, | ||
pendingFields: { | ||
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, | ||
}, | ||
errorFields: { | ||
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; | ||
|
||
const failureData: OnyxUpdate[] = [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, | ||
value: { | ||
connections: { | ||
[CONST.POLICY.CONNECTIONS.NAME.QBO]: { | ||
config: { | ||
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: settingValue ?? null, | ||
pendingFields: { | ||
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null, | ||
}, | ||
errorFields: { | ||
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; | ||
|
||
const successData: OnyxUpdate[] = [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, | ||
value: { | ||
connections: { | ||
[CONST.POLICY.CONNECTIONS.NAME.QBO]: { | ||
config: { | ||
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: settingValue ?? null, | ||
pendingFields: { | ||
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null, | ||
}, | ||
errorFields: { | ||
[CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES]: null, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; | ||
|
||
const parameters: UpdateQuickbooksOnlineEnableNewCategoriesParams = { | ||
policyID, | ||
settingValue: JSON.stringify(settingValue), | ||
idempotencyKey: String(CONST.QUICK_BOOKS_CONFIG.ENABLE_NEW_CATEGORIES), | ||
}; | ||
API.write(WRITE_COMMANDS.UPDATE_QUICKBOOKS_ONLINE_ENABLE_NEW_CATEGORIES, parameters, {optimisticData, failureData, successData}); | ||
} | ||
|
||
export {getQuickbooksOnlineSetupLink, updateQuickbooksOnlineEnableNewCategories}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getQuickbooksOnlineSetupLink
is the same function as it was before - I renamed the file to match spelling; haven't changed this piece at all.