fortnox-api 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +9 -1104
- data/.travis.yml +22 -2
- data/Gemfile +3 -1
- data/Guardfile +4 -2
- data/README.md +2 -2
- data/Rakefile +3 -1
- data/bin/console +17 -3
- data/fortnox-api.gemspec +32 -27
- data/lib/fortnox/api.rb +17 -16
- data/lib/fortnox/api/circular_queue.rb +13 -7
- data/lib/fortnox/api/mappers.rb +29 -25
- data/lib/fortnox/api/mappers/article.rb +7 -6
- data/lib/fortnox/api/mappers/base.rb +18 -16
- data/lib/fortnox/api/mappers/base/from_json.rb +37 -30
- data/lib/fortnox/api/mappers/base/to_json.rb +39 -37
- data/lib/fortnox/api/mappers/customer.rb +7 -7
- data/lib/fortnox/api/mappers/default_delivery_types.rb +4 -2
- data/lib/fortnox/api/mappers/default_templates.rb +5 -4
- data/lib/fortnox/api/mappers/edi_information.rb +5 -4
- data/lib/fortnox/api/mappers/email_information.rb +5 -4
- data/lib/fortnox/api/mappers/invoice.rb +10 -8
- data/lib/fortnox/api/mappers/invoice_row.rb +12 -7
- data/lib/fortnox/api/mappers/order.rb +10 -7
- data/lib/fortnox/api/mappers/order_row.rb +13 -6
- data/lib/fortnox/api/mappers/project.rb +6 -4
- data/lib/fortnox/api/mappers/terms_of_payments.rb +17 -0
- data/lib/fortnox/api/mappers/unit.rb +17 -0
- data/lib/fortnox/api/models.rb +9 -5
- data/lib/fortnox/api/models/article.rb +68 -67
- data/lib/fortnox/api/models/base.rb +52 -36
- data/lib/fortnox/api/models/customer.rb +95 -94
- data/lib/fortnox/api/models/document.rb +186 -0
- data/lib/fortnox/api/models/invoice.rb +44 -44
- data/lib/fortnox/api/models/label.rb +5 -3
- data/lib/fortnox/api/models/order.rb +8 -8
- data/lib/fortnox/api/models/project.rb +10 -8
- data/lib/fortnox/api/models/terms_of_payments.rb +28 -0
- data/lib/fortnox/api/models/unit.rb +24 -0
- data/lib/fortnox/api/repositories.rb +9 -5
- data/lib/fortnox/api/repositories/article.rb +6 -4
- data/lib/fortnox/api/repositories/base.rb +49 -46
- data/lib/fortnox/api/repositories/base/loaders.rb +32 -36
- data/lib/fortnox/api/repositories/base/savers.rb +23 -21
- data/lib/fortnox/api/repositories/customer.rb +6 -4
- data/lib/fortnox/api/repositories/invoice.rb +6 -4
- data/lib/fortnox/api/repositories/order.rb +6 -4
- data/lib/fortnox/api/repositories/project.rb +6 -4
- data/lib/fortnox/api/repositories/terms_of_payments.rb +17 -0
- data/lib/fortnox/api/repositories/unit.rb +17 -0
- data/lib/fortnox/api/request_handling.rb +12 -12
- data/lib/fortnox/api/types.rb +62 -11
- data/lib/fortnox/api/types/default_delivery_types.rb +5 -3
- data/lib/fortnox/api/types/default_templates.rb +3 -1
- data/lib/fortnox/api/types/defaulted.rb +2 -2
- data/lib/fortnox/api/types/document_row.rb +41 -42
- data/lib/fortnox/api/types/edi_information.rb +10 -8
- data/lib/fortnox/api/types/email_information.rb +10 -8
- data/lib/fortnox/api/types/enums.rb +60 -47
- data/lib/fortnox/api/types/invoice_row.rb +8 -8
- data/lib/fortnox/api/types/model.rb +14 -10
- data/lib/fortnox/api/types/nullable.rb +7 -7
- data/lib/fortnox/api/types/order_row.rb +5 -5
- data/lib/fortnox/api/types/required.rb +5 -5
- data/lib/fortnox/api/types/sized.rb +14 -6
- data/lib/fortnox/api/version.rb +3 -1
- data/spec/fortnox/api/mappers/article_spec.rb +3 -1
- data/spec/fortnox/api/mappers/base/from_json_spec.rb +15 -13
- data/spec/fortnox/api/mappers/base/to_json_spec.rb +4 -3
- data/spec/fortnox/api/mappers/base_spec.rb +40 -35
- data/spec/fortnox/api/mappers/contexts/json_conversion.rb +12 -11
- data/spec/fortnox/api/mappers/customer_spec.rb +3 -1
- data/spec/fortnox/api/mappers/default_delivery_types_spec.rb +3 -1
- data/spec/fortnox/api/mappers/edi_information_spec.rb +4 -2
- data/spec/fortnox/api/mappers/email_information_spec.rb +4 -2
- data/spec/fortnox/api/mappers/examples/mapper.rb +17 -9
- data/spec/fortnox/api/mappers/invoice_row_spec.rb +8 -3
- data/spec/fortnox/api/mappers/invoice_spec.rb +4 -1
- data/spec/fortnox/api/mappers/order_row_spec.rb +9 -2
- data/spec/fortnox/api/mappers/order_spec.rb +4 -1
- data/spec/fortnox/api/mappers/project_spec.rb +3 -1
- data/spec/fortnox/api/mappers/terms_of_payments_spec.rb +16 -0
- data/spec/fortnox/api/mappers/unit_spec.rb +57 -0
- data/spec/fortnox/api/models/article_spec.rb +2 -0
- data/spec/fortnox/api/models/base_spec.rb +46 -38
- data/spec/fortnox/api/models/customer_spec.rb +2 -0
- data/spec/fortnox/api/models/examples/document_base.rb +5 -3
- data/spec/fortnox/api/models/examples/model.rb +12 -9
- data/spec/fortnox/api/models/invoice_spec.rb +2 -0
- data/spec/fortnox/api/models/order_spec.rb +2 -0
- data/spec/fortnox/api/models/project_spec.rb +2 -0
- data/spec/fortnox/api/models/terms_of_payments_spec.rb +9 -0
- data/spec/fortnox/api/models/unit_spec.rb +31 -0
- data/spec/fortnox/api/repositories/article_spec.rb +7 -5
- data/spec/fortnox/api/repositories/base_spec.rb +121 -100
- data/spec/fortnox/api/repositories/customer_spec.rb +7 -5
- data/spec/fortnox/api/repositories/examples/all.rb +5 -4
- data/spec/fortnox/api/repositories/examples/find.rb +50 -41
- data/spec/fortnox/api/repositories/examples/only.rb +14 -13
- data/spec/fortnox/api/repositories/examples/save.rb +23 -29
- data/spec/fortnox/api/repositories/examples/save_with_nested_model.rb +11 -11
- data/spec/fortnox/api/repositories/examples/save_with_specially_named_attribute.rb +11 -10
- data/spec/fortnox/api/repositories/examples/search.rb +15 -15
- data/spec/fortnox/api/repositories/invoice_spec.rb +8 -6
- data/spec/fortnox/api/repositories/order_spec.rb +8 -6
- data/spec/fortnox/api/repositories/project_spec.rb +7 -5
- data/spec/fortnox/api/repositories/terms_of_payments_spec.rb +30 -0
- data/spec/fortnox/api/repositories/unit_spec.rb +34 -0
- data/spec/fortnox/api/types/account_number_spec.rb +12 -9
- data/spec/fortnox/api/types/default_delivery_types_spec.rb +6 -4
- data/spec/fortnox/api/types/edi_information_spec.rb +9 -7
- data/spec/fortnox/api/types/email_information_spec.rb +8 -6
- data/spec/fortnox/api/types/email_spec.rb +27 -14
- data/spec/fortnox/api/types/enums_spec.rb +3 -1
- data/spec/fortnox/api/types/examples/document_row.rb +10 -8
- data/spec/fortnox/api/types/examples/enum.rb +29 -22
- data/spec/fortnox/api/types/examples/types.rb +8 -4
- data/spec/fortnox/api/types/housework_types_spec.rb +68 -0
- data/spec/fortnox/api/types/invoice_row_spec.rb +3 -1
- data/spec/fortnox/api/types/model_spec.rb +12 -9
- data/spec/fortnox/api/types/nullable_spec.rb +8 -6
- data/spec/fortnox/api/types/order_row_spec.rb +4 -2
- data/spec/fortnox/api/types/required_spec.rb +4 -2
- data/spec/fortnox/api/types/sized_spec.rb +18 -16
- data/spec/fortnox/api_spec.rb +45 -43
- data/spec/spec_helper.rb +9 -6
- data/spec/support/helpers.rb +3 -1
- data/spec/support/helpers/configuration_helper.rb +2 -0
- data/spec/support/helpers/dummy_class_helper.rb +7 -8
- data/spec/support/helpers/repository_helper.rb +2 -0
- data/spec/support/helpers/when_performing_helper.rb +3 -1
- data/spec/support/matchers.rb +2 -0
- data/spec/support/matchers/type.rb +3 -1
- data/spec/support/matchers/type/attribute_matcher.rb +15 -14
- data/spec/support/matchers/type/enum_matcher.rb +9 -7
- data/spec/support/matchers/type/have_account_number_matcher.rb +11 -9
- data/spec/support/matchers/type/have_country_code_matcher.rb +6 -4
- data/spec/support/matchers/type/have_currency_matcher.rb +4 -2
- data/spec/support/matchers/type/have_customer_type_matcher.rb +6 -4
- data/spec/support/matchers/type/have_default_delivery_type_matcher.rb +4 -2
- data/spec/support/matchers/type/have_discount_type_matcher.rb +4 -2
- data/spec/support/matchers/type/have_email_matcher.rb +11 -9
- data/spec/support/matchers/type/have_housework_type_matcher.rb +9 -0
- data/spec/support/matchers/type/have_nullable_date_matcher.rb +29 -29
- data/spec/support/matchers/type/have_nullable_matcher.rb +23 -21
- data/spec/support/matchers/type/have_nullable_string_matcher.rb +30 -32
- data/spec/support/matchers/type/have_sized_float_matcher.rb +4 -2
- data/spec/support/matchers/type/have_sized_integer_matcher.rb +4 -2
- data/spec/support/matchers/type/have_sized_string_matcher.rb +16 -15
- data/spec/support/matchers/type/have_vat_type_matcher.rb +4 -2
- data/spec/support/matchers/type/numeric_matcher.rb +25 -23
- data/spec/support/matchers/type/require_attribute_matcher.rb +36 -37
- data/spec/support/matchers/type/type_matcher.rb +18 -16
- data/spec/support/vcr_setup.rb +2 -0
- data/spec/vcr_cassettes/orders/{house_work_type_babysitting.yml → housework_type_babysitting.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_cleaning.yml → housework_type_cleaning.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_construction.yml → housework_type_construction.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_cooking.yml → housework_type_cooking.yml} +7 -7
- data/spec/vcr_cassettes/orders/{house_work_type_electricity.yml → housework_type_electricity.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_gardening.yml → housework_type_gardening.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_glassmetalwork.yml → housework_type_glassmetalwork.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_grounddrainagework.yml → housework_type_grounddrainagework.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_hvac.yml → housework_type_hvac.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_masonry.yml → housework_type_masonry.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_othercare.yml → housework_type_othercare.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_othercosts.yml → housework_type_othercosts.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_paintingwallpapering.yml → housework_type_paintingwallpapering.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_snowplowing.yml → housework_type_snowplowing.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_textileclothing.yml → housework_type_textileclothing.yml} +9 -10
- data/spec/vcr_cassettes/orders/{house_work_type_tutoring.yml → housework_type_tutoring.yml} +7 -7
- data/spec/vcr_cassettes/termsofpayments/all.yml +51 -0
- data/spec/vcr_cassettes/termsofpayments/find_failure.yml +45 -0
- data/spec/vcr_cassettes/termsofpayments/find_id_1.yml +46 -0
- data/spec/vcr_cassettes/termsofpayments/find_new.yml +46 -0
- data/spec/vcr_cassettes/termsofpayments/save_new.yml +45 -0
- data/spec/vcr_cassettes/termsofpayments/save_old.yml +46 -0
- data/spec/vcr_cassettes/units/all.yml +48 -0
- data/spec/vcr_cassettes/units/find_failure.yml +45 -0
- data/spec/vcr_cassettes/units/find_id_1.yml +46 -0
- data/spec/vcr_cassettes/units/find_new.yml +48 -0
- data/spec/vcr_cassettes/units/save_new.yml +47 -0
- data/spec/vcr_cassettes/units/save_old.yml +48 -0
- data/spec/vcr_cassettes/units/save_with_specially_named_attribute.yml +47 -0
- metadata +127 -88
- data/docs/account.rb +0 -59
- data/docs/extraction_script.js +0 -23
- data/docs/generation_script.rb +0 -43
- data/docs/json/account.json +0 -77
- data/lib/fortnox/api/models/document_base.rb +0 -189
- data/spec/fortnox/api/types/house_work_types_spec.rb +0 -64
- data/spec/support/matchers/type/have_house_work_type_matcher.rb +0 -7
@@ -1,77 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Fortnox
|
2
4
|
module API
|
3
5
|
module Mapper
|
4
6
|
module FromJSON
|
5
|
-
|
6
7
|
class MissingModelOrMapperException < StandardError
|
7
8
|
end
|
8
9
|
|
9
|
-
def wrapped_json_collection_to_entities_hash(
|
10
|
+
def wrapped_json_collection_to_entities_hash(json_collection_hash)
|
10
11
|
entities_hash = []
|
11
|
-
json_collection_hash[
|
12
|
-
entities_hash << json_hash_to_entity_hash(
|
12
|
+
json_collection_hash[self.class::JSON_COLLECTION_WRAPPER].each do |json_hash|
|
13
|
+
entities_hash << json_hash_to_entity_hash(json_hash, self.class::KEY_MAP)
|
13
14
|
end
|
14
15
|
|
15
16
|
entities_hash
|
16
17
|
end
|
17
18
|
|
18
|
-
def wrapped_json_hash_to_entity_hash(
|
19
|
-
json_hash_to_entity_hash(
|
20
|
-
self.class::KEY_MAP
|
19
|
+
def wrapped_json_hash_to_entity_hash(json_entity_hash)
|
20
|
+
json_hash_to_entity_hash(json_entity_hash[self.class::JSON_ENTITY_WRAPPER],
|
21
|
+
self.class::KEY_MAP)
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
24
25
|
|
25
|
-
def json_hash_to_entity_hash(
|
26
|
-
hash.each_with_object(
|
27
|
-
converted_key = convert_key_from_json(
|
26
|
+
def json_hash_to_entity_hash(hash, key_map)
|
27
|
+
hash.each_with_object({}) do |(key, value), json_hash|
|
28
|
+
converted_key = convert_key_from_json(key, key_map)
|
28
29
|
json_hash[converted_key] =
|
29
30
|
if value.respond_to?(:each)
|
30
|
-
convert_collection(
|
31
|
+
convert_collection(key, value)
|
31
32
|
else
|
32
33
|
value
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
|
-
def convert_collection(
|
38
|
+
def convert_collection(key, collection)
|
38
39
|
mapper_name = key.downcase
|
39
40
|
if Registry.key?(mapper_name)
|
40
|
-
convert_nested_data(
|
41
|
+
convert_nested_data(mapper_name, key, collection)
|
41
42
|
else
|
42
43
|
# NOTE: This probably means this is a nested model that we have
|
43
44
|
# not implemented yet, or that is missing a mapper.
|
44
45
|
# Raise exception during test run if this happens so that we can
|
45
46
|
# add it before a new release.
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
message = "for #{key} (#{mapper_name}, #{Fortnox::API::Mapper::DefaultTemplates.canonical_name_sym}) with"\
|
49
|
+
" #{collection}"
|
50
|
+
|
51
|
+
raise MissingModelOrMapperException, message if ENV['RUBY_ENV']
|
52
|
+
Fortnox::API.logger.warn("Missing Model or Mapper implementation for #{key} with attributes: #{collection}")
|
53
|
+
return convert_hash_keys_from_json_format(collection, {})
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
53
|
-
def convert_nested_data(
|
54
|
-
nested_mapper = Registry[
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
def convert_nested_data(_mapper_name, key, nested_data)
|
58
|
+
nested_mapper = Registry[key.downcase]
|
59
|
+
|
60
|
+
# Assume Hash of nested model
|
61
|
+
return json_hash_to_entity_hash(nested_data, nested_mapper::KEY_MAP) unless nested_data.is_a?(::Array)
|
62
|
+
|
63
|
+
# Array of nested models
|
64
|
+
nested_data.each_with_object([]) do |value, nested_models|
|
65
|
+
nested_models << json_hash_to_entity_hash(value, nested_mapper::KEY_MAP)
|
61
66
|
end
|
62
67
|
end
|
63
68
|
|
64
|
-
def convert_key_from_json(
|
65
|
-
key_map.key(
|
69
|
+
def convert_key_from_json(key, key_map)
|
70
|
+
key_map.key(key) || default_key_from_json_transform(key)
|
66
71
|
end
|
67
72
|
|
68
|
-
def default_key_from_json_transform(
|
73
|
+
def default_key_from_json_transform(key)
|
69
74
|
key = key.to_s
|
70
|
-
unless key =~ /\A[A-Z]+\z/
|
71
|
-
key = key.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z])([A-Z])/, '\1_\2')
|
72
|
-
end
|
75
|
+
key = camelcase_to_underscore(key) unless key =~ /\A[A-Z]+\z/
|
73
76
|
key.downcase.to_sym
|
74
77
|
end
|
78
|
+
|
79
|
+
def camelcase_to_underscore(key)
|
80
|
+
key.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z])([A-Z])/, '\1_\2')
|
81
|
+
end
|
75
82
|
end
|
76
83
|
end
|
77
84
|
end
|
@@ -1,64 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Fortnox
|
2
4
|
module API
|
3
5
|
module Mapper
|
4
6
|
module ToJSON
|
5
7
|
def self.included(base)
|
6
|
-
base.
|
8
|
+
base.send :extend, ClassMethods
|
7
9
|
|
8
|
-
|
10
|
+
base.send :private_class_method,
|
11
|
+
:convert_hash_keys_to_json_format,
|
12
|
+
:convert_key_to_json,
|
13
|
+
:default_key_to_json_transform,
|
14
|
+
:sanitise
|
15
|
+
end
|
9
16
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
module ClassMethods
|
18
|
+
def call(entity, keys_to_filter = {})
|
19
|
+
entity_hash = entity.to_hash
|
20
|
+
clean_entity_hash = sanitise(entity_hash, keys_to_filter)
|
21
|
+
clean_entity_hash = convert_hash_keys_to_json_format(clean_entity_hash)
|
22
|
+
Registry[:hash].call(clean_entity_hash)
|
23
|
+
end
|
16
24
|
|
17
|
-
|
25
|
+
# PRIVATE
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
27
|
+
def convert_hash_keys_to_json_format(hash)
|
28
|
+
hash.each_with_object({}) do |(key, value), json_hash|
|
29
|
+
json_hash[convert_key_to_json(key)] = value
|
23
30
|
end
|
31
|
+
end
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
def convert_key_to_json(key)
|
34
|
+
self::KEY_MAP.fetch(key) { default_key_to_json_transform(key) }
|
35
|
+
end
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
|
37
|
+
def default_key_to_json_transform(key)
|
38
|
+
key.to_s.split('_').map(&:capitalize).join('')
|
39
|
+
end
|
32
40
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
41
|
+
def sanitise(hash, keys_to_filter)
|
42
|
+
hash.reject do |key, value|
|
43
|
+
next false if keys_to_filter.include?(key)
|
44
|
+
value.nil?
|
38
45
|
end
|
39
|
-
|
40
|
-
private_class_method :convert_hash_keys_to_json_format,
|
41
|
-
:convert_key_to_json,
|
42
|
-
:default_key_to_json_transform,
|
43
|
-
:sanitise
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
|
-
def entity_to_hash(
|
48
|
-
entity_json_hash = Registry[
|
49
|
-
.call(
|
50
|
-
wrap_entity_json_hash(
|
49
|
+
def entity_to_hash(entity, keys_to_filter)
|
50
|
+
entity_json_hash = Registry[mapper_name_for(entity)]
|
51
|
+
.call(entity, keys_to_filter)
|
52
|
+
wrap_entity_json_hash(entity_json_hash)
|
51
53
|
end
|
52
54
|
|
53
|
-
def wrap_entity_json_hash(
|
55
|
+
def wrap_entity_json_hash(entity_json_hash)
|
54
56
|
{ self.class::JSON_ENTITY_WRAPPER => entity_json_hash }
|
55
57
|
end
|
56
58
|
|
57
59
|
private
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
61
|
+
def mapper_name_for(value)
|
62
|
+
value.class.name.split('::').last.downcase.to_sym
|
63
|
+
end
|
62
64
|
end
|
63
65
|
end
|
64
66
|
end
|
@@ -1,10 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fortnox/api/mappers/base'
|
2
4
|
|
3
5
|
module Fortnox
|
4
6
|
module API
|
5
7
|
module Mapper
|
6
8
|
class Customer < Fortnox::API::Mapper::Base
|
7
|
-
|
8
9
|
KEY_MAP = {
|
9
10
|
vat_type: 'VATType',
|
10
11
|
vat_number: 'VATNumber',
|
@@ -14,14 +15,13 @@ module Fortnox
|
|
14
15
|
email_offer_cc: 'EmailOfferCC',
|
15
16
|
email_order_bcc: 'EmailOrderBCC',
|
16
17
|
email_order_cc: 'EmailOrderCC',
|
17
|
-
show_price_vat_included: 'ShowPriceVATIncluded'
|
18
|
+
show_price_vat_included: 'ShowPriceVATIncluded'
|
18
19
|
}.freeze
|
19
|
-
JSON_ENTITY_WRAPPER = 'Customer'
|
20
|
-
JSON_COLLECTION_WRAPPER = 'Customers'
|
21
|
-
|
20
|
+
JSON_ENTITY_WRAPPER = 'Customer'
|
21
|
+
JSON_COLLECTION_WRAPPER = 'Customers'
|
22
22
|
end
|
23
23
|
|
24
|
-
Registry.register(
|
24
|
+
Registry.register(Customer.canonical_name_sym, Customer)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fortnox/api/mappers/base'
|
2
4
|
|
3
5
|
module Fortnox
|
4
6
|
module API
|
@@ -7,7 +9,7 @@ module Fortnox
|
|
7
9
|
KEY_MAP = {}.freeze
|
8
10
|
end
|
9
11
|
|
10
|
-
Registry.register(
|
12
|
+
Registry.register(DefaultDeliveryTypes.canonical_name_sym, DefaultDeliveryTypes)
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,15 +1,16 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fortnox/api/mappers/base'
|
2
4
|
|
3
5
|
module Fortnox
|
4
6
|
module API
|
5
7
|
module Mapper
|
6
8
|
class DefaultTemplates < Fortnox::API::Mapper::Base
|
7
|
-
|
8
9
|
KEY_MAP = {}.freeze
|
9
|
-
JSON_ENTITY_WRAPPER = JSON_COLLECTION_WRAPPER = 'DefaultTemplates'
|
10
|
+
JSON_ENTITY_WRAPPER = JSON_COLLECTION_WRAPPER = 'DefaultTemplates'
|
10
11
|
end
|
11
12
|
|
12
|
-
Registry.register(
|
13
|
+
Registry.register(DefaultTemplates.canonical_name_sym, DefaultTemplates)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -1,10 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fortnox/api/mappers/base'
|
2
4
|
|
3
5
|
module Fortnox
|
4
6
|
module API
|
5
7
|
module Mapper
|
6
8
|
class EDIInformation < Fortnox::API::Mapper::Base
|
7
|
-
|
8
9
|
KEY_MAP = {
|
9
10
|
edi_global_location_number: 'EDIGlobalLocationNumber',
|
10
11
|
edi_global_location_number_delivery: 'EDIGlobalLocationNumberDelivery',
|
@@ -13,10 +14,10 @@ module Fortnox
|
|
13
14
|
edi_our_electronic_reference: 'EDIOurElectronicReference',
|
14
15
|
edi_your_electronic_reference: 'EDIYourElectronicReference'
|
15
16
|
}.freeze
|
16
|
-
JSON_ENTITY_WRAPPER = JSON_COLLECTION_WRAPPER = 'EDIInformation'
|
17
|
+
JSON_ENTITY_WRAPPER = JSON_COLLECTION_WRAPPER = 'EDIInformation'
|
17
18
|
end
|
18
19
|
|
19
|
-
Registry.register(
|
20
|
+
Registry.register(EDIInformation.canonical_name_sym, EDIInformation)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -1,18 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fortnox/api/mappers/base'
|
2
4
|
|
3
5
|
module Fortnox
|
4
6
|
module API
|
5
7
|
module Mapper
|
6
8
|
class EmailInformation < Fortnox::API::Mapper::Base
|
7
|
-
|
8
9
|
KEY_MAP = {
|
9
10
|
email_address_bcc: 'EmailAddressBCC',
|
10
11
|
email_address_cc: 'EmailAddressCC'
|
11
12
|
}.freeze
|
12
|
-
JSON_ENTITY_WRAPPER = JSON_COLLECTION_WRAPPER = 'EmailInformation'
|
13
|
+
JSON_ENTITY_WRAPPER = JSON_COLLECTION_WRAPPER = 'EmailInformation'
|
13
14
|
end
|
14
15
|
|
15
|
-
Registry.register(
|
16
|
+
Registry.register(EmailInformation.canonical_name_sym, EmailInformation)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -1,27 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fortnox/api/mappers/base'
|
4
|
+
require 'fortnox/api/mappers/edi_information'
|
5
|
+
require 'fortnox/api/mappers/email_information'
|
6
|
+
require 'fortnox/api/mappers/invoice_row'
|
5
7
|
|
6
8
|
module Fortnox
|
7
9
|
module API
|
8
10
|
module Mapper
|
9
11
|
class Invoice < Fortnox::API::Mapper::Base
|
10
|
-
|
11
12
|
KEY_MAP = {
|
12
13
|
administration_fee_vat: 'AdministrationFeeVAT',
|
13
14
|
edi_information: 'EDIInformation',
|
14
15
|
eu_quarterly_report: 'EUQuarterlyReport',
|
15
16
|
freight_vat: 'FreightVAT',
|
17
|
+
housework: 'HouseWork',
|
16
18
|
ocr: 'OCR',
|
17
19
|
total_vat: 'TotalVAT',
|
18
20
|
vat_included: 'VATIncluded'
|
19
21
|
}.freeze
|
20
|
-
JSON_ENTITY_WRAPPER = 'Invoice'
|
21
|
-
JSON_COLLECTION_WRAPPER = 'Invoices'
|
22
|
+
JSON_ENTITY_WRAPPER = 'Invoice'
|
23
|
+
JSON_COLLECTION_WRAPPER = 'Invoices'
|
22
24
|
end
|
23
25
|
|
24
|
-
Registry.register(
|
26
|
+
Registry.register(Invoice.canonical_name_sym, Invoice)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -1,20 +1,25 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fortnox/api/mappers/base'
|
2
4
|
|
3
5
|
module Fortnox
|
4
6
|
module API
|
5
7
|
module Mapper
|
6
8
|
class InvoiceRow < Fortnox::API::Mapper::Base
|
7
9
|
KEY_MAP = {
|
8
|
-
|
10
|
+
housework: 'HouseWork',
|
11
|
+
housework_hours_to_report: 'HouseWorkHoursToReport',
|
12
|
+
housework_type: 'HouseWorkType',
|
9
13
|
price_excluding_vat: 'PriceExcludingVAT',
|
10
|
-
total_excluding_vat: 'TotalExcludingVAT'
|
14
|
+
total_excluding_vat: 'TotalExcludingVAT',
|
15
|
+
vat: 'VAT'
|
11
16
|
}.freeze
|
12
|
-
JSON_ENTITY_WRAPPER = 'InvoiceRow'
|
13
|
-
JSON_COLLECTION_WRAPPER = 'InvoiceRows'
|
17
|
+
JSON_ENTITY_WRAPPER = 'InvoiceRow'
|
18
|
+
JSON_COLLECTION_WRAPPER = 'InvoiceRows'
|
14
19
|
end
|
15
20
|
|
16
|
-
Registry.register(
|
17
|
-
Registry.register(
|
21
|
+
Registry.register(InvoiceRow.canonical_name_sym, InvoiceRow)
|
22
|
+
Registry.register(:invoicerows, InvoiceRow)
|
18
23
|
end
|
19
24
|
end
|
20
25
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fortnox/api/mappers/base'
|
4
|
+
require 'fortnox/api/mappers/edi_information'
|
5
|
+
require 'fortnox/api/mappers/email_information'
|
6
|
+
require 'fortnox/api/mappers/order_row'
|
5
7
|
|
6
8
|
module Fortnox
|
7
9
|
module API
|
@@ -10,14 +12,15 @@ module Fortnox
|
|
10
12
|
KEY_MAP = {
|
11
13
|
administration_fee_vat: 'AdministrationFeeVAT',
|
12
14
|
freight_vat: 'FreightVAT',
|
15
|
+
housework: 'HouseWork',
|
13
16
|
total_vat: 'TotalVAT',
|
14
17
|
vat_included: 'VATIncluded'
|
15
18
|
}.freeze
|
16
|
-
JSON_ENTITY_WRAPPER = 'Order'
|
17
|
-
JSON_COLLECTION_WRAPPER = 'Orders'
|
19
|
+
JSON_ENTITY_WRAPPER = 'Order'
|
20
|
+
JSON_COLLECTION_WRAPPER = 'Orders'
|
18
21
|
end
|
19
22
|
|
20
|
-
Registry.register(
|
23
|
+
Registry.register(Order.canonical_name_sym, Order)
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|