ledger_sync 1.3.3 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +13 -2
- data/.rubocop.yml +14 -1
- data/.rubocop_todo.yml +0 -3
- data/.travis.yml +7 -2
- data/Dockerfile +2 -2
- data/Gemfile.lock +115 -58
- data/LICENSE.txt +5 -21
- data/README.md +9 -489
- data/bin/quickbooks_online_oauth_server.rb +102 -0
- data/docs/.gitignore +4 -0
- data/documentation/build.sh +10 -0
- data/documentation/generate.rb +32 -0
- data/documentation/generators/generator.rb +80 -0
- data/documentation/generators/guides/generator.rb +36 -0
- data/documentation/generators/reference/generator.rb +76 -0
- data/documentation/generators/reference/ledger/generator.rb +74 -0
- data/documentation/generators/template.rb +22 -0
- data/documentation/helper_methods.rb +17 -0
- data/documentation/site/CNAME +1 -0
- data/documentation/site/LICENSE.md +40 -0
- data/documentation/site/README.md +8 -0
- data/documentation/site/_config.yml +119 -0
- data/documentation/site/_data/guides_sections.yml +10 -0
- data/documentation/site/_data/reference_sections.yml +5 -0
- data/documentation/site/_includes/action_link.html +11 -0
- data/documentation/site/_includes/alerts/base.html +3 -0
- data/documentation/site/_includes/alerts/danger.html +1 -0
- data/documentation/site/_includes/alerts/info.html +1 -0
- data/documentation/site/_includes/alerts/success.html +1 -0
- data/documentation/site/_includes/alerts/warning.html +1 -0
- data/documentation/site/_includes/cta_buttons.html +4 -0
- data/documentation/site/_includes/example.md +8 -0
- data/documentation/site/_includes/footer.html +20 -0
- data/documentation/site/_includes/getting_help.md +8 -0
- data/documentation/site/_includes/guides_menu.html +29 -0
- data/documentation/site/_includes/guides_submenu.html +7 -0
- data/documentation/site/_includes/header.html +35 -0
- data/documentation/site/_includes/installation_instructions.md +17 -0
- data/documentation/site/_includes/ledgers/netsuite_soap_summary.md +1 -0
- data/documentation/site/_includes/ledgers/netsuite_summary.md +1 -0
- data/documentation/site/_includes/ledgers/netsuite_summary_shared.md +1 -0
- data/documentation/site/_includes/ledgers/quickbooks_online_summary.md +1 -0
- data/documentation/site/_includes/ledgers/stripe_summary.md +1 -0
- data/documentation/site/_includes/reference/netsuite/authentication/_token_based_authentication.md +99 -0
- data/documentation/site/_includes/reference/netsuite/authentication/index.md +15 -0
- data/documentation/site/_includes/reference/netsuite/authentication/token_based_authentication.md +6 -0
- data/documentation/site/_includes/reference/netsuite/index.md +25 -0
- data/documentation/site/_includes/reference/netsuite_soap/index.md +11 -0
- data/documentation/site/_includes/reference/quickbooks_online/authentication/index.md +55 -0
- data/documentation/site/_includes/reference/quickbooks_online/errors/index.md +9 -0
- data/documentation/site/_includes/reference/quickbooks_online/index.md +6 -0
- data/documentation/site/_includes/reference/quickbooks_online/webhooks/index.md +42 -0
- data/documentation/site/_includes/reference/stripe/index.md +6 -0
- data/documentation/site/_includes/section_content.html +34 -0
- data/documentation/site/_includes/section_cta.html +28 -0
- data/documentation/site/_includes/section_grid.html +60 -0
- data/documentation/site/_includes/section_guides.html +35 -0
- data/documentation/site/_includes/section_hero.html +28 -0
- data/documentation/site/_includes/submenu.html +8 -0
- data/documentation/site/_layouts/advanced.html +9 -0
- data/documentation/site/_layouts/base.html +34 -0
- data/documentation/site/_layouts/blog.html +51 -0
- data/documentation/site/_layouts/body.html +11 -0
- data/documentation/site/_layouts/guides.html +46 -0
- data/documentation/site/_layouts/page.html +26 -0
- data/documentation/site/_layouts/post.html +52 -0
- data/documentation/site/_layouts/reference.html +46 -0
- data/documentation/site/_layouts/reference_netsuite.html +46 -0
- data/documentation/site/_layouts/reference_netsuite_soap.html +46 -0
- data/documentation/site/_layouts/reference_quickbooks_online.html +46 -0
- data/documentation/site/_layouts/reference_stripe.html +46 -0
- data/documentation/site/_plugins/filters.rb +122 -0
- data/documentation/site/_plugins/hooks.rb +9 -0
- data/documentation/site/_posts/2020-06-01-introducing-docs.md +17 -0
- data/documentation/site/_posts/2020-06-10-netsuite-authentication.md +382 -0
- data/documentation/site/_sass/imports/_animations.scss +19 -0
- data/documentation/site/_sass/imports/_footer.scss +94 -0
- data/documentation/site/_sass/imports/_functions.scss +69 -0
- data/documentation/site/_sass/imports/_general.scss +687 -0
- data/documentation/site/_sass/imports/_guides.scss +300 -0
- data/documentation/site/_sass/imports/_header.scss +358 -0
- data/documentation/site/_sass/imports/_icons.scss +90 -0
- data/documentation/site/_sass/imports/_post-navigation.scss +67 -0
- data/documentation/site/_sass/imports/_posts-pages.scss +165 -0
- data/documentation/site/_sass/imports/_prism.scss +174 -0
- data/documentation/site/_sass/imports/_reset.scss +210 -0
- data/documentation/site/_sass/imports/_sections.scss +370 -0
- data/documentation/site/_sass/imports/_structure.scss +44 -0
- data/documentation/site/_templates/_layouts/reference_ledger.html.erb +46 -0
- data/documentation/site/_templates/guides/ledger.md.erb +9 -0
- data/documentation/site/_templates/reference/resources/index.md.erb +9 -0
- data/documentation/site/_templates/reference/resources/resource.md.erb +27 -0
- data/documentation/site/assets/css/brands.min.css +5 -0
- data/documentation/site/assets/css/fontawesome.min.css +5 -0
- data/documentation/site/assets/css/main.scss +45 -0
- data/documentation/site/assets/css/monokai.css +441 -0
- data/documentation/site/assets/js/main.js +214 -0
- data/documentation/site/assets/js/plugins.js +22 -0
- data/documentation/site/assets/js/prism.js +9 -0
- data/documentation/site/assets/webfonts/fa-brands-400.eot +0 -0
- data/documentation/site/assets/webfonts/fa-brands-400.svg +3452 -0
- data/documentation/site/assets/webfonts/fa-brands-400.ttf +0 -0
- data/documentation/site/assets/webfonts/fa-brands-400.woff +0 -0
- data/documentation/site/assets/webfonts/fa-brands-400.woff2 +0 -0
- data/documentation/site/blog/index.md +6 -0
- data/documentation/site/guides/architecture/clients.md +35 -0
- data/documentation/site/guides/architecture/index.md +14 -0
- data/documentation/site/guides/architecture/operations.md +45 -0
- data/documentation/site/guides/architecture/resources.md +40 -0
- data/documentation/site/guides/architecture/results.md +6 -0
- data/documentation/site/guides/architecture/searchers.md +28 -0
- data/documentation/site/guides/architecture/serialization.md +59 -0
- data/documentation/site/guides/community/index.md +8 -0
- data/documentation/site/guides/contribute/console.md +6 -0
- data/documentation/site/guides/contribute/deployment.md +17 -0
- data/documentation/site/guides/contribute/documentation.md +37 -0
- data/documentation/site/guides/contribute/index.md +18 -0
- data/documentation/site/guides/contribute/qa.md +16 -0
- data/documentation/site/guides/contribute/testing.md +6 -0
- data/documentation/site/guides/customization/custom_resources.md +50 -0
- data/documentation/site/guides/customization/custom_serializers.md +47 -0
- data/documentation/site/guides/customization/index.md +15 -0
- data/documentation/site/guides/customization/resource_converters.md +79 -0
- data/documentation/site/guides/getting-started/get-help.md +7 -0
- data/documentation/site/guides/getting-started/index.md +8 -0
- data/documentation/site/guides/getting-started/installation.md +7 -0
- data/documentation/site/guides/getting-started/quick-start.md +123 -0
- data/documentation/site/guides/index.md +16 -0
- data/documentation/site/guides/ledgers/index.md +12 -0
- data/documentation/site/guides/ledgers/netsuite.md +9 -0
- data/documentation/site/guides/ledgers/netsuite_soap.md +9 -0
- data/documentation/site/guides/ledgers/quickbooks_online.md +9 -0
- data/documentation/site/guides/ledgers/stripe.md +9 -0
- data/documentation/site/guides/modern-treasury/index.md +14 -0
- data/documentation/site/guides/tips_and_more/index.md +76 -0
- data/documentation/site/images/1.jpg +0 -0
- data/documentation/site/images/10.jpg +0 -0
- data/documentation/site/images/2.jpg +0 -0
- data/documentation/site/images/3.jpg +0 -0
- data/documentation/site/images/4.jpg +0 -0
- data/documentation/site/images/5.jpg +0 -0
- data/documentation/site/images/6.jpg +0 -0
- data/documentation/site/images/7.jpg +0 -0
- data/documentation/site/images/8.jpg +0 -0
- data/documentation/site/images/9.jpg +0 -0
- data/documentation/site/images/logo.svg +8 -0
- data/documentation/site/index.md +99 -0
- data/documentation/site/overview.md +21 -0
- data/documentation/site/reference/architecture/clients.md +33 -0
- data/documentation/site/reference/architecture/index.md +14 -0
- data/documentation/site/reference/architecture/operations.md +6 -0
- data/documentation/site/reference/architecture/resources.md +38 -0
- data/documentation/site/reference/architecture/results.md +6 -0
- data/documentation/site/reference/architecture/searchers.md +6 -0
- data/documentation/site/reference/architecture/serialization.md +6 -0
- data/documentation/site/reference/index.md +6 -0
- data/documentation/site/reference/netsuite/authentication/_token_based_authentication.md +99 -0
- data/documentation/site/reference/netsuite/authentication/index.md +15 -0
- data/documentation/site/reference/netsuite/authentication/token_based_authentication.md +6 -0
- data/documentation/site/reference/netsuite/index.md +25 -0
- data/documentation/site/reference/netsuite/resources/account.md +38 -0
- data/documentation/site/reference/netsuite/resources/check.md +49 -0
- data/documentation/site/reference/netsuite/resources/check_line_item.md +23 -0
- data/documentation/site/reference/netsuite/resources/currency.md +45 -0
- data/documentation/site/reference/netsuite/resources/customer.md +48 -0
- data/documentation/site/reference/netsuite/resources/customer_deposit.md +46 -0
- data/documentation/site/reference/netsuite/resources/department.md +47 -0
- data/documentation/site/reference/netsuite/resources/deposit.md +25 -0
- data/documentation/site/reference/netsuite/resources/deposit_line_item.md +23 -0
- data/documentation/site/reference/netsuite/resources/index.md +25 -0
- data/documentation/site/reference/netsuite/resources/invoice.md +25 -0
- data/documentation/site/reference/netsuite/resources/invoice_line_item.md +22 -0
- data/documentation/site/reference/netsuite/resources/item.md +19 -0
- data/documentation/site/reference/netsuite/resources/journal_entry.md +48 -0
- data/documentation/site/reference/netsuite/resources/journal_entry_line_item.md +24 -0
- data/documentation/site/reference/netsuite/resources/ledger_class.md +47 -0
- data/documentation/site/reference/netsuite/resources/location.md +43 -0
- data/documentation/site/reference/netsuite/resources/resource.md +18 -0
- data/documentation/site/reference/netsuite/resources/subsidiary.md +20 -0
- data/documentation/site/reference/netsuite/resources/vendor.md +49 -0
- data/documentation/site/reference/netsuite_soap/index.md +11 -0
- data/documentation/site/reference/netsuite_soap/resources/customer.md +34 -0
- data/documentation/site/reference/netsuite_soap/resources/index.md +9 -0
- data/documentation/site/reference/netsuite_soap/resources/resource.md +18 -0
- data/documentation/site/reference/netsuite_soap/resources/subsidiary.md +32 -0
- data/documentation/site/reference/quickbooks_online/authentication/index.md +55 -0
- data/documentation/site/reference/quickbooks_online/errors/index.md +9 -0
- data/documentation/site/reference/quickbooks_online/index.md +6 -0
- data/documentation/site/reference/quickbooks_online/resources/account.md +44 -0
- data/documentation/site/reference/quickbooks_online/resources/bill.md +45 -0
- data/documentation/site/reference/quickbooks_online/resources/bill_line_item.md +22 -0
- data/documentation/site/reference/quickbooks_online/resources/bill_payment.md +49 -0
- data/documentation/site/reference/quickbooks_online/resources/bill_payment_line_item.md +20 -0
- data/documentation/site/reference/quickbooks_online/resources/currency.md +21 -0
- data/documentation/site/reference/quickbooks_online/resources/customer.md +40 -0
- data/documentation/site/reference/quickbooks_online/resources/department.md +41 -0
- data/documentation/site/reference/quickbooks_online/resources/deposit.md +43 -0
- data/documentation/site/reference/quickbooks_online/resources/deposit_line_item.md +23 -0
- data/documentation/site/reference/quickbooks_online/resources/expense.md +46 -0
- data/documentation/site/reference/quickbooks_online/resources/expense_line_item.md +22 -0
- data/documentation/site/reference/quickbooks_online/resources/index.md +33 -0
- data/documentation/site/reference/quickbooks_online/resources/invoice.md +43 -0
- data/documentation/site/reference/quickbooks_online/resources/invoice_sales_line_item.md +22 -0
- data/documentation/site/reference/quickbooks_online/resources/item.md +19 -0
- data/documentation/site/reference/quickbooks_online/resources/journal_entry.md +41 -0
- data/documentation/site/reference/quickbooks_online/resources/journal_entry_line_item.md +24 -0
- data/documentation/site/reference/quickbooks_online/resources/ledger_class.md +41 -0
- data/documentation/site/reference/quickbooks_online/resources/payment.md +46 -0
- data/documentation/site/reference/quickbooks_online/resources/payment_line_item.md +20 -0
- data/documentation/site/reference/quickbooks_online/resources/preferences.md +34 -0
- data/documentation/site/reference/quickbooks_online/resources/primary_email_addr.md +19 -0
- data/documentation/site/reference/quickbooks_online/resources/primary_phone.md +19 -0
- data/documentation/site/reference/quickbooks_online/resources/resource.md +18 -0
- data/documentation/site/reference/quickbooks_online/resources/subsidiary.md +20 -0
- data/documentation/site/reference/quickbooks_online/resources/transfer.md +42 -0
- data/documentation/site/reference/quickbooks_online/resources/vendor.md +43 -0
- data/documentation/site/reference/quickbooks_online/webhooks/index.md +42 -0
- data/documentation/site/reference/stripe/index.md +6 -0
- data/documentation/site/reference/stripe/resources/customer.md +45 -0
- data/documentation/site/reference/stripe/resources/index.md +8 -0
- data/documentation/site/reference/stripe/resources/resource.md +18 -0
- data/documentation/site/style-guide.md +137 -0
- data/ledger_sync.gemspec +6 -2
- data/lib/ledger_sync.rb +45 -57
- data/lib/ledger_sync/core_ext/resonad.rb +2 -2
- data/lib/ledger_sync/deserializer.rb +108 -0
- data/lib/ledger_sync/error.rb +15 -0
- data/lib/ledger_sync/error/{adaptor_errors.rb → ledger_errors.rb} +13 -13
- data/lib/ledger_sync/error/operation_errors.rb +0 -10
- data/lib/ledger_sync/error/resource_errors.rb +48 -19
- data/lib/ledger_sync/{adaptor_configuration.rb → ledger_configuration.rb} +12 -12
- data/lib/ledger_sync/ledger_configuration_store.rb +56 -0
- data/lib/ledger_sync/ledgers/client.rb +112 -0
- data/lib/ledger_sync/{adaptors → ledgers}/contract.rb +1 -1
- data/lib/ledger_sync/ledgers/dashboard_url_helper.rb +23 -0
- data/lib/ledger_sync/ledgers/mixins/infer_client_mixin.rb +28 -0
- data/lib/ledger_sync/{adaptors → ledgers}/mixins/infer_resource_class_mixin.rb +5 -2
- data/lib/ledger_sync/ledgers/mixins/infer_serializer_mixin.rb +52 -0
- data/lib/ledger_sync/{adaptors → ledgers}/mixins/infer_validation_contract_mixin.rb +1 -1
- data/lib/ledger_sync/{adaptors → ledgers}/mixins/offset_and_limit_pagination_searcher_mixin.rb +1 -1
- data/lib/ledger_sync/ledgers/mixins/serialization_mixin.rb +41 -0
- data/lib/ledger_sync/ledgers/netsuite/account/deserializer.rb +23 -0
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/account/operations/create.rb +5 -5
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/account/operations/find.rb +4 -4
- data/lib/ledger_sync/ledgers/netsuite/account/searcher.rb +12 -0
- data/lib/ledger_sync/ledgers/netsuite/account/searcher_deserializer.rb +29 -0
- data/lib/ledger_sync/ledgers/netsuite/account/serializer.rb +21 -0
- data/lib/ledger_sync/ledgers/netsuite/check/deserializer.rb +29 -0
- data/lib/ledger_sync/ledgers/netsuite/check/operations/create.rb +27 -0
- data/lib/ledger_sync/ledgers/netsuite/check/operations/delete.rb +27 -0
- data/lib/ledger_sync/ledgers/netsuite/check/operations/find.rb +27 -0
- data/lib/ledger_sync/ledgers/netsuite/check/operations/update.rb +27 -0
- data/lib/ledger_sync/ledgers/netsuite/check/searcher.rb +15 -0
- data/lib/ledger_sync/ledgers/netsuite/check/searcher_deserializer.rb +16 -0
- data/lib/ledger_sync/ledgers/netsuite/check/serializer.rb +51 -0
- data/lib/ledger_sync/ledgers/netsuite/check_line_item/deserializer.rb +17 -0
- data/lib/ledger_sync/ledgers/netsuite/check_line_item/serializer.rb +25 -0
- data/lib/ledger_sync/{adaptors/netsuite/adaptor.rb → ledgers/netsuite/client.rb} +57 -18
- data/lib/ledger_sync/ledgers/netsuite/config.rb +5 -0
- data/lib/ledger_sync/ledgers/netsuite/currency/deserializer.rb +23 -0
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/currency/operations/create.rb +4 -4
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/currency/operations/delete.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/currency/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/currency/operations/update.rb +3 -3
- data/lib/ledger_sync/ledgers/netsuite/currency/serializer.rb +21 -0
- data/lib/ledger_sync/ledgers/netsuite/customer/deserializer.rb +22 -0
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/customer/operations/create.rb +8 -6
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/customer/operations/delete.rb +7 -5
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/customer/operations/find.rb +7 -5
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/customer/operations/update.rb +7 -5
- data/lib/ledger_sync/ledgers/netsuite/customer/searcher.rb +12 -0
- data/lib/ledger_sync/ledgers/netsuite/customer/searcher_deserializer.rb +18 -0
- data/lib/ledger_sync/ledgers/netsuite/customer/serializer.rb +29 -0
- data/lib/ledger_sync/ledgers/netsuite/customer_deposit/deserializer.rb +20 -0
- data/lib/ledger_sync/ledgers/netsuite/customer_deposit/operations/create.rb +24 -0
- data/lib/ledger_sync/ledgers/netsuite/customer_deposit/operations/delete.rb +24 -0
- data/lib/ledger_sync/ledgers/netsuite/customer_deposit/operations/find.rb +24 -0
- data/lib/ledger_sync/ledgers/netsuite/customer_deposit/operations/update.rb +24 -0
- data/lib/ledger_sync/ledgers/netsuite/customer_deposit/searcher.rb +12 -0
- data/lib/ledger_sync/ledgers/netsuite/customer_deposit/searcher_deserializer.rb +16 -0
- data/lib/ledger_sync/ledgers/netsuite/customer_deposit/serializer.rb +25 -0
- data/lib/ledger_sync/ledgers/netsuite/dashboard_url_helper.rb +28 -0
- data/lib/ledger_sync/ledgers/netsuite/department/deserializer.rb +15 -0
- data/lib/ledger_sync/ledgers/netsuite/department/operations/create.rb +25 -0
- data/lib/ledger_sync/ledgers/netsuite/department/operations/delete.rb +25 -0
- data/lib/ledger_sync/ledgers/netsuite/department/operations/find.rb +25 -0
- data/lib/ledger_sync/ledgers/netsuite/department/operations/update.rb +25 -0
- data/lib/ledger_sync/ledgers/netsuite/department/searcher.rb +12 -0
- data/lib/ledger_sync/ledgers/netsuite/department/searcher_deserializer.rb +19 -0
- data/lib/ledger_sync/ledgers/netsuite/department/serializer.rb +13 -0
- data/lib/ledger_sync/ledgers/netsuite/deserializer.rb +18 -0
- data/lib/ledger_sync/ledgers/netsuite/error.rb +18 -0
- data/lib/ledger_sync/ledgers/netsuite/journal_entry/deserializer.rb +31 -0
- data/lib/ledger_sync/ledgers/netsuite/journal_entry/operations/create.rb +26 -0
- data/lib/ledger_sync/ledgers/netsuite/journal_entry/operations/delete.rb +26 -0
- data/lib/ledger_sync/ledgers/netsuite/journal_entry/operations/find.rb +26 -0
- data/lib/ledger_sync/ledgers/netsuite/journal_entry/operations/update.rb +30 -0
- data/lib/ledger_sync/ledgers/netsuite/journal_entry/serializer.rb +36 -0
- data/lib/ledger_sync/ledgers/netsuite/journal_entry_line_item/deserializer.rb +23 -0
- data/lib/ledger_sync/ledgers/netsuite/journal_entry_line_item/serializer.rb +21 -0
- data/lib/ledger_sync/ledgers/netsuite/ledger_class/deserializer.rb +15 -0
- data/lib/ledger_sync/ledgers/netsuite/ledger_class/operations/create.rb +25 -0
- data/lib/ledger_sync/ledgers/netsuite/ledger_class/operations/delete.rb +25 -0
- data/lib/ledger_sync/ledgers/netsuite/ledger_class/operations/find.rb +25 -0
- data/lib/ledger_sync/ledgers/netsuite/ledger_class/operations/update.rb +25 -0
- data/lib/ledger_sync/ledgers/netsuite/ledger_class/searcher.rb +12 -0
- data/lib/ledger_sync/ledgers/netsuite/ledger_class/searcher_deserializer.rb +19 -0
- data/lib/ledger_sync/ledgers/netsuite/ledger_class/serializer.rb +13 -0
- data/lib/ledger_sync/ledgers/netsuite/location/deserializer.rb +15 -0
- data/lib/ledger_sync/ledgers/netsuite/location/operations/create.rb +21 -0
- data/lib/ledger_sync/ledgers/netsuite/location/operations/delete.rb +21 -0
- data/lib/ledger_sync/ledgers/netsuite/location/operations/find.rb +21 -0
- data/lib/ledger_sync/ledgers/netsuite/location/operations/update.rb +21 -0
- data/lib/ledger_sync/ledgers/netsuite/location/searcher.rb +12 -0
- data/lib/ledger_sync/ledgers/netsuite/location/serializer.rb +13 -0
- data/lib/ledger_sync/ledgers/netsuite/operation.rb +40 -0
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/operation/create.rb +6 -13
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/operation/delete.rb +4 -4
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/operation/find.rb +9 -5
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/operation/update.rb +6 -13
- data/lib/ledger_sync/ledgers/netsuite/record/http_method.rb +33 -0
- data/lib/ledger_sync/ledgers/netsuite/record/metadata.rb +105 -0
- data/lib/ledger_sync/ledgers/netsuite/record/parameter.rb +20 -0
- data/lib/ledger_sync/ledgers/netsuite/record/property.rb +22 -0
- data/lib/ledger_sync/ledgers/netsuite/reference/serializer.rb +13 -0
- data/lib/ledger_sync/ledgers/netsuite/resource.rb +10 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/account.rb +44 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/check.rb +23 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/check_line_item.rb +15 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/currency.rb +13 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/customer.rb +19 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/customer_deposit.rb +15 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/department.rb +16 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/deposit.rb +28 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/deposit_line_item.rb +25 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/invoice.rb +28 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/invoice_line_item.rb +21 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/item.rb +11 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/journal_entry.rb +26 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/journal_entry_line_item.rb +24 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/ledger_class.rb +16 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/location.rb +11 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/subsidiary.rb +12 -0
- data/lib/ledger_sync/ledgers/netsuite/resources/vendor.rb +23 -0
- data/lib/ledger_sync/ledgers/netsuite/searcher.rb +64 -0
- data/lib/ledger_sync/ledgers/netsuite/serializer.rb +13 -0
- data/lib/ledger_sync/ledgers/netsuite/subsidiary/deserializer.rb +17 -0
- data/lib/ledger_sync/ledgers/netsuite/subsidiary/searcher.rb +12 -0
- data/lib/ledger_sync/ledgers/netsuite/subsidiary/searcher_deserializer.rb +15 -0
- data/lib/ledger_sync/ledgers/netsuite/subsidiary/serializer.rb +15 -0
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/token.rb +18 -22
- data/lib/ledger_sync/ledgers/netsuite/type/deserializer_active_type.rb +32 -0
- data/lib/ledger_sync/ledgers/netsuite/type/deserializer_customer_type.rb +33 -0
- data/lib/ledger_sync/ledgers/netsuite/type/deserializer_entity_type.rb +30 -0
- data/lib/ledger_sync/ledgers/netsuite/type/deserializer_subsidiary_type.rb +33 -0
- data/lib/ledger_sync/ledgers/netsuite/vendor/deserializer.rb +30 -0
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/vendor/operations/create.rb +4 -4
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/vendor/operations/delete.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/vendor/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite/vendor/operations/update.rb +3 -3
- data/lib/ledger_sync/ledgers/netsuite/vendor/searcher.rb +12 -0
- data/lib/ledger_sync/ledgers/netsuite/vendor/searcher_deserializer.rb +21 -0
- data/lib/ledger_sync/ledgers/netsuite/vendor/serializer.rb +30 -0
- data/lib/ledger_sync/{adaptors/netsuite_soap/adaptor.rb → ledgers/netsuite_soap/client.rb} +2 -2
- data/lib/ledger_sync/ledgers/netsuite_soap/config.rb +5 -0
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite_soap/customer/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite_soap/customer/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite_soap/operation.rb +5 -5
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite_soap/operation/create.rb +5 -5
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite_soap/operation/find.rb +2 -2
- data/lib/ledger_sync/ledgers/netsuite_soap/resource.rb +10 -0
- data/lib/ledger_sync/ledgers/netsuite_soap/resources/customer.rb +29 -0
- data/lib/ledger_sync/ledgers/netsuite_soap/resources/subsidiary.rb +12 -0
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite_soap/subsidiary/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/netsuite_soap/subsidiary/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/operation.rb +39 -34
- data/lib/ledger_sync/ledgers/quickbooks_online/account/deserializer.rb +43 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/account/operations/create.rb +4 -4
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/account/operations/find.rb +4 -4
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/account/operations/update.rb +4 -4
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/account/searcher.rb +2 -2
- data/lib/ledger_sync/ledgers/quickbooks_online/account/serializer.rb +37 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/bill/deserializer.rb +45 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/bill/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/bill/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/bill/operations/update.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/bill/searcher.rb +2 -2
- data/lib/ledger_sync/ledgers/quickbooks_online/bill/serializer.rb +44 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/bill_line_item/deserializer.rb +25 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/bill_line_item/serializer.rb +29 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/bill_payment/deserializer.rb +59 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/bill_payment/operations/create.rb +33 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/bill_payment/operations/find.rb +33 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/bill_payment/operations/update.rb +33 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/bill_payment/serializer.rb +77 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/bill_payment_line_item/deserializer.rb +18 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/bill_payment_line_item/serializer.rb +18 -0
- data/lib/ledger_sync/{adaptors/quickbooks_online/adaptor.rb → ledgers/quickbooks_online/client.rb} +21 -21
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/config.rb +1 -1
- data/lib/ledger_sync/ledgers/quickbooks_online/currency/deserializer.rb +17 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/currency/serializer.rb +16 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/customer/deserializer.rb +19 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/customer/operations/create.rb +26 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/customer/operations/find.rb +26 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/customer/operations/update.rb +8 -6
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/customer/searcher.rb +3 -3
- data/lib/ledger_sync/ledgers/quickbooks_online/customer/serializer.rb +19 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/dashboard_url_helper.rb +34 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/department/deserializer.rb +28 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/department/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/department/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/department/operations/update.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/department/searcher.rb +3 -3
- data/lib/ledger_sync/ledgers/quickbooks_online/department/serializer.rb +49 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/deposit/deserializer.rb +39 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/deposit/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/deposit/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/deposit/operations/update.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/deposit/searcher.rb +2 -2
- data/lib/ledger_sync/ledgers/quickbooks_online/deposit/serializer.rb +39 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/deposit_line_item/deserializer.rb +38 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/deposit_line_item/serializer.rb +41 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/deserializer.rb +98 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/expense/deserializer.rb +58 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/expense/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/expense/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/expense/operations/update.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/expense/searcher.rb +2 -2
- data/lib/ledger_sync/ledgers/quickbooks_online/expense/serializer.rb +59 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/expense_line_item/deserializer.rb +25 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/expense_line_item/serializer.rb +27 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/invoice/deserializer.rb +35 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/invoice/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/invoice/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/invoice/operations/update.rb +3 -3
- data/lib/ledger_sync/ledgers/quickbooks_online/invoice/serializer.rb +35 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/invoice_sales_line_item/deserializer.rb +25 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/invoice_sales_line_item/serializer.rb +29 -0
- data/lib/ledger_sync/{adaptors/quickbooks_online/item/ledger_serializer.rb → ledgers/quickbooks_online/item/deserializer.rb} +3 -3
- data/lib/ledger_sync/ledgers/quickbooks_online/item/serializer.rb +12 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/journal_entry/deserializer.rb +33 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/journal_entry/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/journal_entry/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/journal_entry/operations/update.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/journal_entry/searcher.rb +2 -2
- data/lib/ledger_sync/ledgers/quickbooks_online/journal_entry/serializer.rb +33 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/journal_entry_line_item/deserializer.rb +32 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/journal_entry_line_item/serializer.rb +36 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/ledger_class/deserializer.rb +29 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/ledger_class/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/ledger_class/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/ledger_class/operations/update.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/ledger_class/searcher.rb +3 -3
- data/lib/ledger_sync/{adaptors/quickbooks_online/ledger_class/ledger_serializer.rb → ledgers/quickbooks_online/ledger_class/serializer.rb} +8 -9
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/oauth_client.rb +1 -1
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/operation.rb +8 -7
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/operation/create.rb +4 -4
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/operation/find.rb +3 -9
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/operation/full_update.rb +11 -12
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/operation/sparse_update.rb +5 -5
- data/lib/ledger_sync/ledgers/quickbooks_online/payment/deserializer.rb +48 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/payment/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/payment/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/payment/operations/update.rb +3 -3
- data/lib/ledger_sync/ledgers/quickbooks_online/payment/serializer.rb +48 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/payment_line_item/deserializer.rb +18 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/payment_line_item/serializer.rb +18 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/preferences/deserializer.rb +43 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/preferences/operations/find.rb +30 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/preferences/serializer.rb +43 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/request.rb +13 -13
- data/lib/ledger_sync/ledgers/quickbooks_online/resource.rb +10 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/account.rb +355 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/bill.rb +31 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/bill_line_item.rb +21 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/bill_payment.rb +42 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/bill_payment_line_item.rb +19 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/currency.rb +13 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/customer.rb +19 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/department.rb +16 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/deposit.rb +28 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/deposit_line_item.rb +25 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/expense.rb +40 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/expense_line_item.rb +21 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/invoice.rb +28 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/invoice_sales_line_item.rb +21 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/item.rb +11 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/journal_entry.rb +24 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/journal_entry_line_item.rb +29 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/ledger_class.rb +16 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/payment.rb +31 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/payment_line_item.rb +19 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/preferences.rb +24 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/primary_email_addr.rb +11 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/primary_phone.rb +11 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/subsidiary.rb +12 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/transfer.rb +24 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/resources/vendor.rb +23 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/searcher.rb +6 -7
- data/lib/ledger_sync/ledgers/quickbooks_online/serialization/type/amount_float_to_integer_type.rb +21 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb +30 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/serialization/type/integer_to_amount_float_type.rb +21 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb +30 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/serializer.rb +71 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/serialziation/type/mapping_type.rb +25 -0
- data/lib/ledger_sync/ledgers/quickbooks_online/transfer/deserializer.rb +34 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/transfer/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/transfer/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/transfer/operations/update.rb +3 -3
- data/lib/ledger_sync/ledgers/quickbooks_online/transfer/serializer.rb +34 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/util/error_matcher.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/util/error_parser.rb +3 -3
- data/lib/ledger_sync/{adaptors/quickbooks_online/util/adaptor_error_parser.rb → ledgers/quickbooks_online/util/ledger_error_parser.rb} +16 -16
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/util/operation_error_parser.rb +7 -7
- data/lib/ledger_sync/ledgers/quickbooks_online/vendor/deserializer.rb +25 -0
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/vendor/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/vendor/operations/find.rb +4 -4
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/vendor/operations/update.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/vendor/searcher.rb +2 -2
- data/lib/ledger_sync/{adaptors/quickbooks_online/vendor/ledger_serializer.rb → ledgers/quickbooks_online/vendor/serializer.rb} +7 -7
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/webhook.rb +1 -1
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/webhook_event.rb +9 -9
- data/lib/ledger_sync/{adaptors → ledgers}/quickbooks_online/webhook_notification.rb +1 -1
- data/lib/ledger_sync/{adaptors → ledgers}/request.rb +11 -7
- data/lib/ledger_sync/{adaptors → ledgers}/response.rb +1 -1
- data/lib/ledger_sync/{adaptors → ledgers}/searcher.rb +13 -8
- data/lib/ledger_sync/ledgers/stripe/client.rb +37 -0
- data/lib/ledger_sync/{adaptors → ledgers}/stripe/config.rb +1 -1
- data/lib/ledger_sync/{adaptors → ledgers}/stripe/customer/operations/create.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/stripe/customer/operations/delete.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/stripe/customer/operations/find.rb +3 -3
- data/lib/ledger_sync/{adaptors → ledgers}/stripe/customer/operations/update.rb +3 -3
- data/lib/ledger_sync/ledgers/stripe/dashboard_url_helper.rb +21 -0
- data/lib/ledger_sync/{adaptors → ledgers}/stripe/operation.rb +5 -5
- data/lib/ledger_sync/{adaptors → ledgers}/stripe/operation/create.rb +2 -2
- data/lib/ledger_sync/{adaptors → ledgers}/stripe/operation/delete.rb +2 -2
- data/lib/ledger_sync/{adaptors → ledgers}/stripe/operation/find.rb +2 -2
- data/lib/ledger_sync/{adaptors → ledgers}/stripe/operation/update.rb +2 -2
- data/lib/ledger_sync/ledgers/stripe/resource.rb +10 -0
- data/lib/ledger_sync/ledgers/stripe/resources/customer.rb +13 -0
- data/lib/ledger_sync/operation.rb +23 -0
- data/lib/ledger_sync/resource.rb +22 -10
- data/lib/ledger_sync/resource_adaptor.rb +52 -0
- data/lib/ledger_sync/resource_attribute.rb +31 -9
- data/lib/ledger_sync/resource_attribute/dirty_mixin.rb +4 -0
- data/lib/ledger_sync/resource_attribute/mixin.rb +14 -24
- data/lib/ledger_sync/resource_attribute/reference/many.rb +21 -23
- data/lib/ledger_sync/resource_attribute/reference/one.rb +16 -5
- data/lib/ledger_sync/resource_attribute_set.rb +3 -7
- data/lib/ledger_sync/result.rb +3 -3
- data/lib/ledger_sync/serialization/attribute.rb +41 -0
- data/lib/ledger_sync/serialization/attribute_set_mixin.rb +27 -0
- data/lib/ledger_sync/serialization/deserializer_attribute.rb +78 -0
- data/lib/ledger_sync/serialization/deserializer_attribute_set.rb +22 -0
- data/lib/ledger_sync/serialization/mixin.rb +70 -0
- data/lib/ledger_sync/serialization/serializer_attribute.rb +64 -0
- data/lib/ledger_sync/serialization/serializer_attribute_set.rb +22 -0
- data/lib/ledger_sync/serialization/type/deserializer_references_many_type.rb +26 -0
- data/lib/ledger_sync/serialization/type/deserializer_references_one_type.rb +12 -0
- data/lib/ledger_sync/serialization/type/deserializer_type.rb +29 -0
- data/lib/ledger_sync/serialization/type/format_date_type.rb +23 -0
- data/lib/ledger_sync/serialization/type/mapping_type.rb +23 -0
- data/lib/ledger_sync/serialization/type/parse_date_type.rb +23 -0
- data/lib/ledger_sync/serialization/type/serializer_references_many_type.rb +21 -0
- data/lib/ledger_sync/serialization/type/serializer_references_one_type.rb +12 -0
- data/lib/ledger_sync/serialization/type/serializer_type.rb +23 -0
- data/lib/ledger_sync/serializer.rb +95 -0
- data/lib/ledger_sync/type/boolean.rb +2 -0
- data/lib/ledger_sync/type/date.rb +3 -1
- data/lib/ledger_sync/type/float.rb +2 -0
- data/lib/ledger_sync/type/hash.rb +38 -0
- data/lib/ledger_sync/type/id.rb +8 -2
- data/lib/ledger_sync/type/integer.rb +2 -0
- data/lib/ledger_sync/type/reference_many.rb +15 -5
- data/lib/ledger_sync/type/reference_one.rb +9 -18
- data/lib/ledger_sync/type/string.rb +2 -0
- data/lib/ledger_sync/type/string_from_set.rb +43 -0
- data/lib/ledger_sync/type/value_mixin.rb +37 -7
- data/lib/ledger_sync/util/mixins/delegate_iterable_methods_mixin.rb +43 -0
- data/lib/ledger_sync/util/mixins/dupable_mixin.rb +13 -0
- data/lib/ledger_sync/util/mixins/resource_registerable_mixin.rb +29 -0
- data/lib/ledger_sync/util/read_only_object.rb +54 -0
- data/lib/ledger_sync/util/resource_converter.rb +113 -0
- data/lib/ledger_sync/util/resource_converter/attribute.rb +131 -0
- data/lib/ledger_sync/util/resource_converter/attribute_set.rb +42 -0
- data/lib/ledger_sync/util/resource_converter/type/references_many_type.rb +27 -0
- data/lib/ledger_sync/util/resource_converter/type/references_one_type.rb +14 -0
- data/lib/ledger_sync/util/resource_converter/type/resource_converter_type.rb +26 -0
- data/lib/ledger_sync/util/resources_builder.rb +19 -11
- data/lib/ledger_sync/util/string_helpers.rb +3 -3
- data/lib/ledger_sync/util/url_helpers.rb +38 -0
- data/lib/ledger_sync/util/validator.rb +3 -1
- data/lib/ledger_sync/version.rb +1 -1
- data/licenses/BSL.txt +97 -0
- data/licenses/documentation_site.txt +7 -0
- metadata +621 -229
- data/_config.yml +0 -1
- data/lib/ledger_sync/adaptor_configuration_store.rb +0 -56
- data/lib/ledger_sync/adaptors/adaptor.rb +0 -74
- data/lib/ledger_sync/adaptors/ledger_serializer.rb +0 -143
- data/lib/ledger_sync/adaptors/ledger_serializer_attribute.rb +0 -178
- data/lib/ledger_sync/adaptors/ledger_serializer_attribute_set.rb +0 -58
- data/lib/ledger_sync/adaptors/ledger_serializer_type/mapping_type.rb +0 -41
- data/lib/ledger_sync/adaptors/ledger_serializer_type/references_many_type.rb +0 -24
- data/lib/ledger_sync/adaptors/ledger_serializer_type/references_one_type.rb +0 -22
- data/lib/ledger_sync/adaptors/ledger_serializer_type/value_type.rb +0 -17
- data/lib/ledger_sync/adaptors/mixins/infer_adaptor_class_mixin.rb +0 -24
- data/lib/ledger_sync/adaptors/mixins/infer_ledger_serializer_mixin.rb +0 -45
- data/lib/ledger_sync/adaptors/netsuite/account/ledger_deserializer.rb +0 -24
- data/lib/ledger_sync/adaptors/netsuite/account/ledger_serializer.rb +0 -22
- data/lib/ledger_sync/adaptors/netsuite/account/searcher.rb +0 -28
- data/lib/ledger_sync/adaptors/netsuite/config.rb +0 -5
- data/lib/ledger_sync/adaptors/netsuite/currency/deledger_serializer.rb +0 -28
- data/lib/ledger_sync/adaptors/netsuite/currency/ledger_serializer.rb +0 -25
- data/lib/ledger_sync/adaptors/netsuite/customer/ledger_deserializer.rb +0 -27
- data/lib/ledger_sync/adaptors/netsuite/customer/ledger_serializer.rb +0 -38
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer.rb +0 -30
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer_type/reference_type.rb +0 -24
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer_type/subsidiary_type.rb +0 -22
- data/lib/ledger_sync/adaptors/netsuite/operation.rb +0 -19
- data/lib/ledger_sync/adaptors/netsuite/record/http_method.rb +0 -38
- data/lib/ledger_sync/adaptors/netsuite/record/metadata.rb +0 -75
- data/lib/ledger_sync/adaptors/netsuite/record/property.rb +0 -45
- data/lib/ledger_sync/adaptors/netsuite/searcher.rb +0 -17
- data/lib/ledger_sync/adaptors/netsuite/vendor/ledger_deserializer.rb +0 -32
- data/lib/ledger_sync/adaptors/netsuite/vendor/ledger_serializer.rb +0 -35
- data/lib/ledger_sync/adaptors/netsuite_soap/config.rb +0 -5
- data/lib/ledger_sync/adaptors/netsuite_soap/customer/ledger_serializer.rb +0 -13
- data/lib/ledger_sync/adaptors/netsuite_soap/ledger_serializer.rb +0 -25
- data/lib/ledger_sync/adaptors/quickbooks_online/account/ledger_serializer.rb +0 -37
- data/lib/ledger_sync/adaptors/quickbooks_online/bill/ledger_serializer.rb +0 -46
- data/lib/ledger_sync/adaptors/quickbooks_online/bill_line_item/ledger_serializer.rb +0 -30
- data/lib/ledger_sync/adaptors/quickbooks_online/currency/ledger_serializer.rb +0 -17
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/ledger_serializer.rb +0 -23
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/operations/create.rb +0 -22
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/operations/find.rb +0 -22
- data/lib/ledger_sync/adaptors/quickbooks_online/dashboard_url_helper.rb +0 -59
- data/lib/ledger_sync/adaptors/quickbooks_online/department/ledger_serializer.rb +0 -38
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/ledger_serializer.rb +0 -40
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit_line_item/ledger_serializer.rb +0 -34
- data/lib/ledger_sync/adaptors/quickbooks_online/expense/ledger_serializer.rb +0 -52
- data/lib/ledger_sync/adaptors/quickbooks_online/expense_line_item/ledger_serializer.rb +0 -30
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice/ledger_serializer.rb +0 -36
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice_sales_line_item/ledger_serializer.rb +0 -30
- data/lib/ledger_sync/adaptors/quickbooks_online/journal_entry/ledger_serializer.rb +0 -34
- data/lib/ledger_sync/adaptors/quickbooks_online/journal_entry_line_item/ledger_serializer.rb +0 -37
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer.rb +0 -131
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/account_sub_type.rb +0 -305
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/account_type.rb +0 -51
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/amount_type.rb +0 -23
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/classification_type.rb +0 -23
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/date_type.rb +0 -23
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/entity_reference_type.rb +0 -49
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/journal_entry_line_item_type.rb +0 -20
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/payment_type.rb +0 -21
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/transaction_reference_type.rb +0 -49
- data/lib/ledger_sync/adaptors/quickbooks_online/payment/ledger_serializer.rb +0 -50
- data/lib/ledger_sync/adaptors/quickbooks_online/payment_line_item/ledger_serializer.rb +0 -19
- data/lib/ledger_sync/adaptors/quickbooks_online/transfer/ledger_serializer.rb +0 -36
- data/lib/ledger_sync/adaptors/stripe/adaptor.rb +0 -45
- data/lib/ledger_sync/adaptors/test/customer/ledger_serializer.rb +0 -12
- data/lib/ledger_sync/adaptors/test/ledger_serializer.rb +0 -12
- data/lib/ledger_sync/resources/account.rb +0 -17
- data/lib/ledger_sync/resources/bill.rb +0 -27
- data/lib/ledger_sync/resources/bill_line_item.rb +0 -17
- data/lib/ledger_sync/resources/currency.rb +0 -9
- data/lib/ledger_sync/resources/customer.rb +0 -25
- data/lib/ledger_sync/resources/department.rb +0 -14
- data/lib/ledger_sync/resources/deposit.rb +0 -24
- data/lib/ledger_sync/resources/deposit_line_item.rb +0 -22
- data/lib/ledger_sync/resources/expense.rb +0 -33
- data/lib/ledger_sync/resources/expense_line_item.rb +0 -17
- data/lib/ledger_sync/resources/invoice.rb +0 -24
- data/lib/ledger_sync/resources/invoice_sales_line_item.rb +0 -17
- data/lib/ledger_sync/resources/item.rb +0 -5
- data/lib/ledger_sync/resources/journal_entry.rb +0 -20
- data/lib/ledger_sync/resources/journal_entry_line_item.rb +0 -20
- data/lib/ledger_sync/resources/ledger_class.rb +0 -14
- data/lib/ledger_sync/resources/payment.rb +0 -27
- data/lib/ledger_sync/resources/payment_line_item.rb +0 -15
- data/lib/ledger_sync/resources/subsidiary.rb +0 -8
- data/lib/ledger_sync/resources/transfer.rb +0 -20
- data/lib/ledger_sync/resources/vendor.rb +0 -19
- data/qa/env_spec.rb +0 -5
- data/qa/netsuite/account_spec.rb +0 -20
- data/qa/netsuite/currency_spec.rb +0 -16
- data/qa/netsuite/customer.rb +0 -76
- data/qa/netsuite/customer_spec.rb +0 -21
- data/qa/netsuite/vendor.rb +0 -76
- data/qa/netsuite/vendor_spec.rb +0 -23
- data/qa/netsuite_soap/customer_spec.rb +0 -21
- data/qa/netsuite_soap/subsidiary_spec.rb +0 -0
- data/qa/qa_helper.rb +0 -58
- data/qa/quickbooks_online/account_spec.rb +0 -14
- data/qa/quickbooks_online/customer_spec.rb +0 -13
- data/qa/quickbooks_online/expense_spec.rb +0 -31
- data/qa/quickbooks_online/vendor_spec.rb +0 -13
- data/qa/stripe/customers_spec.rb +0 -15
- data/qa/support/adaptor_helpers.rb +0 -99
- data/qa/support/adaptor_support_setup.rb +0 -23
- data/qa/support/netsuite_helpers.rb +0 -33
- data/qa/support/netsuite_shared_examples.rb +0 -30
- data/qa/support/netsuite_soap_helpers.rb +0 -33
- data/qa/support/netsuite_soap_shared_examples.rb +0 -10
- data/qa/support/quickbooks_online_helpers.rb +0 -42
- data/qa/support/quickbooks_online_shared_examples.rb +0 -82
- data/qa/support/shared_examples.rb +0 -127
- data/qa/support/stripe_helpers.rb +0 -22
- data/qa/support/stripe_shared_examples.rb +0 -10
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'resource_converter/attribute_set'
|
|
4
|
+
require_relative 'resource_converter/attribute'
|
|
5
|
+
Gem.find_files('ledger_sync/util/resource_converter/type/**/*.rb').each { |path| require path }
|
|
6
|
+
|
|
7
|
+
module LedgerSync
|
|
8
|
+
module Util
|
|
9
|
+
class ResourceConverter
|
|
10
|
+
def convert(args = {})
|
|
11
|
+
destination = args.fetch(:destination).dup
|
|
12
|
+
destination = Util::HashHelpers.deep_stringify_keys(destination) if destination.is_a?(Hash)
|
|
13
|
+
only_changes = args.fetch(:only_changes, false)
|
|
14
|
+
source = args.fetch(:source).dup
|
|
15
|
+
source = Util::HashHelpers.deep_stringify_keys(source) if source.is_a?(Hash)
|
|
16
|
+
|
|
17
|
+
if source.is_a?(Hash) && args.key?(:only_changes)
|
|
18
|
+
raise 'only_changes can only be passed when the source is a resource'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
self.class.attributes.each do |converter_attribute|
|
|
22
|
+
next if only_changes && !source.attribute_changed?(converter_attribute.source_attribute)
|
|
23
|
+
|
|
24
|
+
args_to_pass = {
|
|
25
|
+
destination: destination,
|
|
26
|
+
source: source
|
|
27
|
+
}
|
|
28
|
+
next if converter_attribute.if_method.present? && !send(converter_attribute.if_method, args_to_pass)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# This is for in place changes
|
|
32
|
+
destination = converter_attribute.build_destination!(args_to_pass)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
destination
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self._attribute(destination_attribute = nil, args = {}, &block)
|
|
39
|
+
if args.key?(:destination_attribute)
|
|
40
|
+
raise 'You cannot provide destination_attribute in args. Pass the value as the first argument.'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
attributes.add(
|
|
44
|
+
ResourceConverter::Attribute.new(
|
|
45
|
+
args.merge(
|
|
46
|
+
block: (block if block_given?),
|
|
47
|
+
destination_attribute: destination_attribute
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.attribute(*args, &block)
|
|
54
|
+
_attribute(*args, &block)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.attributes
|
|
58
|
+
@attributes ||= ResourceConverter::AttributeSet.new(resource_converter_class: self)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self._references(destination_attribute = nil, args = {}, &block)
|
|
62
|
+
reference_type = args.fetch(:reference_type)
|
|
63
|
+
resource_converter = args.fetch(:resource_converter)
|
|
64
|
+
|
|
65
|
+
reference_type_class = case reference_type
|
|
66
|
+
when :many
|
|
67
|
+
ResourceConverter::Type::ReferencesManyType
|
|
68
|
+
when :one
|
|
69
|
+
ResourceConverter::Type::ReferencesOneType
|
|
70
|
+
else
|
|
71
|
+
raise "Unkown reference type: #{references_type}"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
_attribute(
|
|
75
|
+
destination_attribute,
|
|
76
|
+
{
|
|
77
|
+
type: reference_type_class.new(
|
|
78
|
+
resource_converter: resource_converter
|
|
79
|
+
)
|
|
80
|
+
}.merge(
|
|
81
|
+
args.except(
|
|
82
|
+
%i[
|
|
83
|
+
reference_type
|
|
84
|
+
resource_converter
|
|
85
|
+
]
|
|
86
|
+
)
|
|
87
|
+
),
|
|
88
|
+
&block
|
|
89
|
+
)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def self.references_one(destination_attribute = nil, args = {}, &block)
|
|
93
|
+
_references(
|
|
94
|
+
destination_attribute,
|
|
95
|
+
{
|
|
96
|
+
reference_type: :one
|
|
97
|
+
}.merge(args),
|
|
98
|
+
&block
|
|
99
|
+
)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def self.references_many(destination_attribute = nil, args = {}, &block)
|
|
103
|
+
_references(
|
|
104
|
+
destination_attribute,
|
|
105
|
+
{
|
|
106
|
+
reference_type: :many
|
|
107
|
+
}.merge(args),
|
|
108
|
+
&block
|
|
109
|
+
)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Gem.find_files('ledger_sync/serialization/type/**/*.rb').each { |path| require path }
|
|
4
|
+
|
|
5
|
+
module LedgerSync
|
|
6
|
+
module Util
|
|
7
|
+
class ResourceConverter
|
|
8
|
+
class Attribute
|
|
9
|
+
attr_reader :block,
|
|
10
|
+
:destination_attribute,
|
|
11
|
+
:if_method,
|
|
12
|
+
:source_attribute,
|
|
13
|
+
:type
|
|
14
|
+
|
|
15
|
+
def initialize(args = {})
|
|
16
|
+
@block = args.fetch(:block, nil)
|
|
17
|
+
@destination_attribute = args.fetch(:destination_attribute, nil).to_s
|
|
18
|
+
@source_attribute = args.fetch(:source_attribute, destination_attribute).to_s
|
|
19
|
+
@type = args.fetch(:type, nil) || LedgerSync::Type::Value.new
|
|
20
|
+
@if_method = args.fetch(:if, nil)
|
|
21
|
+
|
|
22
|
+
return if block.blank?
|
|
23
|
+
|
|
24
|
+
raise 'block cannot be provided on references' if reference?
|
|
25
|
+
raise 'block and destination_attribute cannot both be present' if destination_attribute.present?
|
|
26
|
+
raise 'block and source_attribute cannot both be present' if source_attribute.present?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def block?
|
|
30
|
+
block.present?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def block_value_for(args = {})
|
|
34
|
+
destination = args.fetch(:destination).dup
|
|
35
|
+
source = args.fetch(:source).dup
|
|
36
|
+
|
|
37
|
+
new_destination = block.call(
|
|
38
|
+
{
|
|
39
|
+
attribute: self,
|
|
40
|
+
destination: destination,
|
|
41
|
+
source: source
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return new_destination if destination.class == new_destination.class
|
|
46
|
+
|
|
47
|
+
raise "Block value must be the same class as the destination: #{destination.class}"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def build_destination!(args = {})
|
|
51
|
+
destination = args.fetch(:destination)
|
|
52
|
+
destination = Util::HashHelpers.deep_stringify_keys(destination) if destination.is_a?(Hash)
|
|
53
|
+
source = args.fetch(:source).dup
|
|
54
|
+
source = Util::HashHelpers.deep_stringify_keys(source) if source.is_a?(Hash)
|
|
55
|
+
|
|
56
|
+
if block?
|
|
57
|
+
return block_value_for(
|
|
58
|
+
destination: destination,
|
|
59
|
+
source: source
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
value = value(destination: destination, source: source)
|
|
64
|
+
|
|
65
|
+
if destination.is_a?(Hash)
|
|
66
|
+
destination = Util::HashHelpers.deep_merge(
|
|
67
|
+
hash_to_merge_into: destination,
|
|
68
|
+
other_hash: destination_attribute_dot_parts.reverse.inject(value) { |a, n| { n => a } }
|
|
69
|
+
)
|
|
70
|
+
else
|
|
71
|
+
destination.assign_attribute(
|
|
72
|
+
destination_attribute_dot_parts.first,
|
|
73
|
+
value
|
|
74
|
+
)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
destination
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def destination_attribute_class(destination:)
|
|
81
|
+
@destination_attribute_type ||= {}
|
|
82
|
+
@destination_attribute_type[destination] ||= destination.class.destination_attributes[destination_attribute_dot_parts.first.to_sym].type.resource_class
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def destination_attribute_dot_parts
|
|
86
|
+
@destination_attribute_dot_parts ||= destination_attribute.split('.')
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def reference?
|
|
90
|
+
references_many? || references_one?
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def references_one?
|
|
94
|
+
type.is_a?(Type::ReferencesOneType)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def references_many?
|
|
98
|
+
type.is_a?(Type::ReferencesManyType)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def reference_resource_converter
|
|
102
|
+
@reference_resource_converter ||= type.resource_converter
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def source_attribute_dot_parts
|
|
106
|
+
@source_attribute_dot_parts ||= source_attribute.split('.')
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def value(destination:, source:)
|
|
110
|
+
value = if source.is_a?(Hash)
|
|
111
|
+
source.dig(*source_attribute_dot_parts)
|
|
112
|
+
else
|
|
113
|
+
source_attribute_dot_parts.inject(source) { |r, dot_method| r&.send(dot_method) }
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
return type.cast(value: value) unless reference?
|
|
117
|
+
|
|
118
|
+
destination_attribute_first_dot_part = destination_attribute_dot_parts.first
|
|
119
|
+
new_destination = if destination.is_a?(Hash)
|
|
120
|
+
{}
|
|
121
|
+
else
|
|
122
|
+
destination.class.resource_attributes.fetch(
|
|
123
|
+
destination_attribute_first_dot_part.to_sym
|
|
124
|
+
).type.resource_class.new
|
|
125
|
+
end
|
|
126
|
+
type.cast(destination: new_destination, source: source, value: value)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../mixins/delegate_iterable_methods_mixin'
|
|
4
|
+
|
|
5
|
+
module LedgerSync
|
|
6
|
+
module Util
|
|
7
|
+
class ResourceConverter
|
|
8
|
+
class AttributeSet
|
|
9
|
+
include Mixins::DelegateIterableMethodsMixin
|
|
10
|
+
|
|
11
|
+
attr_reader :attributes,
|
|
12
|
+
:resource_converter_class
|
|
13
|
+
|
|
14
|
+
delegate_array_methods_to :attributes
|
|
15
|
+
|
|
16
|
+
def initialize(args = {})
|
|
17
|
+
@attributes = []
|
|
18
|
+
@attribute_keys = {}
|
|
19
|
+
@resource_converter_class = args.fetch(:resource_converter_class)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def add(attribute)
|
|
23
|
+
unless attribute.destination_attribute.nil?
|
|
24
|
+
if @attribute_keys.key?(attribute.destination_attribute.to_s)
|
|
25
|
+
raise "destination_attribute already defined for #{resource_converter_class.name}: #{attribute.destination_attribute}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
@attribute_keys[attribute.destination_attribute] = attribute
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
attributes << attribute
|
|
32
|
+
|
|
33
|
+
attribute
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def hash_attribute?(key)
|
|
37
|
+
hash_attribute_keyed_hash.include?(key.to_s)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'resource_converter_type'
|
|
4
|
+
|
|
5
|
+
module LedgerSync
|
|
6
|
+
module Util
|
|
7
|
+
class ResourceConverter
|
|
8
|
+
module Type
|
|
9
|
+
class ReferencesManyType < ResourceConverterType
|
|
10
|
+
def cast_value(args = {})
|
|
11
|
+
destination = args.fetch(:destination)
|
|
12
|
+
values = args.fetch(:value)
|
|
13
|
+
|
|
14
|
+
return if values.nil?
|
|
15
|
+
|
|
16
|
+
values.map do |value|
|
|
17
|
+
super(
|
|
18
|
+
destination: destination,
|
|
19
|
+
value: value
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LedgerSync
|
|
4
|
+
module Util
|
|
5
|
+
class ResourceConverter
|
|
6
|
+
module Type
|
|
7
|
+
class ResourceConverterType < LedgerSync::Type::Value
|
|
8
|
+
attr_reader :resource_converter
|
|
9
|
+
|
|
10
|
+
def initialize(args = {})
|
|
11
|
+
@resource_converter = args.fetch(:resource_converter)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def cast_value(args = {})
|
|
15
|
+
destination = args.fetch(:destination)
|
|
16
|
+
source = args.fetch(:value)
|
|
17
|
+
|
|
18
|
+
return if source.nil?
|
|
19
|
+
|
|
20
|
+
resource_converter.new.convert(destination: destination, source: source)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -6,16 +6,18 @@ module LedgerSync
|
|
|
6
6
|
attr_reader :cast,
|
|
7
7
|
:data,
|
|
8
8
|
:ignore_unrecognized_attributes,
|
|
9
|
+
:ledger,
|
|
9
10
|
:root_resource_external_id,
|
|
10
11
|
:root_resource_type
|
|
11
12
|
|
|
12
|
-
def initialize(
|
|
13
|
-
@all_resources
|
|
14
|
-
@
|
|
15
|
-
@
|
|
16
|
-
@
|
|
17
|
-
@
|
|
18
|
-
@
|
|
13
|
+
def initialize(args = {})
|
|
14
|
+
@all_resources = {}
|
|
15
|
+
@ledger = args.fetch(:ledger)
|
|
16
|
+
@cast = args.fetch(:cast, true)
|
|
17
|
+
@data = Util::HashHelpers.deep_symbolize_keys(args.fetch(:data))
|
|
18
|
+
@ignore_unrecognized_attributes = args.fetch(:ignore_unrecognized_attributes, false)
|
|
19
|
+
@root_resource_external_id = args.fetch(:root_resource_external_id)
|
|
20
|
+
@root_resource_type = args.fetch(:root_resource_type)
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
def resource
|
|
@@ -42,7 +44,11 @@ module LedgerSync
|
|
|
42
44
|
current_data = @data.dig(type, external_id, :data)
|
|
43
45
|
raise "No data provided for #{type} (ID: #{external_id})" if current_data.nil?
|
|
44
46
|
|
|
45
|
-
resource_class =
|
|
47
|
+
resource_class = if ledger == :root
|
|
48
|
+
LedgerSync.resources.find { |e| e.resource_type == type }
|
|
49
|
+
else
|
|
50
|
+
LedgerSync.ledgers.send(ledger).client_class.resources[type]
|
|
51
|
+
end
|
|
46
52
|
raise "#{type} is an invalid resource type" if resource_class.nil?
|
|
47
53
|
|
|
48
54
|
current_data = Hash[
|
|
@@ -50,7 +56,9 @@ module LedgerSync
|
|
|
50
56
|
k = k.to_sym
|
|
51
57
|
|
|
52
58
|
attribute = resource_class.resource_attributes[k]
|
|
53
|
-
|
|
59
|
+
if attribute.nil? && !ignore_unrecognized_attributes
|
|
60
|
+
raise "Unrecognized attribute for #{resource_class.name}: #{k}"
|
|
61
|
+
end
|
|
54
62
|
|
|
55
63
|
v = if attribute.is_a?(ResourceAttribute::Reference::One)
|
|
56
64
|
resource_type = resource_type_by(external_id: current_data[k])
|
|
@@ -66,7 +74,7 @@ module LedgerSync
|
|
|
66
74
|
)
|
|
67
75
|
end
|
|
68
76
|
elsif cast
|
|
69
|
-
attribute.type.cast(v)
|
|
77
|
+
attribute.type.cast(value: v)
|
|
70
78
|
else
|
|
71
79
|
v
|
|
72
80
|
end
|
|
@@ -87,7 +95,7 @@ module LedgerSync
|
|
|
87
95
|
@external_id_to_type_hash ||= begin
|
|
88
96
|
ret = {}
|
|
89
97
|
data.each do |type, type_resources|
|
|
90
|
-
type_resources.
|
|
98
|
+
type_resources.each_key do |external_id|
|
|
91
99
|
ret[external_id] = type
|
|
92
100
|
end
|
|
93
101
|
end
|
|
@@ -6,7 +6,7 @@ module LedgerSync
|
|
|
6
6
|
module_function
|
|
7
7
|
|
|
8
8
|
def camelcase(str)
|
|
9
|
-
str.to_s.split('/').map { |e| inflect(e.split('_').collect(&:
|
|
9
|
+
str.to_s.split('/').map { |e| inflect(e.split('_').collect(&:camelcase).join) }.join('::')
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def underscore!(str)
|
|
@@ -22,9 +22,9 @@ module LedgerSync
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def inflect(str)
|
|
25
|
-
return str unless LedgerSync.respond_to?(:
|
|
25
|
+
return str unless LedgerSync.respond_to?(:ledgers)
|
|
26
26
|
|
|
27
|
-
LedgerSync.
|
|
27
|
+
LedgerSync.ledgers.inflections.each do |inflection|
|
|
28
28
|
next unless inflection.downcase == str.downcase
|
|
29
29
|
|
|
30
30
|
return inflection
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LedgerSync
|
|
4
|
+
module Util
|
|
5
|
+
class URLHelpers
|
|
6
|
+
def self.merge_params_in_url(args = {})
|
|
7
|
+
params = args.fetch(:params)
|
|
8
|
+
uri = args.fetch(:url)
|
|
9
|
+
|
|
10
|
+
uri = URI.parse(uri) unless uri.is_a?(URI::HTTPS) || uri.is_a?(URI::HTTP)
|
|
11
|
+
uri.query = URI.encode_www_form(
|
|
12
|
+
params.inject(URI.decode_www_form(String(uri.query))) { |prev, param| prev << param }
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
uri.to_s
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.merge_params_in_path(args = {})
|
|
19
|
+
params = args.fetch(:params)
|
|
20
|
+
path = args.fetch(:path)
|
|
21
|
+
|
|
22
|
+
root, str_params = path.split('?')
|
|
23
|
+
str_params = Rack::Utils.parse_nested_query(str_params)
|
|
24
|
+
|
|
25
|
+
[
|
|
26
|
+
root,
|
|
27
|
+
Rack::Utils.build_query(str_params.merge(HashHelpers.deep_stringify_keys(params)))
|
|
28
|
+
].compact.join('?')
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.id_from_url(args = {})
|
|
32
|
+
uri = args.fetch(:url)
|
|
33
|
+
|
|
34
|
+
URI.parse(uri).path.split('/').last
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|