fortnox-ruby 0.0.1 → 0.0.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/fortnox-ruby.gemspec +3 -0
- data/lib/fortnox-ruby.rb +4 -0
- data/lib/fortnox.rb +49 -15
- data/lib/fortnox/client.rb +3 -25
- data/lib/fortnox/configurable.rb +2 -3
- data/lib/fortnox/default.rb +0 -6
- data/lib/fortnox/json_fields_mapper.rb +36 -0
- data/lib/fortnox/relation.rb +15 -0
- data/lib/fortnox/relation_builder.rb +25 -0
- data/lib/fortnox/request.rb +42 -0
- data/lib/fortnox/resource.rb +83 -4
- data/lib/fortnox/resources/account.rb +8 -0
- data/lib/fortnox/resources/account_chart.rb +5 -0
- data/lib/fortnox/resources/archive.rb +5 -0
- data/lib/fortnox/resources/article.rb +11 -0
- data/lib/fortnox/resources/article_file_connection.rb +5 -0
- data/lib/fortnox/resources/article_url_connection.rb +5 -0
- data/lib/fortnox/resources/company_setting.rb +9 -0
- data/lib/fortnox/resources/contract.rb +14 -0
- data/lib/fortnox/resources/contract_accrual.rb +6 -0
- data/lib/fortnox/resources/contract_template.rb +8 -0
- data/lib/fortnox/resources/cost_center.rb +5 -0
- data/lib/fortnox/resources/currency.rb +5 -0
- data/lib/fortnox/resources/customer.rb +14 -8
- data/lib/fortnox/resources/financial_year.rb +5 -0
- data/lib/fortnox/resources/inbox.rb +4 -0
- data/lib/fortnox/resources/invoice.rb +20 -0
- data/lib/fortnox/resources/invoice_accrual.rb +6 -0
- data/lib/fortnox/resources/invoice_payment.rb +9 -0
- data/lib/fortnox/resources/locked_period.rb +5 -0
- data/lib/fortnox/resources/mode_of_payment.rb +5 -0
- data/lib/fortnox/resources/offer.rb +16 -0
- data/lib/fortnox/resources/order.rb +18 -0
- data/lib/fortnox/resources/price.rb +5 -0
- data/lib/fortnox/resources/price_list.rb +5 -0
- data/lib/fortnox/resources/print_template.rb +5 -0
- data/lib/fortnox/resources/project.rb +5 -0
- data/lib/fortnox/resources/supplier.rb +12 -0
- data/lib/fortnox/resources/supplier_invoice.rb +10 -0
- data/lib/fortnox/resources/supplier_invoice_accrual.rb +7 -0
- data/lib/fortnox/resources/supplier_invoice_external_url_connection.rb +5 -0
- data/lib/fortnox/resources/supplier_invoice_file_connection.rb +5 -0
- data/lib/fortnox/resources/supplier_invoice_payment.rb +9 -0
- data/lib/fortnox/resources/tax_reduction.rb +9 -0
- data/lib/fortnox/resources/terms_of_delivery.rb +5 -0
- data/lib/fortnox/resources/terms_of_payment.rb +5 -0
- data/lib/fortnox/resources/unit.rb +5 -0
- data/lib/fortnox/resources/voucher.rb +7 -0
- data/lib/fortnox/resources/voucher_file_connection.rb +5 -0
- data/lib/fortnox/resources/voucher_series.rb +5 -0
- data/lib/fortnox/resources/way_of_delivery.rb +5 -0
- data/lib/fortnox/version.rb +1 -1
- metadata +62 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee8bf6ab8bac2b6b7552fef0ecd51c9f4c89a45b
|
4
|
+
data.tar.gz: 4f07c987bdeb1d1b775ea4c415a4f7ac2c8cb058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38e10da807cada44738b55d5e7e956304aeac1309320e44f86edc3b17f4611fb955079be6ce7f340b975212fea76cd82f8fb09af5e44779c965744556f34ec27
|
7
|
+
data.tar.gz: 6cb161afb2d1c01a0ba12ee4c482301d96959af439bcfc17176a6e2034799cb14158c10c8fda2bf94ad7702f8f280babf66079f763549e7b847ec10745e6bb39
|
data/fortnox-ruby.gemspec
CHANGED
@@ -18,9 +18,12 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.required_ruby_version = '~> 2.0'
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.10"
|
22
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
25
|
spec.add_development_dependency "rspec"
|
24
26
|
spec.add_development_dependency "dotenv", "~> 2.0"
|
25
27
|
spec.add_dependency "httparty", "~> 0.13"
|
28
|
+
spec.add_dependency "activesupport", "~> 4.2"
|
26
29
|
end
|
data/lib/fortnox-ruby.rb
ADDED
data/lib/fortnox.rb
CHANGED
@@ -1,7 +1,55 @@
|
|
1
1
|
require 'httparty'
|
2
|
-
|
2
|
+
|
3
|
+
require 'fortnox/configurable'
|
3
4
|
require 'fortnox/client'
|
4
5
|
require 'fortnox/default'
|
6
|
+
require 'fortnox/error'
|
7
|
+
require 'fortnox/json_fields_mapper'
|
8
|
+
require 'fortnox/relation'
|
9
|
+
require 'fortnox/relation_builder'
|
10
|
+
require 'fortnox/resource'
|
11
|
+
require 'fortnox/request'
|
12
|
+
require 'fortnox/version'
|
13
|
+
|
14
|
+
require 'fortnox/resources/account'
|
15
|
+
require 'fortnox/resources/account_chart'
|
16
|
+
require 'fortnox/resources/archive'
|
17
|
+
require 'fortnox/resources/article'
|
18
|
+
require 'fortnox/resources/article_file_connection'
|
19
|
+
require 'fortnox/resources/article_url_connection'
|
20
|
+
require 'fortnox/resources/company_setting'
|
21
|
+
require 'fortnox/resources/contract'
|
22
|
+
require 'fortnox/resources/contract_accrual'
|
23
|
+
require 'fortnox/resources/contract_template'
|
24
|
+
require 'fortnox/resources/cost_center'
|
25
|
+
require 'fortnox/resources/currency'
|
26
|
+
require 'fortnox/resources/customer'
|
27
|
+
require 'fortnox/resources/financial_year'
|
28
|
+
require 'fortnox/resources/inbox'
|
29
|
+
require 'fortnox/resources/invoice_accrual'
|
30
|
+
require 'fortnox/resources/invoice_payment'
|
31
|
+
require 'fortnox/resources/locked_period'
|
32
|
+
require 'fortnox/resources/mode_of_payment'
|
33
|
+
require 'fortnox/resources/offer'
|
34
|
+
require 'fortnox/resources/order'
|
35
|
+
require 'fortnox/resources/price'
|
36
|
+
require 'fortnox/resources/price_list'
|
37
|
+
require 'fortnox/resources/print_template'
|
38
|
+
require 'fortnox/resources/project'
|
39
|
+
require 'fortnox/resources/supplier'
|
40
|
+
require 'fortnox/resources/supplier_invoice'
|
41
|
+
require 'fortnox/resources/supplier_invoice_accrual'
|
42
|
+
require 'fortnox/resources/supplier_invoice_external_url_connection'
|
43
|
+
require 'fortnox/resources/supplier_invoice_file_connection'
|
44
|
+
require 'fortnox/resources/supplier_invoice_payment'
|
45
|
+
require 'fortnox/resources/tax_reduction'
|
46
|
+
require 'fortnox/resources/terms_of_delivery'
|
47
|
+
require 'fortnox/resources/terms_of_payment'
|
48
|
+
require 'fortnox/resources/unit'
|
49
|
+
require 'fortnox/resources/voucher'
|
50
|
+
require 'fortnox/resources/voucher_file_connection'
|
51
|
+
require 'fortnox/resources/voucher_series'
|
52
|
+
require 'fortnox/resources/way_of_delivery'
|
5
53
|
|
6
54
|
module Fortnox
|
7
55
|
class << self
|
@@ -10,20 +58,6 @@ module Fortnox
|
|
10
58
|
def client
|
11
59
|
@client ||= Fortnox::Client.new(options)
|
12
60
|
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def respond_to_missing?(method_name, include_private=false)
|
17
|
-
client.respond_to?(method_name, include_private)
|
18
|
-
end
|
19
|
-
|
20
|
-
def method_missing(method_name, *args, &block)
|
21
|
-
if client.respond_to?(method_name)
|
22
|
-
client.send(method_name, *args, &block)
|
23
|
-
else
|
24
|
-
super
|
25
|
-
end
|
26
|
-
end
|
27
61
|
end
|
28
62
|
end
|
29
63
|
|
data/lib/fortnox/client.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'fortnox/configurable'
|
2
|
-
require 'fortnox/resource'
|
3
|
-
require 'fortnox/error'
|
4
2
|
|
5
3
|
module Fortnox
|
6
4
|
class Client
|
@@ -16,13 +14,12 @@ module Fortnox
|
|
16
14
|
headers 'Accept' => 'application/json', 'Content-Type' => 'application/json'
|
17
15
|
|
18
16
|
format :json
|
17
|
+
base_uri 'https://api.fortnox.se/3/'.freeze
|
19
18
|
|
20
19
|
def initialize(options = {})
|
21
20
|
Fortnox::Configurable.keys.each do |key|
|
22
21
|
instance_variable_set(:"@#{key}", options[key] || Fortnox.instance_variable_get(:"@#{key}"))
|
23
22
|
end
|
24
|
-
|
25
|
-
self.class.default_options.merge!(base_uri: api_endpoint)
|
26
23
|
end
|
27
24
|
|
28
25
|
def fetch_access_token
|
@@ -31,27 +28,8 @@ module Fortnox
|
|
31
28
|
'Authorization-Code' => authorization_code
|
32
29
|
}
|
33
30
|
|
34
|
-
response = get(
|
35
|
-
@access_token =
|
36
|
-
end
|
37
|
-
|
38
|
-
def request(verb, url, options = {})
|
39
|
-
response = send(verb, url, options.merge(headers: auth_headers))
|
40
|
-
if response.success?
|
41
|
-
response
|
42
|
-
else
|
43
|
-
raise Fortnox::Error.from_response(response)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def extract_token(response)
|
50
|
-
response.fetch('Authorization').fetch('AccessToken')
|
51
|
-
end
|
52
|
-
|
53
|
-
def root_path
|
54
|
-
'/'.freeze
|
31
|
+
response = get('/', headers: headers)
|
32
|
+
@access_token = response.fetch('Authorization').fetch('AccessToken')
|
55
33
|
end
|
56
34
|
|
57
35
|
def auth_headers
|
data/lib/fortnox/configurable.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
module Fortnox
|
2
2
|
module Configurable
|
3
3
|
|
4
|
-
attr_accessor :access_token, :client_id, :client_secret, :authorization_code
|
4
|
+
attr_accessor :access_token, :client_id, :client_secret, :authorization_code
|
5
5
|
|
6
6
|
class << self
|
7
7
|
def keys
|
8
8
|
@keys ||= [
|
9
|
-
:access_token,
|
10
|
-
:api_endpoint,
|
11
9
|
:client_id,
|
10
|
+
:access_token,
|
12
11
|
:client_secret,
|
13
12
|
:authorization_code
|
14
13
|
]
|
data/lib/fortnox/default.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module Fortnox
|
2
2
|
module Default
|
3
|
-
API_ENDPOINT = 'https://api.fortnox.se/3/'.freeze
|
4
|
-
|
5
3
|
class << self
|
6
4
|
def options
|
7
5
|
Hash[Fortnox::Configurable.keys.map{|key| [key, send(key)]}]
|
@@ -19,10 +17,6 @@ module Fortnox
|
|
19
17
|
ENV['FORTNOX_CLIENT_SECRET']
|
20
18
|
end
|
21
19
|
|
22
|
-
def api_endpoint
|
23
|
-
ENV['FORTNOX_API_ENDPOINT'] || API_ENDPOINT
|
24
|
-
end
|
25
|
-
|
26
20
|
def authorization_code
|
27
21
|
ENV['FORTNOX_AUTHORIZATION_CODE']
|
28
22
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class JSONFieldsMapper
|
3
|
+
def self.mapping
|
4
|
+
{
|
5
|
+
bg: "BG",
|
6
|
+
pg: "PG",
|
7
|
+
bic: "BIC",
|
8
|
+
ean: "EAN",
|
9
|
+
ocr: "OCR",
|
10
|
+
sru: "SRU",
|
11
|
+
vat: "VAT",
|
12
|
+
www: "WWW",
|
13
|
+
iban: "IBAN",
|
14
|
+
vat_code: "VATCode",
|
15
|
+
vat_type: "VATType",
|
16
|
+
total_vat: "TotalVAT",
|
17
|
+
vat_number: "VATNumber",
|
18
|
+
eu_account: "EUAccount",
|
19
|
+
freight_vat: "FreightVAT",
|
20
|
+
invoice_ocr: "InvoiceOCR",
|
21
|
+
vat_included: "VATIncluded",
|
22
|
+
euvat_account: "EUVATAccount",
|
23
|
+
url_connection: "URLConnection",
|
24
|
+
email_order_cc: "EmailOrderCC",
|
25
|
+
email_offer_cc: "EmailOfferCC",
|
26
|
+
email_order_bcc: "EmailOrderBCC",
|
27
|
+
email_offer_bcc: "EmailOfferBCC",
|
28
|
+
email_invoice_cc: "EmailInvoiceCC",
|
29
|
+
email_invoice_bcc: "EmailInvoiceBCC",
|
30
|
+
administration_fee_vat: "AdministrationFeeVAT",
|
31
|
+
show_price_vat_included: "ShowPriceVATIncluded",
|
32
|
+
external_url_connection: "ExternalURLConnection"
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class Relation
|
3
|
+
attr_reader :name, :type, :class_override
|
4
|
+
|
5
|
+
def initialize(name, type, class_override: nil)
|
6
|
+
@name = name.to_s
|
7
|
+
@type = type
|
8
|
+
@class_override = class_override
|
9
|
+
end
|
10
|
+
|
11
|
+
def relation_class
|
12
|
+
"Fortnox::#{class_override || name.classify}".constantize
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class RelationBuilder
|
3
|
+
attr_reader :resource, :attributes
|
4
|
+
|
5
|
+
def initialize(resource, attributes)
|
6
|
+
@resource = resource
|
7
|
+
@attributes = attributes
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
resource.class.relations.each do |relation|
|
12
|
+
build_relation(relation)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def build_relation(relation)
|
19
|
+
if attrs = attributes.delete(relation.name)
|
20
|
+
value = relation.relation_class.build_objects(attrs)
|
21
|
+
resource.public_send("#{relation.name}=", value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class Request
|
3
|
+
attr_reader :url, :type, :params
|
4
|
+
|
5
|
+
def initialize(type, url, params = {})
|
6
|
+
@url = url
|
7
|
+
@type = type
|
8
|
+
@params = params
|
9
|
+
end
|
10
|
+
|
11
|
+
def content
|
12
|
+
case type
|
13
|
+
when :post, :put
|
14
|
+
{ body: params.to_json }
|
15
|
+
when :get
|
16
|
+
{ query: params }
|
17
|
+
when :delete
|
18
|
+
{}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def execute
|
23
|
+
response.success? ? response.parsed_response : raise_from(response)
|
24
|
+
end
|
25
|
+
|
26
|
+
def raise_from(response)
|
27
|
+
raise Fortnox::Error.from_response(response)
|
28
|
+
end
|
29
|
+
|
30
|
+
def response
|
31
|
+
@response ||= client.send(type, url, {headers: auth_headers}.merge(Fortnox::Client.headers))
|
32
|
+
end
|
33
|
+
|
34
|
+
def auth_headers
|
35
|
+
client.auth_headers
|
36
|
+
end
|
37
|
+
|
38
|
+
def client
|
39
|
+
Fortnox.client
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/fortnox/resource.rb
CHANGED
@@ -1,15 +1,94 @@
|
|
1
|
+
require 'active_support/core_ext/string/inflections.rb'
|
2
|
+
|
1
3
|
module Fortnox
|
2
4
|
class Resource
|
3
|
-
|
5
|
+
class << self
|
6
|
+
def relations
|
7
|
+
@relations ||= Set.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def relation(name, type, class_override: nil)
|
11
|
+
relations << Relation.new(name, type, class_override: class_override)
|
12
|
+
attr_accessor name
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_objects(data)
|
16
|
+
case data
|
17
|
+
when Hash then new(data)
|
18
|
+
when Array then data.map{|item| build_objects(item) }
|
19
|
+
else data
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_writer :default_search_options
|
24
|
+
|
25
|
+
def default_search_options
|
26
|
+
@default_search_options ||= { page: 1, page_size: 50 }
|
27
|
+
end
|
28
|
+
|
29
|
+
def endpoint(value = nil)
|
30
|
+
@endpoint = value if value
|
31
|
+
@endpoint || name.demodulize.downcase.pluralize
|
32
|
+
end
|
33
|
+
|
34
|
+
def search(options = {})
|
35
|
+
query = default_search_options.merge(options)
|
36
|
+
perform_request(:get, "/#{endpoint}", query)
|
37
|
+
end
|
38
|
+
|
39
|
+
def fetch(id = nil)
|
40
|
+
perform_request(:get, "/#{endpoint}/#{id}")
|
41
|
+
end
|
42
|
+
|
43
|
+
def create(attributes)
|
44
|
+
perform_request(:post, "/#{endpoint}", attributes)
|
45
|
+
end
|
46
|
+
|
47
|
+
def perform_request(type, url, params = {})
|
48
|
+
response = Request.new(type, url, params).execute
|
49
|
+
build_objects(response)
|
50
|
+
end
|
51
|
+
end
|
4
52
|
|
5
53
|
def initialize(attributes = {})
|
6
|
-
|
54
|
+
Hash(attributes[self.class.name.demodulize]).each do |key, value|
|
55
|
+
next if /@/ === key
|
56
|
+
public_send("#{key.underscore}=", value)
|
57
|
+
end
|
58
|
+
|
59
|
+
RelationBuilder.new(self, attributes).call
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_json(*args)
|
63
|
+
to_hash.to_json(*args)
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_hash
|
67
|
+
fields_mapping = JSONFieldsMapper.mapping
|
68
|
+
|
69
|
+
instance_variables
|
70
|
+
.each_with_object({}) do |variable, obj|
|
71
|
+
value = instance_variable_get(variable)
|
72
|
+
|
73
|
+
case value
|
74
|
+
when Resource
|
75
|
+
value = value.to_hash
|
76
|
+
when Array
|
77
|
+
value = value.map(&:to_hash)
|
78
|
+
end
|
79
|
+
|
80
|
+
field = variable[1..-1]
|
81
|
+
key = fields_mapping.fetch(field.to_sym, field.camelize)
|
82
|
+
obj[key] = value
|
83
|
+
end
|
7
84
|
end
|
8
85
|
|
9
|
-
def
|
86
|
+
def update(attributes)
|
87
|
+
self.class.perform_request(:put, "#{endpoint}/#{id}", attributes)
|
10
88
|
end
|
11
89
|
|
12
|
-
def
|
90
|
+
def endpoint
|
91
|
+
self.class.endpoint
|
13
92
|
end
|
14
93
|
end
|
15
94
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class Account < Resource
|
3
|
+
attr_accessor :active, :balance_brought_forward, :balance_carried_forward,
|
4
|
+
:cost_center, :cost_center_settings, :description, :number, :project,
|
5
|
+
:project_settings, :sru, :transaction_information, :transaction_information_settings,
|
6
|
+
:vat_code, :year
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class Article < Resource
|
3
|
+
attr_accessor :article_number, :bulky, :construction_account, :depth,
|
4
|
+
:description, :disposable_quantity, :ean, :eu_account, :euvat_account,
|
5
|
+
:expired, :export_account, :height, :housework, :housework_type, :manufacturer,
|
6
|
+
:manufacturer_article_number, :note, :purchase_account, :purchase_price,
|
7
|
+
:quantity_in_stock, :reserved_quantity, :sales_account, :sales_price, :stock_goods,
|
8
|
+
:stock_place, :stock_value, :stock_warning, :supplier_name, :supplier_number,
|
9
|
+
:type, :unit, :vat, :webshop_article, :weight, :width
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class CompanySetting < Resource
|
3
|
+
attr_accessor :address, :bg, :bic, :branch_code, :city, :contact_first_name,
|
4
|
+
:contact_last_name, :country, :country_code, :database_number, :domicile,
|
5
|
+
:email, :fax, :iban, :name, :organization_number, :pg, :phone1, :phone2,
|
6
|
+
:tax_enabled, :vat_number, :visit_address, :visit_city, :visit_country,
|
7
|
+
:visit_country_code, :visit_name, :visit_zip_code, :www, :zip_code
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class Contract < Resource
|
3
|
+
attr_accessor :active, :administration_fee, :comments, :continuous, :contract_date,
|
4
|
+
:contract_length, :contribution_percent, :contribution_value, :cost_center,
|
5
|
+
:currency, :customer_name, :customer_number, :document_number, :email_information,
|
6
|
+
:external_invoice_reference1, :external_invoice_reference2, :freight, :gross,
|
7
|
+
:house_work, :invoice_discount, :invoice_interval, :invoice_rows,
|
8
|
+
:invoices_remaining, :language, :last_invoice_date, :net, :ongoing,
|
9
|
+
:our_reference, :period_end, :period_start, :price_list, :print_template,
|
10
|
+
:project, :remarks, :tax_reduction, :template_name, :template_number,
|
11
|
+
:terms_of_delivery, :terms_of_payment, :total, :total_to_pay, :total_vat,
|
12
|
+
:vat_included, :way_of_delivery, :your_order_number
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class ContractTemplate < Resource
|
3
|
+
attr_accessor :administration_fee, :contract_length, :freight, :invoice_interval,
|
4
|
+
:invoice_rows, :continuous, :our_reference, :print_template, :remarks,
|
5
|
+
:template_name, :template_number, :terms_of_delivery, :terms_of_payment,
|
6
|
+
:way_of_delivery
|
7
|
+
end
|
8
|
+
end
|
@@ -1,11 +1,17 @@
|
|
1
1
|
module Fortnox
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
class Customer < Resource
|
3
|
+
attr_accessor :address1, :address2, :city, :country, :comments, :currency,
|
4
|
+
:cost_center, :country_code, :customer_number, :default_delivery_types,
|
5
|
+
:default_templates, :delivery_address1, :delivery_address2, :delivery_city,
|
6
|
+
:delivery_country, :delivery_country_code, :delivery_fax, :delivery_name,
|
7
|
+
:delivery_phone1, :delivery_phone2, :delivery_zip_code, :email, :email_invoice,
|
8
|
+
:email_invoice_bcc, :email_invoice_cc, :email_offer, :email_offer_bcc,
|
9
|
+
:email_offer_cc, :email_order, :email_order_bcc, :email_order_cc, :fax,
|
10
|
+
:invoice_administration_fee, :invoice_discount, :invoice_freight,
|
11
|
+
:invoice_remark, :name, :organisation_number, :our_reference, :phone1,
|
12
|
+
:phone2, :price_list, :project, :sales_account, :show_price_vat_included,
|
13
|
+
:terms_of_delivery, :terms_of_payment, :type, :vat_number, :vat_type,
|
14
|
+
:visiting_address, :visiting_city, :visiting_country, :visiting_country_code,
|
15
|
+
:visiting_zip_code, :way_of_delivery, :www, :your_reference, :zip_code
|
10
16
|
end
|
11
17
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class Invoice < Resource
|
3
|
+
attr_accessor :address1, :address2, :administration_fee, :administration_fee_vat,
|
4
|
+
:balance, :basis_tax_reduction, :booked, :cancelled, :city, :comments, :contract_reference,
|
5
|
+
:contribution_percent, :contribution_value, :cost_center, :country, :credit,
|
6
|
+
:credit_invoice_reference, :currency, :currency_rate, :currency_unit, :customer_name,
|
7
|
+
:customer_number, :delivery_address1, :delivery_address2, :delivery_city,
|
8
|
+
:delivery_country, :delivery_date, :delivery_name, :delivery_zip_code, :document_number,
|
9
|
+
:due_date, :edi_information, :eu_quarterly_report, :email_information,
|
10
|
+
:external_invoice_reference1, :external_invoice_reference2, :freight, :freight_vat,
|
11
|
+
:gross, :house_work, :invoice_date, :invoice_period_end, :invoice_period_start,
|
12
|
+
:invoice_reference, :invoice_rows, :invoice_type, :language, :last_remind_date,
|
13
|
+
:net, :not_completed, :ocr, :offer_reference, :order_reference, :organisation_number,
|
14
|
+
:our_reference, :payment_way, :phone1, :phone2, :price_list, :print_template,
|
15
|
+
:project, :remarks, :reminders, :round_off, :sent, :tax_reduction,
|
16
|
+
:terms_of_delivery, :terms_of_payment, :total, :total_to_pay, :total_vat,
|
17
|
+
:vat_included, :voucher_number, :voucher_series, :voucher_year, :way_of_delivery,
|
18
|
+
:your_order_number, :your_reference, :zip_code
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class InvoicePayment < Resource
|
3
|
+
attr_accessor :amount, :amount_currency, :booked, :currency, :currency_rate,
|
4
|
+
:currency_unit, :external_invoice_reference1, :external_invoice_reference2,
|
5
|
+
:invoice_customer_name, :invoice_customer_number, :invoice_number, :invoice_due_date,
|
6
|
+
:invoice_ocr, :invoice_total, :mode_of_payment, :number, :payment_date,
|
7
|
+
:voucher_number, :voucher_series, :voucher_year, :source, :write_offs
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class Offer < Resource
|
3
|
+
attr_accessor :administration_fee, :administration_fee_vat, :address1, :address2,
|
4
|
+
:basis_tax_reduction, :cancelled, :city, :comments, :contribution_percent,
|
5
|
+
:contribution_value, :copy_remarks, :country, :cost_center, :currency,
|
6
|
+
:currency_rate, :currency_unit, :customer_name, :customer_number,
|
7
|
+
:delivery_address1, :delivery_address2, :delivery_city, :delivery_country,
|
8
|
+
:delivery_date, :delivery_name, :delivery_zip_code, :document_number,
|
9
|
+
:email_information, :expire_date, :freight, :freight_vat, :gross, :house_work,
|
10
|
+
:invoice_reference, :language, :net, :not_completed, :offer_date, :offer_rows,
|
11
|
+
:order_reference, :organisation_number, :our_reference, :phone1, :phone2,
|
12
|
+
:price_list, :print_template, :project, :remarks, :round_off, :sent, :tax_reduction,
|
13
|
+
:terms_of_delivery, :terms_of_payment, :total, :total_to_pay, :total_vat,
|
14
|
+
:vat_included, :way_of_delivery, :your_reference, :your_reference_number, :zip_code
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class Order < Resource
|
3
|
+
attr_accessor :administration_fee, :administration_fee_vat, :address1,
|
4
|
+
:address2, :basis_tax_reduction, :cancelled, :city, :comments,
|
5
|
+
:contribution_percent, :contribution_value, :copy_remarks, :country,
|
6
|
+
:cost_center, :currency, :currency_rate, :currency_unit, :customer_name,
|
7
|
+
:customer_number, :delivery_address1, :delivery_address2, :delivery_city,
|
8
|
+
:delivery_country, :delivery_date, :delivery_name, :delivery_zip_code,
|
9
|
+
:document_number, :email_information, :external_invoice_reference1,
|
10
|
+
:external_invoice_reference2, :freight, :freight_vat, :gross, :house_work,
|
11
|
+
:invoice_reference, :language, :net, :not_completed, :offer_reference,
|
12
|
+
:order_date, :order_rows, :organisation_number, :our_reference, :phone1,
|
13
|
+
:phone2, :price_list, :print_template, :project, :remarks, :round_off, :sent,
|
14
|
+
:tax_reduction, :terms_of_delivery, :terms_of_payment, :total, :total_to_pay,
|
15
|
+
:total_vat, :vat_included, :way_of_delivery, :your_reference, :your_order_number,
|
16
|
+
:zip_code
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class Supplier < Resource
|
3
|
+
attr_accessor :active, :address1, :address2, :bank, :bank_account_number,
|
4
|
+
:bg, :bic, :branch_code, :city, :clearing_number, :comments, :cost_center,
|
5
|
+
:country, :country_code, :currency, :disable_payment_file, :email, :fax,
|
6
|
+
:iban, :name, :organisation_number, :our_reference, :our_customer_number,
|
7
|
+
:pg, :phone1, :phone2, :pre_defined_account, :project, :supplier_number,
|
8
|
+
:terms_of_payment, :vat_number, :vat_type, :visiting_address, :visiting_city,
|
9
|
+
:visiting_country, :visiting_country_code, :visiting_zip_code, :work_place,
|
10
|
+
:www, :your_reference, :zip_code
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class SupplierInvoice < Resource
|
3
|
+
attr_accessor :administration_fee, :balance, :booked, :cancelled, :comments,
|
4
|
+
:cost_center, :credit, :credit_reference, :currency, :currency_rate,
|
5
|
+
:currency_unit, :disable_payment_file, :due_date, :external_invoice_number,
|
6
|
+
:external_invoice_series, :freight, :given_number, :invoice_date, :invoice_number,
|
7
|
+
:ocr, :our_reference, :project, :round_off_value, :sales_type,
|
8
|
+
:supplier_invoice_rows, :supplier_number, :supplier_name, :total, :vat, :your_reference
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class SupplierInvoicePayment < Resource
|
3
|
+
attr_accessor :amount, :amount_currency, :booked, :currency, :currency_rate,
|
4
|
+
:currency_unit, :information, :invoice_number, :invoice_due_date,
|
5
|
+
:invoice_ocr, :invoice_supplier_name, :invoice_supplier_number,
|
6
|
+
:invoice_total, :mode_of_payment, :number, :payment_date, :source,
|
7
|
+
:voucher_number, :voucher_series, :voucher_year, :write_offs
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Fortnox
|
2
|
+
class TaxReduction < Resource
|
3
|
+
attr_accessor :approved_amount, :asked_amount, :billed_amount, :customer_name,
|
4
|
+
:id, :property_designation, :reference_document_type, :reference_number,
|
5
|
+
:request_sent, :residence_association_organisation_number,
|
6
|
+
:social_security_number, :type_of_reduction, :voucher_number, :voucher_series,
|
7
|
+
:voucher_year
|
8
|
+
end
|
9
|
+
end
|
data/lib/fortnox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fortnox-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.13'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activesupport
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.2'
|
83
97
|
description:
|
84
98
|
email:
|
85
99
|
- birmanmark@gmail.com
|
@@ -98,13 +112,57 @@ files:
|
|
98
112
|
- bin/console
|
99
113
|
- bin/setup
|
100
114
|
- fortnox-ruby.gemspec
|
115
|
+
- lib/fortnox-ruby.rb
|
101
116
|
- lib/fortnox.rb
|
102
117
|
- lib/fortnox/client.rb
|
103
118
|
- lib/fortnox/configurable.rb
|
104
119
|
- lib/fortnox/default.rb
|
105
120
|
- lib/fortnox/error.rb
|
121
|
+
- lib/fortnox/json_fields_mapper.rb
|
122
|
+
- lib/fortnox/relation.rb
|
123
|
+
- lib/fortnox/relation_builder.rb
|
124
|
+
- lib/fortnox/request.rb
|
106
125
|
- lib/fortnox/resource.rb
|
126
|
+
- lib/fortnox/resources/account.rb
|
127
|
+
- lib/fortnox/resources/account_chart.rb
|
128
|
+
- lib/fortnox/resources/archive.rb
|
129
|
+
- lib/fortnox/resources/article.rb
|
130
|
+
- lib/fortnox/resources/article_file_connection.rb
|
131
|
+
- lib/fortnox/resources/article_url_connection.rb
|
132
|
+
- lib/fortnox/resources/company_setting.rb
|
133
|
+
- lib/fortnox/resources/contract.rb
|
134
|
+
- lib/fortnox/resources/contract_accrual.rb
|
135
|
+
- lib/fortnox/resources/contract_template.rb
|
136
|
+
- lib/fortnox/resources/cost_center.rb
|
137
|
+
- lib/fortnox/resources/currency.rb
|
107
138
|
- lib/fortnox/resources/customer.rb
|
139
|
+
- lib/fortnox/resources/financial_year.rb
|
140
|
+
- lib/fortnox/resources/inbox.rb
|
141
|
+
- lib/fortnox/resources/invoice.rb
|
142
|
+
- lib/fortnox/resources/invoice_accrual.rb
|
143
|
+
- lib/fortnox/resources/invoice_payment.rb
|
144
|
+
- lib/fortnox/resources/locked_period.rb
|
145
|
+
- lib/fortnox/resources/mode_of_payment.rb
|
146
|
+
- lib/fortnox/resources/offer.rb
|
147
|
+
- lib/fortnox/resources/order.rb
|
148
|
+
- lib/fortnox/resources/price.rb
|
149
|
+
- lib/fortnox/resources/price_list.rb
|
150
|
+
- lib/fortnox/resources/print_template.rb
|
151
|
+
- lib/fortnox/resources/project.rb
|
152
|
+
- lib/fortnox/resources/supplier.rb
|
153
|
+
- lib/fortnox/resources/supplier_invoice.rb
|
154
|
+
- lib/fortnox/resources/supplier_invoice_accrual.rb
|
155
|
+
- lib/fortnox/resources/supplier_invoice_external_url_connection.rb
|
156
|
+
- lib/fortnox/resources/supplier_invoice_file_connection.rb
|
157
|
+
- lib/fortnox/resources/supplier_invoice_payment.rb
|
158
|
+
- lib/fortnox/resources/tax_reduction.rb
|
159
|
+
- lib/fortnox/resources/terms_of_delivery.rb
|
160
|
+
- lib/fortnox/resources/terms_of_payment.rb
|
161
|
+
- lib/fortnox/resources/unit.rb
|
162
|
+
- lib/fortnox/resources/voucher.rb
|
163
|
+
- lib/fortnox/resources/voucher_file_connection.rb
|
164
|
+
- lib/fortnox/resources/voucher_series.rb
|
165
|
+
- lib/fortnox/resources/way_of_delivery.rb
|
108
166
|
- lib/fortnox/version.rb
|
109
167
|
homepage: https://github.com/mbirman/fortnox
|
110
168
|
licenses:
|
@@ -116,9 +174,9 @@ require_paths:
|
|
116
174
|
- lib
|
117
175
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
176
|
requirements:
|
119
|
-
- - "
|
177
|
+
- - "~>"
|
120
178
|
- !ruby/object:Gem::Version
|
121
|
-
version: '0'
|
179
|
+
version: '2.0'
|
122
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
181
|
requirements:
|
124
182
|
- - ">="
|