economic-rest 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +6 -4
- data/Rakefile +5 -5
- data/economic-rest.gemspec +19 -19
- data/lib/economic/base.rb +17 -22
- data/lib/economic/base_repo.rb +54 -51
- data/lib/economic/company.rb +16 -0
- data/lib/economic/journal_voucher_repo.rb +2 -8
- data/lib/economic/pricing_repo.rb +3 -3
- data/lib/economic/product_repo.rb +3 -3
- data/lib/economic/rest.rb +58 -54
- data/lib/economic/rest/version.rb +1 -1
- data/lib/economic/self.rb +17 -0
- data/lib/economic/self_repo.rb +9 -0
- data/lib/economic/session.rb +2 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 908c6d73f7538cacc8a9dc4803dddbd62372a93c338c39deba8e5b50d2b6cf2c
|
4
|
+
data.tar.gz: 458eff20fc6976d941553ba149b9ce7124231c8bd46c9bb8377e5b586b4614e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f437c2d4fbf955927245cf941b66acc8a665680e2e5a054b29047236637b19bbcce7776f7c20819b0c8656fb67117c1aa4bf6fe79ae489e52bba8ec2c765ee5
|
7
|
+
data.tar.gz: e125cd5b5920aa6858f49dda59b1f6595a03beb015109844a6cc233f7dd206f33c204dd260d01ea01a82aac9ceb71fcb762c2ec49907fcda796c09ed27b04189
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
git_source(:bitbucket) { |_repo_name|
|
3
|
+
git_source(:bitbucket) { |_repo_name| "https://bitbucket.org/traels/economic-rest" }
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in economic-rest.gemspec
|
6
6
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
economic-rest (0.3.
|
4
|
+
economic-rest (0.3.5)
|
5
5
|
rest-client
|
6
6
|
|
7
7
|
GEM
|
@@ -15,6 +15,7 @@ GEM
|
|
15
15
|
domain_name (0.5.20190701)
|
16
16
|
unf (>= 0.0.5, < 1.0.0)
|
17
17
|
hashdiff (0.3.8)
|
18
|
+
http-accept (1.7.0)
|
18
19
|
http-cookie (1.0.3)
|
19
20
|
domain_name (~> 0.5)
|
20
21
|
json (2.1.0)
|
@@ -22,14 +23,15 @@ GEM
|
|
22
23
|
method_source (>= 0.6.7)
|
23
24
|
rake (>= 0.9.2.2)
|
24
25
|
method_source (0.9.2)
|
25
|
-
mime-types (3.
|
26
|
+
mime-types (3.3)
|
26
27
|
mime-types-data (~> 3.2015)
|
27
|
-
mime-types-data (3.2019.
|
28
|
+
mime-types-data (3.2019.0904)
|
28
29
|
minitest (5.11.3)
|
29
30
|
netrc (0.11.0)
|
30
31
|
public_suffix (3.0.3)
|
31
32
|
rake (10.5.0)
|
32
|
-
rest-client (2.0
|
33
|
+
rest-client (2.1.0)
|
34
|
+
http-accept (>= 1.7.0, < 2.0)
|
33
35
|
http-cookie (>= 1.0.2, < 2.0)
|
34
36
|
mime-types (>= 1.16, < 4.0)
|
35
37
|
netrc (~> 0.8)
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
4
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
7
|
-
t.test_files = FileList[
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
8
|
end
|
9
9
|
|
10
10
|
task default: :test
|
data/economic-rest.gemspec
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
lib = File.expand_path(
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
3
|
+
require "economic/rest/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = "economic-rest"
|
7
|
+
spec.version = Economic::Rest::VERSION
|
8
|
+
spec.authors = ["Peter Klogborg"]
|
9
|
+
spec.email = ["klogborg@traels.it"]
|
10
10
|
|
11
|
-
spec.summary
|
11
|
+
spec.summary = 'Ruby wrapper for the e-conomic REST API, that aims at making working with the API bearable.
|
12
12
|
E-conomic is a web-based accounting system. For their marketing speak, see http://www.e-conomic.co.uk/about/. More details about their API at http://www.e-conomic.co.uk/integration/integration-partner/.
|
13
13
|
The documentation can be found at https://restdocs.e-conomic.com'
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
14
|
+
spec.homepage = "https://bitbucket.org/traels/economic-rest"
|
15
|
+
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
18
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
19
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
21
|
end
|
22
|
-
spec.bindir
|
23
|
-
spec.executables
|
24
|
-
spec.require_paths = [
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
27
|
+
spec.add_development_dependency "m"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "simplecov"
|
31
|
+
spec.add_development_dependency "webmock", "~> 3.5"
|
32
32
|
|
33
|
-
spec.add_dependency
|
33
|
+
spec.add_dependency "rest-client"
|
34
34
|
end
|
data/lib/economic/base.rb
CHANGED
@@ -21,7 +21,7 @@ module Economic
|
|
21
21
|
attr_accessor economic_cased_attibute_name
|
22
22
|
alias_method snake_case(economic_cased_attibute_name), economic_cased_attibute_name
|
23
23
|
alias_method "#{snake_case(economic_cased_attibute_name)}=", "#{economic_cased_attibute_name}="
|
24
|
-
alias_method
|
24
|
+
alias_method "id_key", economic_cased_attibute_name if id
|
25
25
|
add_attribute economic_cased_attibute_name
|
26
26
|
end
|
27
27
|
|
@@ -34,18 +34,15 @@ module Economic
|
|
34
34
|
|
35
35
|
def values_based_on_hash(hash)
|
36
36
|
@internal_hash = hash || {}
|
37
|
-
|
38
37
|
self.class.attributes.each do |field_name|
|
39
38
|
public_send("#{field_name}=", @internal_hash[field_name])
|
40
39
|
end
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
related_model = model_class(name).new(@internal_hash[name])
|
41
|
+
self.class.relations&.each do |relation_hash|
|
42
|
+
name = relation_hash[:name]
|
43
|
+
related_model = model_class(name).new(@internal_hash[name])
|
46
44
|
|
47
|
-
|
48
|
-
end
|
45
|
+
instance_variable_set("@#{name}", related_model)
|
49
46
|
end
|
50
47
|
end
|
51
48
|
|
@@ -58,15 +55,13 @@ module Economic
|
|
58
55
|
return_hash[field_name] = public_send(field_name) if public_send(field_name)
|
59
56
|
end
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
relation_fields = relation_hash[:fields]
|
58
|
+
self.class.relations&.each do |relation_hash|
|
59
|
+
relation_name = relation_hash[:name]
|
60
|
+
relation_fields = relation_hash[:fields]
|
65
61
|
|
66
|
-
|
62
|
+
relation_data = public_send(relation_name).to_h(only_fields: relation_fields)
|
67
63
|
|
68
|
-
|
69
|
-
end
|
64
|
+
return_hash[relation_name] = relation_data unless relation_data.empty?
|
70
65
|
end
|
71
66
|
return_hash
|
72
67
|
end
|
@@ -79,15 +74,15 @@ module Economic
|
|
79
74
|
end
|
80
75
|
|
81
76
|
def self.snake_case(camel_cased)
|
82
|
-
camel_cased.to_s.gsub(/::/,
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
77
|
+
camel_cased.to_s.gsub(/::/, "/")
|
78
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
79
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
80
|
+
.tr("-", "_")
|
81
|
+
.downcase
|
87
82
|
end
|
88
83
|
|
89
84
|
def self.low_camel_case(snake_cased)
|
90
|
-
camel = snake_cased.split(
|
85
|
+
camel = snake_cased.split("_").collect(&:capitalize).join
|
91
86
|
camel[0, 1].downcase + camel[1..-1]
|
92
87
|
end
|
93
88
|
|
@@ -96,7 +91,7 @@ module Economic
|
|
96
91
|
end
|
97
92
|
|
98
93
|
def model_class(name)
|
99
|
-
Object.const_get(
|
94
|
+
Object.const_get("Economic::" + name.slice(0, 1).capitalize + name.slice(1..-1))
|
100
95
|
end
|
101
96
|
end
|
102
97
|
end
|
data/lib/economic/base_repo.rb
CHANGED
@@ -1,53 +1,37 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "rest-client"
|
2
|
+
require "json"
|
3
|
+
require "economic/session"
|
4
4
|
|
5
5
|
module Economic
|
6
6
|
class BaseRepo
|
7
|
-
URL =
|
7
|
+
URL = "https://restapi.e-conomic.com/".freeze
|
8
8
|
|
9
9
|
class << self
|
10
|
-
def headers
|
11
|
-
{ 'X-AppSecretToken': Session.app_secret_token, 'X-AgreementGrantToken': Session.agreement_grant_token, 'Content-Type': 'application/json' }
|
12
|
-
end
|
13
|
-
|
14
|
-
def fetch(pageindex: 0, filter_text: '')
|
15
|
-
url = endpoint_url
|
16
|
-
url << "?skippages=#{pageindex}&pagesize=1000"
|
17
|
-
url << "&filter=#{filter_text}" unless filter_text == ''
|
18
|
-
|
19
|
-
response = RestClient.get(URI.escape(url), headers)
|
20
|
-
test_response(response)
|
21
|
-
end
|
22
|
-
|
23
10
|
def save(model)
|
24
11
|
post_or_put = model.id_key.nil? ? :post : :put
|
25
12
|
|
26
|
-
|
27
|
-
|
28
|
-
test_response(response)
|
13
|
+
send_request(method: post_or_put, url: URI.escape(endpoint_url + "/" + model.id_key.to_s), payload: model.to_h.to_json)
|
29
14
|
end
|
30
15
|
|
31
16
|
def send(model)
|
32
|
-
|
33
|
-
test_response(response)
|
17
|
+
send_request(method: :post, url: URI.escape(endpoint_url), payload: model.to_h.to_json)
|
34
18
|
end
|
35
19
|
|
36
|
-
def all(filter_text:
|
20
|
+
def all(filter_text: "")
|
37
21
|
pagination = {}
|
38
22
|
pageindex = 0
|
39
23
|
entries = []
|
40
24
|
|
41
25
|
# Loop until last page, last page does not have a 'nextPage'
|
42
|
-
while pagination[
|
26
|
+
while pagination["nextPage"] || pageindex.zero?
|
43
27
|
response = fetch(pageindex: pageindex, filter_text: filter_text)
|
44
28
|
|
45
29
|
hash = JSON.parse(response.body)
|
46
|
-
hash[
|
30
|
+
hash["collection"].each do |entry_hash|
|
47
31
|
entries.push model.new(entry_hash)
|
48
32
|
end
|
49
33
|
|
50
|
-
pagination = hash[
|
34
|
+
pagination = hash["pagination"]
|
51
35
|
pageindex += 1
|
52
36
|
end
|
53
37
|
entries
|
@@ -61,52 +45,71 @@ module Economic
|
|
61
45
|
filter("lastUpdated$gt:#{to_iso8601z(date)}")
|
62
46
|
end
|
63
47
|
|
64
|
-
def to_iso8601z(date)
|
65
|
-
date = date.iso8601
|
66
|
-
date = date[0...-5].tr('+', 'Z') if date.include?('+')
|
67
|
-
date
|
68
|
-
end
|
69
|
-
|
70
48
|
def find(id)
|
71
|
-
response =
|
49
|
+
response = send_request(method: :get, url: endpoint_url + "/" + id.to_s)
|
72
50
|
entry_hash = JSON.parse(response.body)
|
73
51
|
model.new(entry_hash)
|
74
52
|
end
|
75
53
|
|
54
|
+
def endpoint_url
|
55
|
+
URL + endpoint_name
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
76
60
|
def model
|
77
|
-
scopes = name.split(
|
61
|
+
scopes = name.split("::")
|
78
62
|
scopes[1] = scopes[1][0...-1] if scopes.count == 3
|
79
|
-
Object.const_get("#{scopes[0]}::#{scopes[1].sub(
|
63
|
+
Object.const_get("#{scopes[0]}::#{scopes[1].sub("Repo", "")}")
|
80
64
|
end
|
81
65
|
|
82
66
|
def endpoint_name
|
83
|
-
end_p = name.sub(
|
84
|
-
if end_p.include?(
|
85
|
-
end_p = end_p.gsub(
|
86
|
-
end_p = end_p.gsub(
|
67
|
+
end_p = name.sub("Economic::", "")
|
68
|
+
if end_p.include?("::")
|
69
|
+
end_p = end_p.gsub("Repo", "")
|
70
|
+
end_p = end_p.gsub("::", "/")
|
87
71
|
else
|
88
|
-
end_p = end_p.gsub(
|
72
|
+
end_p = end_p.gsub("Repo", "s")
|
89
73
|
end
|
90
|
-
end_p = end_p.gsub(
|
74
|
+
end_p = end_p.gsub("Journals", "Journals-Experimental")
|
75
|
+
end_p = end_p.gsub("Selfs", "Self")
|
91
76
|
kebab(end_p)
|
92
77
|
end
|
93
78
|
|
94
|
-
def
|
95
|
-
|
79
|
+
def to_iso8601z(date)
|
80
|
+
date = date.iso8601
|
81
|
+
date = date[0...-5].tr("+", "Z") if date.include?("+")
|
82
|
+
date
|
83
|
+
end
|
84
|
+
|
85
|
+
def send_request(method:, url:, payload: "", &block)
|
86
|
+
if payload.strip.empty?
|
87
|
+
RestClient::Request.execute(method: method, url: url, headers: headers, &block)
|
88
|
+
else
|
89
|
+
RestClient::Request.execute(method: method, url: url, payload: payload, headers: headers, &block)
|
90
|
+
end
|
91
|
+
rescue => e
|
92
|
+
raise e.to_s + ": " + e.response.to_s
|
93
|
+
end
|
94
|
+
|
95
|
+
def headers
|
96
|
+
{'X-AppSecretToken': Session.app_secret_token, 'X-AgreementGrantToken': Session.agreement_grant_token, 'Content-Type': "application/json"}
|
96
97
|
end
|
97
98
|
|
98
|
-
def
|
99
|
-
|
99
|
+
def fetch(pageindex: 0, filter_text: "")
|
100
|
+
url = endpoint_url
|
101
|
+
url << "?skippages=#{pageindex}&pagesize=1000"
|
102
|
+
url << "&filter=#{filter_text}" unless filter_text == ""
|
100
103
|
|
101
|
-
|
104
|
+
send_request(method: :get, url: URI.escape(url))
|
102
105
|
end
|
103
106
|
|
104
107
|
def kebab(string)
|
105
|
-
string.gsub(/::/,
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
108
|
+
string.gsub(/::/, "/")
|
109
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
110
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
111
|
+
.tr("_", "-")
|
112
|
+
.downcase
|
110
113
|
end
|
111
114
|
end
|
112
115
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Economic
|
2
|
+
class Company < Base
|
3
|
+
field :addressLine1
|
4
|
+
field :addressLine2
|
5
|
+
field :attention
|
6
|
+
field :city
|
7
|
+
field :companyIdentificationNumber
|
8
|
+
field :country
|
9
|
+
field :email
|
10
|
+
field :name
|
11
|
+
field :phoneNumber
|
12
|
+
field :vatNumber
|
13
|
+
field :website
|
14
|
+
field :zip
|
15
|
+
end
|
16
|
+
end
|
@@ -1,19 +1,13 @@
|
|
1
1
|
module Economic
|
2
2
|
class JournalVoucherRepo < Economic::BaseRepo
|
3
3
|
def self.save(voucher)
|
4
|
-
response =
|
5
|
-
URI.escape(Economic::JournalRepo.endpoint_url + '/' + voucher.journal.journalNumber.to_s + '/vouchers'),
|
6
|
-
voucher.to_h.to_json,
|
7
|
-
headers
|
8
|
-
)
|
9
|
-
|
10
|
-
test_response(response)
|
4
|
+
response = send_request(method: :post, url: URI.escape(Economic::JournalRepo.endpoint_url + "/" + voucher.journal.journalNumber.to_s + "/vouchers"), payload: voucher.to_h.to_json)
|
11
5
|
|
12
6
|
Voucher.new(JSON.parse(response.body).first)
|
13
7
|
end
|
14
8
|
|
15
9
|
def self.endpoint_name
|
16
|
-
raise StandardError,
|
10
|
+
raise StandardError, "only save is available on this repository"
|
17
11
|
end
|
18
12
|
end
|
19
13
|
end
|
@@ -4,12 +4,12 @@ module Economic
|
|
4
4
|
id = product_or_product_number.product_number if product_or_product_number.respond_to? :product_number
|
5
5
|
id ||= product_or_product_number
|
6
6
|
|
7
|
-
end_point = [superclass.endpoint_url, id,
|
8
|
-
response =
|
7
|
+
end_point = [superclass.endpoint_url, id, "pricing", "currency-specific-sales-prices"].join("/")
|
8
|
+
response = send_request(method: :get, url: URI.escape(end_point))
|
9
9
|
entry_hash = JSON.parse(response.body)
|
10
10
|
pricings = []
|
11
11
|
|
12
|
-
entry_hash[
|
12
|
+
entry_hash["collection"].each do |pricing|
|
13
13
|
pricings.push Pricing.new(pricing)
|
14
14
|
end
|
15
15
|
pricings
|
@@ -4,12 +4,12 @@ module Economic
|
|
4
4
|
id = product_group_or_product_group_number.product_group_number if product_group_or_product_group_number.respond_to? :product_group_number
|
5
5
|
id ||= product_group_or_product_group_number
|
6
6
|
|
7
|
-
end_point = [ProductGroupRepo.endpoint_url, id,
|
8
|
-
response =
|
7
|
+
end_point = [ProductGroupRepo.endpoint_url, id, "products"].join("/")
|
8
|
+
response = send_request(method: :get, url: URI.escape(end_point))
|
9
9
|
entry_hash = JSON.parse(response.body)
|
10
10
|
products = []
|
11
11
|
|
12
|
-
entry_hash[
|
12
|
+
entry_hash["collection"].each do |product|
|
13
13
|
products.push Product.new(product)
|
14
14
|
end
|
15
15
|
products
|
data/lib/economic/rest.rb
CHANGED
@@ -1,61 +1,65 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
require
|
5
|
-
require
|
6
|
-
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
37
|
-
require
|
38
|
-
require
|
39
|
-
require
|
40
|
-
|
41
|
-
require
|
42
|
-
require
|
43
|
-
require
|
44
|
-
require
|
45
|
-
|
46
|
-
require
|
47
|
-
require
|
48
|
-
|
49
|
-
require
|
50
|
-
require
|
1
|
+
require "economic/rest/version"
|
2
|
+
require "rest-client"
|
3
|
+
|
4
|
+
require "economic/base_repo"
|
5
|
+
require "economic/base"
|
6
|
+
|
7
|
+
require "economic/currency"
|
8
|
+
require "economic/vat_zone"
|
9
|
+
require "economic/vat_zone_repo"
|
10
|
+
require "economic/vat_type"
|
11
|
+
require "economic/vat_type_repo"
|
12
|
+
require "economic/inventory"
|
13
|
+
require "economic/customer_group"
|
14
|
+
require "economic/product_group"
|
15
|
+
|
16
|
+
require "economic/pricing"
|
17
|
+
require "economic/delivery"
|
18
|
+
require "economic/layout"
|
19
|
+
require "economic/layout_repo"
|
20
|
+
require "economic/notes"
|
21
|
+
require "economic/payment_terms"
|
22
|
+
require "economic/pdf"
|
23
|
+
require "economic/project"
|
24
|
+
require "economic/recipient"
|
25
|
+
require "economic/references"
|
26
|
+
|
27
|
+
require "economic/customer_repo"
|
28
|
+
require "economic/customer"
|
29
|
+
require "economic/customer_group_repo"
|
30
|
+
require "economic/product_repo"
|
31
|
+
require "economic/product"
|
32
|
+
require "economic/pricing_repo"
|
33
|
+
|
34
|
+
require "economic/orders/repo"
|
35
|
+
require "economic/order"
|
36
|
+
require "economic/orders/archived_repo"
|
37
|
+
require "economic/orders/drafts_repo"
|
38
|
+
require "economic/orders/sent_repo"
|
39
|
+
require "economic/product_group_repo"
|
40
|
+
|
41
|
+
require "economic/journal_repo"
|
42
|
+
require "economic/journal"
|
43
|
+
require "economic/journal_voucher_repo"
|
44
|
+
require "economic/voucher"
|
45
|
+
|
46
|
+
require "economic/accounting_year"
|
47
|
+
require "economic/accounting_year_repo"
|
48
|
+
|
49
|
+
require "economic/unit"
|
50
|
+
require "economic/unit_repo"
|
51
|
+
|
52
|
+
require "economic/company"
|
53
|
+
require "economic/self"
|
54
|
+
require "economic/self_repo"
|
51
55
|
|
52
56
|
module Economic
|
53
57
|
class Demo
|
54
58
|
def self.hello
|
55
|
-
RestClient.get(
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
RestClient.get("https://restapi.e-conomic.com/",
|
60
|
+
'X-AppSecretToken': "Demo",
|
61
|
+
'X-AgreementGrantToken': "Demo",
|
62
|
+
'Content-Type': "application/json")
|
59
63
|
end
|
60
64
|
end
|
61
65
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Economic
|
2
|
+
class Self < Base
|
3
|
+
field :agreementNumber
|
4
|
+
field :canSendElectronicInvoice
|
5
|
+
field :companyAffiliation
|
6
|
+
field :modules
|
7
|
+
field :signupDate
|
8
|
+
field :userName
|
9
|
+
|
10
|
+
# relation :agreementType object The type of agreement this is. It can either be denmark, sweden or norway
|
11
|
+
# relation :application object The company’s bank settings.
|
12
|
+
# relation :bankInformation object The company’s bank settings.
|
13
|
+
relation :company, fields: []
|
14
|
+
# relation :settings object Other settings.
|
15
|
+
# relation :user object The currently logged in user.
|
16
|
+
end
|
17
|
+
end
|
data/lib/economic/session.rb
CHANGED
@@ -8,13 +8,13 @@ module Economic
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.app_secret_token
|
11
|
-
raise ArgumentError,
|
11
|
+
raise ArgumentError, "Authentication tokens not set, Call Session.authentication" if @private_app_id.nil?
|
12
12
|
|
13
13
|
@private_app_id
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.agreement_grant_token
|
17
|
-
raise ArgumentError,
|
17
|
+
raise ArgumentError, "Authentication tokens not set, Call Session.authentication" if @access_id.nil?
|
18
18
|
|
19
19
|
@access_id
|
20
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: economic-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Klogborg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/economic/accounting_year_repo.rb
|
130
130
|
- lib/economic/base.rb
|
131
131
|
- lib/economic/base_repo.rb
|
132
|
+
- lib/economic/company.rb
|
132
133
|
- lib/economic/currency.rb
|
133
134
|
- lib/economic/customer.rb
|
134
135
|
- lib/economic/customer_group.rb
|
@@ -160,6 +161,8 @@ files:
|
|
160
161
|
- lib/economic/references.rb
|
161
162
|
- lib/economic/rest.rb
|
162
163
|
- lib/economic/rest/version.rb
|
164
|
+
- lib/economic/self.rb
|
165
|
+
- lib/economic/self_repo.rb
|
163
166
|
- lib/economic/session.rb
|
164
167
|
- lib/economic/unit.rb
|
165
168
|
- lib/economic/unit_repo.rb
|
@@ -187,8 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
190
|
- !ruby/object:Gem::Version
|
188
191
|
version: '0'
|
189
192
|
requirements: []
|
190
|
-
|
191
|
-
rubygems_version: 2.7.6
|
193
|
+
rubygems_version: 3.0.3
|
192
194
|
signing_key:
|
193
195
|
specification_version: 4
|
194
196
|
summary: Ruby wrapper for the e-conomic REST API, that aims at making working with
|