fortnox-api 0.9.2 → 1.0.0.rc2
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/CHANGELOG.md +120 -95
- data/{LICENSE.txt → LICENSE.md} +0 -0
- data/README.md +245 -248
- data/bin/fortnox-setup +211 -0
- data/bin/fortnox-update-env +38 -0
- data/fortnox.gemspec +29 -0
- data/lib/fortnox/auth/thread_local.rb +28 -0
- data/lib/fortnox/collection.rb +23 -0
- data/lib/fortnox/mappers/country_code.rb +34 -0
- data/lib/fortnox/mappers/date.rb +21 -0
- data/lib/fortnox/mappers/document_row.rb +12 -0
- data/lib/fortnox/mappers/edi_information.rb +15 -0
- data/lib/fortnox/mappers/email_information.rb +11 -0
- data/lib/fortnox/mappers/invoice_row.rb +14 -0
- data/lib/fortnox/mappers/label_references.rb +24 -0
- data/lib/fortnox/mappers/order_row.rb +9 -0
- data/lib/fortnox/mappers/struct.rb +71 -0
- data/lib/fortnox/mappers/struct_array.rb +31 -0
- data/lib/fortnox/resource.rb +131 -0
- data/lib/fortnox/resources/article.rb +160 -0
- data/lib/fortnox/resources/customer.rb +209 -0
- data/lib/fortnox/resources/document.rb +202 -0
- data/lib/fortnox/resources/invoice.rb +92 -0
- data/lib/fortnox/resources/label.rb +15 -0
- data/lib/fortnox/resources/order.rb +38 -0
- data/lib/fortnox/resources/project.rb +41 -0
- data/lib/fortnox/resources/terms_of_payment.rb +23 -0
- data/lib/fortnox/resources/unit.rb +26 -0
- data/lib/fortnox/struct.rb +24 -0
- data/lib/fortnox/structs/default_delivery_types.rb +16 -0
- data/lib/fortnox/structs/default_templates.rb +19 -0
- data/lib/fortnox/structs/document_row.rb +62 -0
- data/lib/fortnox/structs/edi_information.rb +25 -0
- data/lib/fortnox/structs/email_information.rb +22 -0
- data/lib/fortnox/structs/invoice_row.rb +13 -0
- data/lib/fortnox/structs/order_row.rb +10 -0
- data/lib/fortnox/types.rb +129 -0
- data/lib/fortnox/{api/version.rb → version.rb} +1 -3
- data/lib/fortnox.rb +111 -0
- metadata +55 -580
- data/.codeclimate.yml +0 -20
- data/.env.template +0 -7
- data/.env.test +0 -11
- data/.gitignore +0 -20
- data/.rspec +0 -2
- data/.rubocop.yml +0 -41
- data/.tool-versions +0 -1
- data/.travis.yml +0 -32
- data/CLAUDE.md +0 -79
- data/CONTRIBUTE.md +0 -38
- data/DEVELOPER_README.md +0 -69
- data/Gemfile +0 -6
- data/Guardfile +0 -16
- data/Rakefile +0 -140
- data/bin/console +0 -22
- data/bin/fortnox +0 -285
- data/bin/get_tokens +0 -79
- data/bin/renew_tokens +0 -28
- data/docs/gotchas.md +0 -146
- data/fortnox-api.gemspec +0 -50
- data/lib/fortnox/api/mappers/article.rb +0 -23
- data/lib/fortnox/api/mappers/base/canonical_name_sym.rb +0 -21
- data/lib/fortnox/api/mappers/base/from_json.rb +0 -91
- data/lib/fortnox/api/mappers/base/to_json.rb +0 -66
- data/lib/fortnox/api/mappers/base.rb +0 -30
- data/lib/fortnox/api/mappers/customer.rb +0 -27
- data/lib/fortnox/api/mappers/default_delivery_types.rb +0 -15
- data/lib/fortnox/api/mappers/default_templates.rb +0 -16
- data/lib/fortnox/api/mappers/edi_information.rb +0 -23
- data/lib/fortnox/api/mappers/email_information.rb +0 -19
- data/lib/fortnox/api/mappers/invoice.rb +0 -29
- data/lib/fortnox/api/mappers/invoice_row.rb +0 -25
- data/lib/fortnox/api/mappers/order.rb +0 -26
- data/lib/fortnox/api/mappers/order_row.rb +0 -23
- data/lib/fortnox/api/mappers/project.rb +0 -17
- data/lib/fortnox/api/mappers/terms_of_payment.rb +0 -17
- data/lib/fortnox/api/mappers/unit.rb +0 -17
- data/lib/fortnox/api/mappers/value/array.rb +0 -18
- data/lib/fortnox/api/mappers/value/country_string.rb +0 -24
- data/lib/fortnox/api/mappers/value/date.rb +0 -11
- data/lib/fortnox/api/mappers/value/hash.rb +0 -16
- data/lib/fortnox/api/mappers/value/identity.rb +0 -18
- data/lib/fortnox/api/mappers.rb +0 -21
- data/lib/fortnox/api/models/article.rb +0 -134
- data/lib/fortnox/api/models/base.rb +0 -128
- data/lib/fortnox/api/models/customer.rb +0 -210
- data/lib/fortnox/api/models/document.rb +0 -189
- data/lib/fortnox/api/models/invoice.rb +0 -87
- data/lib/fortnox/api/models/label.rb +0 -19
- data/lib/fortnox/api/models/order.rb +0 -27
- data/lib/fortnox/api/models/project.rb +0 -42
- data/lib/fortnox/api/models/terms_of_payment.rb +0 -28
- data/lib/fortnox/api/models/unit.rb +0 -24
- data/lib/fortnox/api/models.rb +0 -9
- data/lib/fortnox/api/repositories/article.rb +0 -17
- data/lib/fortnox/api/repositories/authentication.rb +0 -61
- data/lib/fortnox/api/repositories/base/loaders.rb +0 -64
- data/lib/fortnox/api/repositories/base/savers.rb +0 -57
- data/lib/fortnox/api/repositories/base.rb +0 -93
- data/lib/fortnox/api/repositories/customer.rb +0 -17
- data/lib/fortnox/api/repositories/invoice.rb +0 -17
- data/lib/fortnox/api/repositories/order.rb +0 -17
- data/lib/fortnox/api/repositories/project.rb +0 -17
- data/lib/fortnox/api/repositories/terms_of_payment.rb +0 -17
- data/lib/fortnox/api/repositories/unit.rb +0 -17
- data/lib/fortnox/api/repositories.rb +0 -10
- data/lib/fortnox/api/request_handling.rb +0 -46
- data/lib/fortnox/api/types/default_delivery_types.rb +0 -20
- data/lib/fortnox/api/types/default_templates.rb +0 -23
- data/lib/fortnox/api/types/defaulted.rb +0 -11
- data/lib/fortnox/api/types/document_row.rb +0 -64
- data/lib/fortnox/api/types/edi_information.rb +0 -29
- data/lib/fortnox/api/types/email_information.rb +0 -26
- data/lib/fortnox/api/types/enums.rb +0 -116
- data/lib/fortnox/api/types/invoice_row.rb +0 -19
- data/lib/fortnox/api/types/model.rb +0 -37
- data/lib/fortnox/api/types/nullable.rb +0 -25
- data/lib/fortnox/api/types/order_row.rb +0 -16
- data/lib/fortnox/api/types/required.rb +0 -13
- data/lib/fortnox/api/types/shim/country_string.rb +0 -10
- data/lib/fortnox/api/types/sized.rb +0 -33
- data/lib/fortnox/api/types.rb +0 -144
- data/lib/fortnox/api.rb +0 -62
- data/spec/fortnox/api/mappers/article_spec.rb +0 -17
- data/spec/fortnox/api/mappers/base/canonical_name_sym_spec.rb +0 -36
- data/spec/fortnox/api/mappers/base/from_json_spec.rb +0 -70
- data/spec/fortnox/api/mappers/base/to_json_spec.rb +0 -68
- data/spec/fortnox/api/mappers/base_spec.rb +0 -154
- data/spec/fortnox/api/mappers/contexts/json_conversion.rb +0 -62
- data/spec/fortnox/api/mappers/customer_spec.rb +0 -27
- data/spec/fortnox/api/mappers/default_delivery_types_spec.rb +0 -14
- data/spec/fortnox/api/mappers/edi_information_spec.rb +0 -23
- data/spec/fortnox/api/mappers/email_information_spec.rb +0 -19
- data/spec/fortnox/api/mappers/examples/mapper.rb +0 -34
- data/spec/fortnox/api/mappers/invoice_row_spec.rb +0 -24
- data/spec/fortnox/api/mappers/invoice_spec.rb +0 -27
- data/spec/fortnox/api/mappers/order_row_spec.rb +0 -21
- data/spec/fortnox/api/mappers/order_spec.rb +0 -23
- data/spec/fortnox/api/mappers/project_spec.rb +0 -12
- data/spec/fortnox/api/mappers/terms_of_payment_spec.rb +0 -16
- data/spec/fortnox/api/mappers/unit_spec.rb +0 -56
- data/spec/fortnox/api/models/article_spec.rb +0 -9
- data/spec/fortnox/api/models/base_spec.rb +0 -117
- data/spec/fortnox/api/models/customer_spec.rb +0 -9
- data/spec/fortnox/api/models/examples/document_base.rb +0 -15
- data/spec/fortnox/api/models/examples/model.rb +0 -22
- data/spec/fortnox/api/models/invoice_spec.rb +0 -11
- data/spec/fortnox/api/models/order_spec.rb +0 -12
- data/spec/fortnox/api/models/project_spec.rb +0 -9
- data/spec/fortnox/api/models/terms_of_payment_spec.rb +0 -9
- data/spec/fortnox/api/models/unit_spec.rb +0 -33
- data/spec/fortnox/api/repositories/article_spec.rb +0 -80
- data/spec/fortnox/api/repositories/authentication_spec.rb +0 -103
- data/spec/fortnox/api/repositories/base_spec.rb +0 -168
- data/spec/fortnox/api/repositories/customer_spec.rb +0 -119
- data/spec/fortnox/api/repositories/examples/all.rb +0 -17
- data/spec/fortnox/api/repositories/examples/find.rb +0 -84
- data/spec/fortnox/api/repositories/examples/only.rb +0 -34
- data/spec/fortnox/api/repositories/examples/save.rb +0 -76
- data/spec/fortnox/api/repositories/examples/save_with_nested_model.rb +0 -28
- data/spec/fortnox/api/repositories/examples/save_with_specially_named_attribute.rb +0 -26
- data/spec/fortnox/api/repositories/examples/search.rb +0 -39
- data/spec/fortnox/api/repositories/invoice_spec.rb +0 -297
- data/spec/fortnox/api/repositories/order_spec.rb +0 -53
- data/spec/fortnox/api/repositories/project_spec.rb +0 -36
- data/spec/fortnox/api/repositories/terms_of_payment_spec.rb +0 -34
- data/spec/fortnox/api/repositories/unit_spec.rb +0 -39
- data/spec/fortnox/api/types/account_number_spec.rb +0 -35
- data/spec/fortnox/api/types/country_code_spec.rb +0 -42
- data/spec/fortnox/api/types/country_spec.rb +0 -67
- data/spec/fortnox/api/types/default_delivery_types_spec.rb +0 -12
- data/spec/fortnox/api/types/edi_information_spec.rb +0 -15
- data/spec/fortnox/api/types/email_information_spec.rb +0 -15
- data/spec/fortnox/api/types/email_spec.rb +0 -56
- data/spec/fortnox/api/types/enums_spec.rb +0 -17
- data/spec/fortnox/api/types/examples/document_row.rb +0 -25
- data/spec/fortnox/api/types/examples/enum.rb +0 -55
- data/spec/fortnox/api/types/examples/types.rb +0 -11
- data/spec/fortnox/api/types/housework_types_spec.rb +0 -149
- data/spec/fortnox/api/types/invoice_row_spec.rb +0 -11
- data/spec/fortnox/api/types/model_spec.rb +0 -69
- data/spec/fortnox/api/types/nullable_spec.rb +0 -79
- data/spec/fortnox/api/types/order_row_spec.rb +0 -15
- data/spec/fortnox/api/types/required_spec.rb +0 -36
- data/spec/fortnox/api/types/sales_account_spec.rb +0 -57
- data/spec/fortnox/api/types/sized_spec.rb +0 -76
- data/spec/fortnox/api_spec.rb +0 -66
- data/spec/spec_helper.rb +0 -35
- data/spec/support/helpers/configuration_helper.rb +0 -39
- data/spec/support/helpers/repository_helper.rb +0 -10
- data/spec/support/helpers.rb +0 -3
- data/spec/support/matchers/type/attribute_matcher.rb +0 -40
- data/spec/support/matchers/type/enum_matcher.rb +0 -23
- data/spec/support/matchers/type/have_account_number_matcher.rb +0 -23
- data/spec/support/matchers/type/have_currency_matcher.rb +0 -9
- data/spec/support/matchers/type/have_customer_type_matcher.rb +0 -15
- data/spec/support/matchers/type/have_default_delivery_type_matcher.rb +0 -9
- data/spec/support/matchers/type/have_discount_type_matcher.rb +0 -9
- data/spec/support/matchers/type/have_email_matcher.rb +0 -24
- data/spec/support/matchers/type/have_housework_type_matcher.rb +0 -9
- data/spec/support/matchers/type/have_nullable_date_matcher.rb +0 -60
- data/spec/support/matchers/type/have_nullable_matcher.rb +0 -54
- data/spec/support/matchers/type/have_nullable_string_matcher.rb +0 -47
- data/spec/support/matchers/type/have_sized_float_matcher.rb +0 -10
- data/spec/support/matchers/type/have_sized_integer_matcher.rb +0 -10
- data/spec/support/matchers/type/have_sized_string_matcher.rb +0 -36
- data/spec/support/matchers/type/have_vat_type_matcher.rb +0 -9
- data/spec/support/matchers/type/numeric_matcher.rb +0 -52
- data/spec/support/matchers/type/require_attribute_matcher.rb +0 -68
- data/spec/support/matchers/type/type_matcher.rb +0 -40
- data/spec/support/matchers/type.rb +0 -19
- data/spec/support/matchers.rb +0 -3
- data/spec/support/vcr_setup.rb +0 -25
- data/spec/vcr_cassettes/articles/all.yml +0 -67
- data/spec/vcr_cassettes/articles/find_by_hash_failure.yml +0 -62
- data/spec/vcr_cassettes/articles/find_failure.yml +0 -62
- data/spec/vcr_cassettes/articles/find_id_1.yml +0 -63
- data/spec/vcr_cassettes/articles/find_new.yml +0 -63
- data/spec/vcr_cassettes/articles/limits/quantity_in_stock_min_value.yml +0 -63
- data/spec/vcr_cassettes/articles/limits/quantity_in_stock_rounding_positive_value.yml +0 -63
- data/spec/vcr_cassettes/articles/multi_param_find_by_hash.yml +0 -62
- data/spec/vcr_cassettes/articles/save_new.yml +0 -63
- data/spec/vcr_cassettes/articles/save_old.yml +0 -63
- data/spec/vcr_cassettes/articles/save_with_specially_named_attribute.yml +0 -63
- data/spec/vcr_cassettes/articles/search_by_name.yml +0 -65
- data/spec/vcr_cassettes/articles/search_miss.yml +0 -62
- data/spec/vcr_cassettes/articles/search_with_special_char.yml +0 -62
- data/spec/vcr_cassettes/articles/single_param_find_by_hash.yml +0 -62
- data/spec/vcr_cassettes/authentication/expired_token.yml +0 -54
- data/spec/vcr_cassettes/authentication/invalid_authorization.yml +0 -57
- data/spec/vcr_cassettes/authentication/invalid_refresh_token.yml +0 -58
- data/spec/vcr_cassettes/authentication/valid_request.yml +0 -63
- data/spec/vcr_cassettes/customers/all.yml +0 -69
- data/spec/vcr_cassettes/customers/find_by_hash_failure.yml +0 -62
- data/spec/vcr_cassettes/customers/find_failure.yml +0 -62
- data/spec/vcr_cassettes/customers/find_id_1.yml +0 -64
- data/spec/vcr_cassettes/customers/find_new.yml +0 -63
- data/spec/vcr_cassettes/customers/find_with_sales_account.yml +0 -63
- data/spec/vcr_cassettes/customers/multi_param_find_by_hash.yml +0 -63
- data/spec/vcr_cassettes/customers/save_new.yml +0 -63
- data/spec/vcr_cassettes/customers/save_new_with_country_code_SE.yml +0 -64
- data/spec/vcr_cassettes/customers/save_new_with_idn_email.yml +0 -67
- data/spec/vcr_cassettes/customers/save_new_with_sales_account.yml +0 -63
- data/spec/vcr_cassettes/customers/save_old.yml +0 -63
- data/spec/vcr_cassettes/customers/save_with_specially_named_attribute.yml +0 -63
- data/spec/vcr_cassettes/customers/search_by_name.yml +0 -64
- data/spec/vcr_cassettes/customers/search_miss.yml +0 -62
- data/spec/vcr_cassettes/customers/search_with_special_char.yml +0 -62
- data/spec/vcr_cassettes/customers/single_param_find_by_hash.yml +0 -64
- data/spec/vcr_cassettes/invoices/all.yml +0 -96
- data/spec/vcr_cassettes/invoices/filter_hit.yml +0 -64
- data/spec/vcr_cassettes/invoices/filter_invalid.yml +0 -60
- data/spec/vcr_cassettes/invoices/find_by_hash_failure.yml +0 -62
- data/spec/vcr_cassettes/invoices/find_failure.yml +0 -62
- data/spec/vcr_cassettes/invoices/find_id_1.yml +0 -65
- data/spec/vcr_cassettes/invoices/find_new.yml +0 -65
- data/spec/vcr_cassettes/invoices/multi_param_find_by_hash.yml +0 -63
- data/spec/vcr_cassettes/invoices/row_delivered_quantity_decimals.yml +0 -65
- data/spec/vcr_cassettes/invoices/row_delivered_quantity_decimals_round_up.yml +0 -65
- data/spec/vcr_cassettes/invoices/row_description_limit.yml +0 -65
- data/spec/vcr_cassettes/invoices/row_price_limit.yml +0 -65
- data/spec/vcr_cassettes/invoices/row_price_limit_round_up.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_new.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_new_with_comments.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_new_with_country.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_new_with_country_GB.yml +0 -66
- data/spec/vcr_cassettes/invoices/save_new_with_country_Norge.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_new_with_country_Norway.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_new_with_country_Sverige.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_new_with_country_VA.yml +0 -66
- data/spec/vcr_cassettes/invoices/save_new_with_country_VI.yml +0 -66
- data/spec/vcr_cassettes/invoices/save_new_with_country_empty_string.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_new_with_country_nil.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_new_with_unsaved_parent.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_old.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_old_with_empty_comments.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_old_with_empty_country.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_old_with_nil_comments.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_old_with_nil_country.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_with_nested_model.yml +0 -65
- data/spec/vcr_cassettes/invoices/save_with_specially_named_attribute.yml +0 -65
- data/spec/vcr_cassettes/invoices/search_by_name.yml +0 -63
- data/spec/vcr_cassettes/invoices/search_miss.yml +0 -62
- data/spec/vcr_cassettes/invoices/search_with_special_char.yml +0 -62
- data/spec/vcr_cassettes/invoices/single_param_find_by_hash.yml +0 -64
- data/spec/vcr_cassettes/orders/all.yml +0 -69
- data/spec/vcr_cassettes/orders/filter_hit.yml +0 -64
- data/spec/vcr_cassettes/orders/filter_invalid.yml +0 -60
- data/spec/vcr_cassettes/orders/find_by_hash_failure.yml +0 -62
- data/spec/vcr_cassettes/orders/find_failure.yml +0 -62
- data/spec/vcr_cassettes/orders/find_id_1.yml +0 -67
- data/spec/vcr_cassettes/orders/find_new.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_invalid_tax_reduction_type.yml +0 -61
- data/spec/vcr_cassettes/orders/housework_othercoses_invalid.yml +0 -61
- data/spec/vcr_cassettes/orders/housework_type_babysitting.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_cleaning.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_construction.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_cooking.yml +0 -61
- data/spec/vcr_cassettes/orders/housework_type_electricity.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_gardening.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_glassmetalwork.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_grounddrainagework.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_hvac.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_itservices.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_majorappliancerepair.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_masonry.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_movingservices.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_othercare.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_othercosts.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_paintingwallpapering.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_snowplowing.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_textileclothing.yml +0 -65
- data/spec/vcr_cassettes/orders/housework_type_tutoring.yml +0 -61
- data/spec/vcr_cassettes/orders/multi_param_find_by_hash.yml +0 -63
- data/spec/vcr_cassettes/orders/save_new.yml +0 -65
- data/spec/vcr_cassettes/orders/save_old.yml +0 -65
- data/spec/vcr_cassettes/orders/save_with_nested_model.yml +0 -65
- data/spec/vcr_cassettes/orders/search_by_name.yml +0 -63
- data/spec/vcr_cassettes/orders/search_miss.yml +0 -62
- data/spec/vcr_cassettes/orders/search_with_special_char.yml +0 -62
- data/spec/vcr_cassettes/orders/single_param_find_by_hash.yml +0 -64
- data/spec/vcr_cassettes/projects/all.yml +0 -64
- data/spec/vcr_cassettes/projects/find_by_hash_failure.yml +0 -62
- data/spec/vcr_cassettes/projects/find_failure.yml +0 -62
- data/spec/vcr_cassettes/projects/find_id_1.yml +0 -63
- data/spec/vcr_cassettes/projects/find_new.yml +0 -63
- data/spec/vcr_cassettes/projects/multi_param_find_by_hash.yml +0 -64
- data/spec/vcr_cassettes/projects/save_new.yml +0 -63
- data/spec/vcr_cassettes/projects/save_old.yml +0 -63
- data/spec/vcr_cassettes/projects/single_param_find_by_hash.yml +0 -63
- data/spec/vcr_cassettes/termsofpayments/all.yml +0 -68
- data/spec/vcr_cassettes/termsofpayments/find_failure.yml +0 -62
- data/spec/vcr_cassettes/termsofpayments/find_id_1.yml +0 -62
- data/spec/vcr_cassettes/termsofpayments/find_new.yml +0 -63
- data/spec/vcr_cassettes/termsofpayments/save_new.yml +0 -63
- data/spec/vcr_cassettes/termsofpayments/save_old.yml +0 -63
- data/spec/vcr_cassettes/units/all.yml +0 -64
- data/spec/vcr_cassettes/units/find_failure.yml +0 -62
- data/spec/vcr_cassettes/units/find_id_1.yml +0 -63
- data/spec/vcr_cassettes/units/find_new.yml +0 -63
- data/spec/vcr_cassettes/units/save_new.yml +0 -63
- data/spec/vcr_cassettes/units/save_old.yml +0 -63
- data/spec/vcr_cassettes/units/save_with_specially_named_attribute.yml +0 -63
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Fortnox
|
|
4
|
+
class Resource < RestEasy::Resource
|
|
5
|
+
include Fortnox::Types
|
|
6
|
+
|
|
7
|
+
settings do
|
|
8
|
+
setting :instance_wrapper, reader: true
|
|
9
|
+
setting :collection_wrapper, reader: true
|
|
10
|
+
setting :scope, reader: true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
@registered_resources = []
|
|
14
|
+
|
|
15
|
+
before_parse do |data, meta|
|
|
16
|
+
if data.key?(config.instance_wrapper)
|
|
17
|
+
meta.partial = false
|
|
18
|
+
next data[config.instance_wrapper]
|
|
19
|
+
elsif data.key?(config.collection_wrapper)
|
|
20
|
+
meta.partial = true
|
|
21
|
+
next data[config.collection_wrapper]
|
|
22
|
+
else
|
|
23
|
+
raise Fortnox::RequestError, "Unknown response format: #{data}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
after_serialise do |data|
|
|
28
|
+
if meta.new?
|
|
29
|
+
# Strip nils for new records — rely on Fortnox defaults
|
|
30
|
+
data = data.compact
|
|
31
|
+
elsif __changes__.any?
|
|
32
|
+
# Only send changed attributes on update, preserving explicit nils
|
|
33
|
+
changed_api_names = __changes__.keys.filter_map do |model_name|
|
|
34
|
+
self.class.all_attribute_definitions[model_name]&.api_name
|
|
35
|
+
end
|
|
36
|
+
data = data.slice(*changed_api_names)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# TODO: rest-easy should do this wrapping for us.
|
|
40
|
+
{ config.instance_wrapper => data }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class << self
|
|
44
|
+
attr_reader :registered_resources
|
|
45
|
+
|
|
46
|
+
def inherited(subclass)
|
|
47
|
+
super
|
|
48
|
+
Fortnox::Resource.registered_resources << subclass
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def parse(response)
|
|
52
|
+
with_translated_errors do
|
|
53
|
+
pagination = extract_pagination(response)
|
|
54
|
+
result = super
|
|
55
|
+
result.is_a?(Array) ? Collection.new(result, **pagination) : result
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def stub(**model_data)
|
|
60
|
+
with_translated_errors { super }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def save(instance)
|
|
64
|
+
with_translated_errors { super }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def only(filter)
|
|
68
|
+
response = get(path: config.path, params: { filter: })
|
|
69
|
+
parse(response)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def search(hash)
|
|
73
|
+
attribute, value = hash.first
|
|
74
|
+
response = get(path: config.path, params: { attribute => value })
|
|
75
|
+
parse(response)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def find(id_or_hash)
|
|
79
|
+
return find_all_by(id_or_hash) if id_or_hash.is_a? Hash
|
|
80
|
+
|
|
81
|
+
find_one_by(id_or_hash)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def find_one_by(id)
|
|
85
|
+
response = get(path: "#{config.path}/#{id}")
|
|
86
|
+
parse(response)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def find_all_by(hash)
|
|
90
|
+
response = get(path: config.path.to_s, params: hash)
|
|
91
|
+
parse(response)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
[:get, :post, :put, :delete].each do |method|
|
|
95
|
+
define_method(method) do |**options|
|
|
96
|
+
options[:headers] ||= {}
|
|
97
|
+
options[:headers]['Content-Type'] = 'application/json'
|
|
98
|
+
options[:headers]['Accept'] = 'application/json'
|
|
99
|
+
with_translated_errors { super(**options) }
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
private
|
|
104
|
+
|
|
105
|
+
# Translate rest-easy errors at the gem boundary so callers only see
|
|
106
|
+
# Fortnox-namespaced exceptions.
|
|
107
|
+
def with_translated_errors
|
|
108
|
+
yield
|
|
109
|
+
rescue RestEasy::ConstraintError => e
|
|
110
|
+
raise Fortnox::ConstraintError.new(e.attribute_name, e.value, e.message)
|
|
111
|
+
rescue RestEasy::MissingAttributeError => e
|
|
112
|
+
raise Fortnox::MissingAttributeError, e.attribute_name
|
|
113
|
+
rescue RestEasy::AttributeError => e
|
|
114
|
+
raise Fortnox::AttributeError, e.message
|
|
115
|
+
rescue RestEasy::RequestError => e
|
|
116
|
+
raise Fortnox::RequestError, e.response || e.message
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def extract_pagination(data)
|
|
120
|
+
return {} unless data.is_a?(Hash) && data.key?('MetaInformation')
|
|
121
|
+
|
|
122
|
+
meta = data['MetaInformation']
|
|
123
|
+
{
|
|
124
|
+
total: meta['@TotalResources']&.to_i,
|
|
125
|
+
pages: meta['@TotalPages']&.to_i,
|
|
126
|
+
current_page: meta['@CurrentPage']&.to_i
|
|
127
|
+
}
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Fortnox
|
|
4
|
+
class Article < Fortnox::Resource
|
|
5
|
+
using RestEasy::Refinements
|
|
6
|
+
|
|
7
|
+
configure do
|
|
8
|
+
path 'articles'
|
|
9
|
+
instance_wrapper 'Article'
|
|
10
|
+
collection_wrapper 'Articles'
|
|
11
|
+
scope 'article'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# @url Direct URL to the record.
|
|
15
|
+
attr :url <=> '@url', Coercible::String.optional, :read_only
|
|
16
|
+
|
|
17
|
+
# True If the article is active
|
|
18
|
+
attr :active, Bool.optional, Boolean
|
|
19
|
+
|
|
20
|
+
# ArticleNumber Article number
|
|
21
|
+
key :article_number, Sized::String[50]
|
|
22
|
+
|
|
23
|
+
# Bulky If the article is bulky.
|
|
24
|
+
attr :bulky, Bool.optional, Boolean
|
|
25
|
+
|
|
26
|
+
# ConstructionAccount Account number for construction work (special VAT rules in Sweden).
|
|
27
|
+
# The number must be of an existing account.
|
|
28
|
+
attr :construction_account, Types::AccountNumber
|
|
29
|
+
|
|
30
|
+
# Depth The depth of the article in millimeters
|
|
31
|
+
attr :depth, Sized::Integer[0, 999_999_999]
|
|
32
|
+
|
|
33
|
+
# Description The description of the article
|
|
34
|
+
attr :description, Sized::String[200], :required
|
|
35
|
+
|
|
36
|
+
# DisposableQuantity Disposable quantity of the article.
|
|
37
|
+
attr :disposable_quantity, Coercible::Float.optional, :read_only
|
|
38
|
+
|
|
39
|
+
# EAN EAN bar code
|
|
40
|
+
attr :ean <=> 'EAN', Sized::String[30]
|
|
41
|
+
|
|
42
|
+
# EUAccount Account number for the sales account to EU.
|
|
43
|
+
# The number must be of an existing account.
|
|
44
|
+
attr :eu_account <=> 'EUAccount', Types::AccountNumber
|
|
45
|
+
|
|
46
|
+
# EUVATAccount Account number for the sales account to EU with VAT.
|
|
47
|
+
# The number must be of an existing account.
|
|
48
|
+
attr :eu_vat_account <=> 'EUVATAccount', Types::AccountNumber
|
|
49
|
+
|
|
50
|
+
# ExportAccount Account number for the sales account outside EU.
|
|
51
|
+
# The number must be of an existing account.
|
|
52
|
+
attr :export_account, Types::AccountNumber
|
|
53
|
+
|
|
54
|
+
# Height The height of the article in millimeters
|
|
55
|
+
attr :height, Sized::Integer[0, 999_999_999]
|
|
56
|
+
|
|
57
|
+
# Housework If the article is housework
|
|
58
|
+
attr :housework, Bool.optional, Boolean
|
|
59
|
+
|
|
60
|
+
# HouseworkType The type of housework.
|
|
61
|
+
attr :housework_type, HouseworkTypes
|
|
62
|
+
|
|
63
|
+
# Manufacturer The manufacturer of the article
|
|
64
|
+
attr :manufacturer, Sized::String[50]
|
|
65
|
+
|
|
66
|
+
# ManufacturerArticleNumber The manufacturer's article number
|
|
67
|
+
attr :manufacturer_article_number, Sized::String[50]
|
|
68
|
+
|
|
69
|
+
# Note Text note
|
|
70
|
+
attr :note, Sized::String[10_000]
|
|
71
|
+
|
|
72
|
+
# PurchaseAccount Account number for purchase.
|
|
73
|
+
# The number must be of an existing account.
|
|
74
|
+
attr :purchase_account, Types::AccountNumber
|
|
75
|
+
|
|
76
|
+
# PurchasePrice Purchase price of the article
|
|
77
|
+
attr :purchase_price, Sized::Float[0.0, 99_999_999_999_999.9]
|
|
78
|
+
|
|
79
|
+
# QuantityInStock Quantity in stock of the article
|
|
80
|
+
attr :quantity_in_stock, Sized::Float[-100_000_000_000_000.0, 99_999_999_999_999.9]
|
|
81
|
+
|
|
82
|
+
# ReservedQuantity Reserved quantity of the article
|
|
83
|
+
attr :reserved_quantity, Coercible::Float.optional, :read_only
|
|
84
|
+
|
|
85
|
+
# SalesAccount Account number for the sales account in Sweden.
|
|
86
|
+
# The number must be of an existing account.
|
|
87
|
+
attr :sales_account, Types::AccountNumber
|
|
88
|
+
|
|
89
|
+
# SalesPrice Price of article for its default price list
|
|
90
|
+
attr :sales_price, Coercible::Float.optional, :read_only
|
|
91
|
+
|
|
92
|
+
# StockGoods If the article is stock goods
|
|
93
|
+
attr :stock_goods, Bool.optional, Boolean
|
|
94
|
+
|
|
95
|
+
# StockPlace Storage place for the article
|
|
96
|
+
attr :stock_place, Sized::String[100]
|
|
97
|
+
|
|
98
|
+
# StockValue Value in stock of the article
|
|
99
|
+
attr :stock_value, Coercible::Float.optional, :read_only
|
|
100
|
+
|
|
101
|
+
# StockWarning When to start warning for low quantity in stock
|
|
102
|
+
attr :stock_warning, Sized::Float[0.0, 99_999_999_999_999.9]
|
|
103
|
+
|
|
104
|
+
# SupplierName Name of the supplier
|
|
105
|
+
attr :supplier_name, Coercible::String.optional, :read_only
|
|
106
|
+
|
|
107
|
+
# SupplierNumber Supplier number for the article.
|
|
108
|
+
# The number must be of an existing supplier.
|
|
109
|
+
attr :supplier_number, Coercible::String.optional
|
|
110
|
+
|
|
111
|
+
# Type The type of the article
|
|
112
|
+
attr :type, ArticleTypes
|
|
113
|
+
|
|
114
|
+
# Unit Unit code for the article.
|
|
115
|
+
# The code must be of an existing unit.
|
|
116
|
+
attr :unit, Coercible::String.optional
|
|
117
|
+
|
|
118
|
+
# VAT VAT percent, this is predefined by the VAT for the sales account
|
|
119
|
+
attr :vat <=> 'VAT', Coercible::Float.optional
|
|
120
|
+
|
|
121
|
+
# WebshopArticle If the article is a webshop article
|
|
122
|
+
attr :webshop_article, Bool.optional, Boolean
|
|
123
|
+
|
|
124
|
+
# Weight Weight of the article in grams
|
|
125
|
+
attr :weight, Sized::Integer[0, 999_999_999]
|
|
126
|
+
|
|
127
|
+
# Width Width of the article in millimeters.
|
|
128
|
+
attr :width, Sized::Integer[0, 999_999_999]
|
|
129
|
+
|
|
130
|
+
# True If the article has expired
|
|
131
|
+
attr :expired, Bool.optional, Boolean
|
|
132
|
+
|
|
133
|
+
# CostCalculationMethod Cost calculation method used for the article.
|
|
134
|
+
attr :cost_calculation_method, Coercible::String.optional
|
|
135
|
+
|
|
136
|
+
# StockAccount Account number for stock.
|
|
137
|
+
attr :stock_account, Types::AccountNumber
|
|
138
|
+
|
|
139
|
+
# StockChangeAccount Account number for stock changes.
|
|
140
|
+
attr :stock_change_account, Types::AccountNumber
|
|
141
|
+
|
|
142
|
+
# DirectCost Direct cost of the article.
|
|
143
|
+
attr :direct_cost, Coercible::Float.optional
|
|
144
|
+
|
|
145
|
+
# FreightCost Freight cost of the article.
|
|
146
|
+
attr :freight_cost, Coercible::Float.optional
|
|
147
|
+
|
|
148
|
+
# OtherCost Other cost of the article.
|
|
149
|
+
attr :other_cost, Coercible::Float.optional
|
|
150
|
+
|
|
151
|
+
# DefaultStockPoint Default stock point for the article.
|
|
152
|
+
attr :default_stock_point, Coercible::String.optional
|
|
153
|
+
|
|
154
|
+
# DefaultStockLocation Default stock location for the article.
|
|
155
|
+
attr :default_stock_location, Coercible::String.optional
|
|
156
|
+
|
|
157
|
+
# CommodityCode Commodity code of the article.
|
|
158
|
+
attr :commodity_code, Coercible::String.optional
|
|
159
|
+
end
|
|
160
|
+
end
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Fortnox
|
|
4
|
+
class Customer < Fortnox::Resource
|
|
5
|
+
using RestEasy::Refinements
|
|
6
|
+
|
|
7
|
+
configure do
|
|
8
|
+
path 'customers'
|
|
9
|
+
instance_wrapper 'Customer'
|
|
10
|
+
collection_wrapper 'Customers'
|
|
11
|
+
scope 'customer'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Direct URL to the record.
|
|
15
|
+
attr :url <=> '@url', Coercible::String.optional, :read_only
|
|
16
|
+
|
|
17
|
+
# First address of the customer
|
|
18
|
+
attr :address1, Sized::String[1024]
|
|
19
|
+
|
|
20
|
+
# Second address of the customer
|
|
21
|
+
attr :address2, Sized::String[1024]
|
|
22
|
+
|
|
23
|
+
# City of the customer
|
|
24
|
+
attr :city, Sized::String[1024]
|
|
25
|
+
|
|
26
|
+
# Country of the customer
|
|
27
|
+
attr :country, Coercible::String.optional, :read_only
|
|
28
|
+
|
|
29
|
+
# Comments
|
|
30
|
+
attr :comments, Sized::String[1024]
|
|
31
|
+
|
|
32
|
+
# Currency of the customer
|
|
33
|
+
attr :currency, Currencies
|
|
34
|
+
|
|
35
|
+
# Cost center of the customer
|
|
36
|
+
attr :cost_center, Coercible::String.optional
|
|
37
|
+
|
|
38
|
+
# Country code of the customer
|
|
39
|
+
attr :country_code, Sized::String[2]
|
|
40
|
+
|
|
41
|
+
# Customer number
|
|
42
|
+
key :customer_number, Sized::String[1024]
|
|
43
|
+
|
|
44
|
+
# Default delivery types
|
|
45
|
+
attr :default_delivery_types, Structs::DefaultDeliveryTypes, Mappers::Struct.for(Structs::DefaultDeliveryTypes)
|
|
46
|
+
|
|
47
|
+
# Default templates
|
|
48
|
+
attr :default_templates, Structs::DefaultTemplates, Mappers::Struct.for(Structs::DefaultTemplates)
|
|
49
|
+
|
|
50
|
+
# First delivery address of the customer
|
|
51
|
+
attr :delivery_address1, Sized::String[1024]
|
|
52
|
+
|
|
53
|
+
# Second delivery address of the customer
|
|
54
|
+
attr :delivery_address2, Sized::String[1024]
|
|
55
|
+
|
|
56
|
+
# Delivery city of the customer
|
|
57
|
+
attr :delivery_city, Sized::String[1024]
|
|
58
|
+
|
|
59
|
+
# Delivery country of the customer
|
|
60
|
+
attr :delivery_country, Coercible::String.optional, :read_only
|
|
61
|
+
|
|
62
|
+
# Delivery country code of the customer
|
|
63
|
+
attr :delivery_country_code, Sized::String[2]
|
|
64
|
+
|
|
65
|
+
# Delivery fax number of the customer
|
|
66
|
+
attr :delivery_fax, Sized::String[1024]
|
|
67
|
+
|
|
68
|
+
# Delivery name of the customer
|
|
69
|
+
attr :delivery_name, Sized::String[1024]
|
|
70
|
+
|
|
71
|
+
# First delivery phone number of the customer
|
|
72
|
+
attr :delivery_phone1, Sized::String[1024]
|
|
73
|
+
|
|
74
|
+
# Second delivery phone number of the customer
|
|
75
|
+
attr :delivery_phone2, Sized::String[1024]
|
|
76
|
+
|
|
77
|
+
# Delivery zip code of the customer
|
|
78
|
+
attr :delivery_zip_code, Sized::String[1024]
|
|
79
|
+
|
|
80
|
+
# Email address of the customer
|
|
81
|
+
attr :email, Email
|
|
82
|
+
|
|
83
|
+
# Invoice email address of the customer
|
|
84
|
+
attr :email_invoice, Email
|
|
85
|
+
|
|
86
|
+
# Invoice BCC email address of the customer
|
|
87
|
+
attr :email_invoice_bcc <=> 'EmailInvoiceBCC', Email
|
|
88
|
+
|
|
89
|
+
# Invoice CC email address of the customer
|
|
90
|
+
attr :email_invoice_cc <=> 'EmailInvoiceCC', Email
|
|
91
|
+
|
|
92
|
+
# Offer email address of the customer
|
|
93
|
+
attr :email_offer, Email
|
|
94
|
+
|
|
95
|
+
# Offer BCC email address of the customer
|
|
96
|
+
attr :email_offer_bcc <=> 'EmailOfferBCC', Email
|
|
97
|
+
|
|
98
|
+
# Offer CC email address of the customer
|
|
99
|
+
attr :email_offer_cc <=> 'EmailOfferCC', Email
|
|
100
|
+
|
|
101
|
+
# Order email address of the customer
|
|
102
|
+
attr :email_order, Email
|
|
103
|
+
|
|
104
|
+
# Order BCC email address of the customer
|
|
105
|
+
attr :email_order_bcc <=> 'EmailOrderBCC', Email
|
|
106
|
+
|
|
107
|
+
# Order CC email address of the customer
|
|
108
|
+
attr :email_order_cc <=> 'EmailOrderCC', Email
|
|
109
|
+
|
|
110
|
+
# Fax number of the customer
|
|
111
|
+
attr :fax, Sized::String[1024]
|
|
112
|
+
|
|
113
|
+
# Invoice administration fee, 12 digits (incl. decimals)
|
|
114
|
+
attr :invoice_administration_fee, Sized::Float[0.0, 99_999_999_999.9]
|
|
115
|
+
|
|
116
|
+
# Invoice discount, 12 digits (incl. decimals)
|
|
117
|
+
attr :invoice_discount, Sized::Float[0.0, 99_999_999_999.9]
|
|
118
|
+
|
|
119
|
+
# Invoice freight fee, 12 digits (incl. decimals)
|
|
120
|
+
attr :invoice_freight, Sized::Float[0.0, 99_999_999_999.9]
|
|
121
|
+
|
|
122
|
+
# Invoice remark
|
|
123
|
+
attr :invoice_remark, Sized::String[1024]
|
|
124
|
+
|
|
125
|
+
# Name of the customer
|
|
126
|
+
attr :name, Sized::String[1024], :required
|
|
127
|
+
|
|
128
|
+
# Organisation number of the customer
|
|
129
|
+
attr :organisation_number, Sized::String[30]
|
|
130
|
+
|
|
131
|
+
# Our reference
|
|
132
|
+
attr :our_reference, Sized::String[50]
|
|
133
|
+
|
|
134
|
+
# First phone number of the customer
|
|
135
|
+
attr :phone1, Sized::String[1024]
|
|
136
|
+
|
|
137
|
+
# Second phone number of the customer
|
|
138
|
+
attr :phone2, Sized::String[1024]
|
|
139
|
+
|
|
140
|
+
# Price list of the customer
|
|
141
|
+
attr :price_list, Coercible::String.optional
|
|
142
|
+
|
|
143
|
+
# Project of the customer
|
|
144
|
+
attr :project, Coercible::String.optional
|
|
145
|
+
|
|
146
|
+
# Sales account of the customer
|
|
147
|
+
attr :sales_account, Types::AccountNumber
|
|
148
|
+
|
|
149
|
+
# Show prices with VAT included or not
|
|
150
|
+
attr :show_price_vat_included <=> 'ShowPriceVATIncluded', Bool.optional, Boolean
|
|
151
|
+
|
|
152
|
+
# Terms of delivery code
|
|
153
|
+
attr :terms_of_delivery, Coercible::String.optional
|
|
154
|
+
|
|
155
|
+
# Terms of payment code
|
|
156
|
+
attr :terms_of_payment, Coercible::String.optional
|
|
157
|
+
|
|
158
|
+
# Customer type
|
|
159
|
+
attr :type, CustomerTypes
|
|
160
|
+
|
|
161
|
+
# VAT number of the customer
|
|
162
|
+
attr :vat_number <=> 'VATNumber', Coercible::String.optional
|
|
163
|
+
|
|
164
|
+
# VAT type of the customer
|
|
165
|
+
attr :vat_type <=> 'VATType', VATTypes
|
|
166
|
+
|
|
167
|
+
# Visit address of the customer
|
|
168
|
+
attr :visiting_address, Sized::String[128]
|
|
169
|
+
|
|
170
|
+
# Visit city of the customer
|
|
171
|
+
attr :visiting_city, Sized::String[128]
|
|
172
|
+
|
|
173
|
+
# Visit country of the customer
|
|
174
|
+
attr :visiting_country, Coercible::String.optional, :read_only
|
|
175
|
+
|
|
176
|
+
# Visiting country code
|
|
177
|
+
attr :visiting_country_code, Sized::String[2]
|
|
178
|
+
|
|
179
|
+
# Visit zip code of the customer
|
|
180
|
+
attr :visiting_zip_code, Sized::String[10]
|
|
181
|
+
|
|
182
|
+
# Way of delivery code
|
|
183
|
+
attr :way_of_delivery, Coercible::String.optional
|
|
184
|
+
|
|
185
|
+
# Your reference
|
|
186
|
+
attr :your_reference, Sized::String[50]
|
|
187
|
+
|
|
188
|
+
# Zip code of the customer
|
|
189
|
+
attr :zip_code, Sized::String[10]
|
|
190
|
+
|
|
191
|
+
# Active If the customer is active.
|
|
192
|
+
attr :active, Bool.optional, Boolean
|
|
193
|
+
|
|
194
|
+
# Phone number of the customer. Only present in collection responses.
|
|
195
|
+
attr :phone, Coercible::String.optional
|
|
196
|
+
|
|
197
|
+
# External reference
|
|
198
|
+
attr :external_reference, Sized::String[1024]
|
|
199
|
+
|
|
200
|
+
# GLN Global Location Number
|
|
201
|
+
attr :gln <=> 'GLN', Sized::String[13]
|
|
202
|
+
|
|
203
|
+
# GLNDelivery Global Location Number for delivery
|
|
204
|
+
attr :gln_delivery <=> 'GLNDelivery', Sized::String[13]
|
|
205
|
+
|
|
206
|
+
# WWW Website URL
|
|
207
|
+
attr :www <=> 'WWW', Sized::String[128]
|
|
208
|
+
end
|
|
209
|
+
end
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Fortnox
|
|
4
|
+
# Shared attributes for Offer, Order and Invoice — the three "document" resources in Fortnox.
|
|
5
|
+
# In the Fortnox implementation these are so close together that they are saved in the same database table.
|
|
6
|
+
# This is never used standalone, only inherited by the respective resources.
|
|
7
|
+
class Document < Fortnox::Resource
|
|
8
|
+
using RestEasy::Refinements
|
|
9
|
+
|
|
10
|
+
# Url Direct url to the record.
|
|
11
|
+
attr :url <=> '@url', Coercible::String.optional, :read_only
|
|
12
|
+
|
|
13
|
+
# @urlTaxReductionList Direct URL to the tax reduction list.
|
|
14
|
+
attr :tax_reduction_list_url <=> '@urlTaxReductionList', Coercible::String.optional, :read_only
|
|
15
|
+
|
|
16
|
+
# AdministrationFee The document administration fee.
|
|
17
|
+
attr :administration_fee, Coercible::Float.optional
|
|
18
|
+
|
|
19
|
+
# AdministrationFeeVAT VAT of the document administration fee.
|
|
20
|
+
attr :administration_fee_vat <=> 'AdministrationFeeVAT', Coercible::Float.optional, :read_only
|
|
21
|
+
|
|
22
|
+
# Address1 Document address 1.
|
|
23
|
+
attr :address1, Sized::String[1024]
|
|
24
|
+
|
|
25
|
+
# Address2 Document address 2
|
|
26
|
+
attr :address2, Sized::String[1024]
|
|
27
|
+
|
|
28
|
+
# BasisTaxReduction Basis of tax reduction.
|
|
29
|
+
attr :basis_tax_reduction, Coercible::Float.optional, :read_only
|
|
30
|
+
|
|
31
|
+
# Cancelled If the document is cancelled.
|
|
32
|
+
attr :cancelled, Bool.optional, :read_only, Boolean
|
|
33
|
+
|
|
34
|
+
# City City for the document address.
|
|
35
|
+
attr :city, Sized::String[1024]
|
|
36
|
+
|
|
37
|
+
# Comments Comments of the document
|
|
38
|
+
attr :comments, Sized::String[1024]
|
|
39
|
+
|
|
40
|
+
# ContributionPercent Document contribution in percent.
|
|
41
|
+
attr :contribution_percent, Coercible::Float.optional, :read_only
|
|
42
|
+
|
|
43
|
+
# ContributionValue Document contribution in amount.
|
|
44
|
+
attr :contribution_value, Coercible::Float.optional, :read_only
|
|
45
|
+
|
|
46
|
+
# Country Country for the document address.
|
|
47
|
+
attr :country_code <=> 'Country', Sized::String[2], Mappers::CountryCode
|
|
48
|
+
|
|
49
|
+
# CostCenter Code of the cost center.
|
|
50
|
+
attr :cost_center, Coercible::String.optional
|
|
51
|
+
|
|
52
|
+
# Currency Code of the currency.
|
|
53
|
+
attr :currency, Currencies
|
|
54
|
+
|
|
55
|
+
# CurrencyRate Currency rate used for the document
|
|
56
|
+
attr :currency_rate, Coercible::Float.optional
|
|
57
|
+
|
|
58
|
+
# CurrencyUnit Currency unit used for the document
|
|
59
|
+
attr :currency_unit, Coercible::Float.optional
|
|
60
|
+
|
|
61
|
+
# CustomerName Name of the customer
|
|
62
|
+
attr :customer_name, Sized::String[1024]
|
|
63
|
+
|
|
64
|
+
# CustomerNumber Customer number of the customer.
|
|
65
|
+
attr :customer_number, Strict::String, :required
|
|
66
|
+
|
|
67
|
+
# DeliveryAddress1 Document delivery address 1.
|
|
68
|
+
attr :delivery_address1, Sized::String[1024]
|
|
69
|
+
|
|
70
|
+
# DeliveryAddress2 Document delivery address 2.
|
|
71
|
+
attr :delivery_address2, Sized::String[1024]
|
|
72
|
+
|
|
73
|
+
# DeliveryCity City for the document delivery address.
|
|
74
|
+
attr :delivery_city, Sized::String[1024]
|
|
75
|
+
|
|
76
|
+
# DeliveryCountry Country for the document delivery address.
|
|
77
|
+
attr :delivery_country, Sized::String[2], Mappers::CountryCode
|
|
78
|
+
|
|
79
|
+
# DeliveryDate Date of delivery.
|
|
80
|
+
attr :delivery_date, Date.optional, Mappers::Date
|
|
81
|
+
|
|
82
|
+
# DeliveryName Name of the recipient of the delivery
|
|
83
|
+
attr :delivery_name, Sized::String[1024]
|
|
84
|
+
|
|
85
|
+
# DeliveryZipCode ZipCode for the document delivery address.
|
|
86
|
+
attr :delivery_zip_code, Sized::String[1024]
|
|
87
|
+
|
|
88
|
+
# DocumentNumber The document number.
|
|
89
|
+
key :document_number, Coercible::Integer.optional
|
|
90
|
+
|
|
91
|
+
# EmailInformation Separate EmailInformation object
|
|
92
|
+
attr :email_information, Structs::EmailInformation, Mappers::EmailInformation
|
|
93
|
+
|
|
94
|
+
# ExternalInvoiceReference1 External document reference 1
|
|
95
|
+
attr :external_invoice_reference1, Sized::String[80]
|
|
96
|
+
|
|
97
|
+
# ExternalInvoiceReference2 External document reference 2
|
|
98
|
+
attr :external_invoice_reference2, Sized::String[80]
|
|
99
|
+
|
|
100
|
+
# Freight Freight cost of the document. 12 digits (incl. decimals)
|
|
101
|
+
attr :freight, Sized::Float[0.0, 99_999_999_999.9]
|
|
102
|
+
|
|
103
|
+
# FreightVAT VAT of the freight cost.
|
|
104
|
+
attr :freight_vat <=> 'FreightVAT', Coercible::Float.optional, :read_only
|
|
105
|
+
|
|
106
|
+
# Gross Gross value of the document
|
|
107
|
+
attr :gross, Coercible::Float.optional, :read_only
|
|
108
|
+
|
|
109
|
+
# HouseWork If there is any row of the document marked "housework".
|
|
110
|
+
attr :housework <=> 'HouseWork', Bool.optional, :read_only, Boolean
|
|
111
|
+
|
|
112
|
+
# Labels attached to the document.
|
|
113
|
+
attr :labels, Strict::Array.of(Types.Instance(Label)), Mappers::LabelReferences
|
|
114
|
+
|
|
115
|
+
# Net Net amount
|
|
116
|
+
attr :net, Coercible::Float.optional, :read_only
|
|
117
|
+
|
|
118
|
+
# NotCompleted If the document is set as not completed.
|
|
119
|
+
attr :not_completed, Bool.optional, Boolean
|
|
120
|
+
|
|
121
|
+
# OfferReference Reference to the offer, if one exists.
|
|
122
|
+
attr :offer_reference, Coercible::Integer.optional, :read_only
|
|
123
|
+
|
|
124
|
+
# OrganisationNumber Organisation number of the customer for the document.
|
|
125
|
+
attr :organisation_number, Coercible::String.optional, :read_only
|
|
126
|
+
|
|
127
|
+
# OurReference Our reference
|
|
128
|
+
attr :our_reference, Sized::String[50]
|
|
129
|
+
|
|
130
|
+
# Phone1 Phone number 1 of the customer for the document
|
|
131
|
+
attr :phone1, Sized::String[1024]
|
|
132
|
+
|
|
133
|
+
# Phone2 Phone number 2 of the customer for the document
|
|
134
|
+
attr :phone2, Sized::String[1024]
|
|
135
|
+
|
|
136
|
+
# PriceList Code of the price list.
|
|
137
|
+
attr :price_list, Coercible::String.optional
|
|
138
|
+
|
|
139
|
+
# PrintTemplate Print template of the document.
|
|
140
|
+
attr :print_template, Coercible::String.optional
|
|
141
|
+
|
|
142
|
+
# Project Code of the project.
|
|
143
|
+
attr :project, Coercible::String.optional
|
|
144
|
+
|
|
145
|
+
# Remarks Remarks of the document
|
|
146
|
+
attr :remarks, Sized::String[1024]
|
|
147
|
+
|
|
148
|
+
# RoundOff Round off amount for the document.
|
|
149
|
+
attr :round_off, Coercible::Float.optional, :read_only
|
|
150
|
+
|
|
151
|
+
# Sent If the document is printed or sent in any way.
|
|
152
|
+
attr :sent, Bool.optional, :read_only, Boolean
|
|
153
|
+
|
|
154
|
+
# TaxReduction The amount of tax reduction.
|
|
155
|
+
attr :tax_reduction, Coercible::Integer.optional, :read_only
|
|
156
|
+
|
|
157
|
+
# TaxReductionType Type of tax reduction.
|
|
158
|
+
attr :tax_reduction_type, TaxReductionTypes
|
|
159
|
+
|
|
160
|
+
# TermsOfDelivery Code of the terms of delivery.
|
|
161
|
+
attr :terms_of_delivery, Coercible::String.optional
|
|
162
|
+
|
|
163
|
+
# TermsOfPayment Code of the terms of payment.
|
|
164
|
+
attr :terms_of_payment, Coercible::String.optional
|
|
165
|
+
|
|
166
|
+
# Total The total amount of the document.
|
|
167
|
+
attr :total, Coercible::Float.optional, :read_only
|
|
168
|
+
|
|
169
|
+
# TotalVAT The total VAT amount of the document.
|
|
170
|
+
attr :total_vat <=> 'TotalVAT', Coercible::Float.optional, :read_only
|
|
171
|
+
|
|
172
|
+
# VATIncluded If the price of the document is including VAT.
|
|
173
|
+
attr :vat_included <=> 'VATIncluded', Bool.optional, Boolean
|
|
174
|
+
|
|
175
|
+
# WayOfDelivery Code of the way of delivery.
|
|
176
|
+
attr :way_of_delivery, Coercible::String.optional
|
|
177
|
+
|
|
178
|
+
# YourOrderNumber Your order number
|
|
179
|
+
attr :your_order_number, Sized::String[75]
|
|
180
|
+
|
|
181
|
+
# YourReference Your reference
|
|
182
|
+
attr :your_reference, Sized::String[50]
|
|
183
|
+
|
|
184
|
+
# ZipCode Zip code of the document
|
|
185
|
+
attr :zip_code, Sized::String[1024]
|
|
186
|
+
|
|
187
|
+
# Language Language code.
|
|
188
|
+
attr :language, Coercible::String.optional
|
|
189
|
+
|
|
190
|
+
# OutboundDate Date of outbound delivery.
|
|
191
|
+
attr :outbound_date, Date.optional, Mappers::Date
|
|
192
|
+
|
|
193
|
+
# TimeBasisReference Reference to time basis.
|
|
194
|
+
attr :time_basis_reference, Coercible::Integer.optional
|
|
195
|
+
|
|
196
|
+
# TotalToPay Total amount to pay.
|
|
197
|
+
attr :total_to_pay, Coercible::Float.optional
|
|
198
|
+
|
|
199
|
+
# WarehouseReady If the document is warehouse ready.
|
|
200
|
+
attr :warehouse_ready, Bool.optional, Boolean
|
|
201
|
+
end
|
|
202
|
+
end
|