economic-rest 0.5.10 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec06c8760ea6c2c97777086789faf1cc3a9c4c16f8c66a968c8cd4ecf996bd95
4
- data.tar.gz: c04eb4ba040c5e701dd0e239b11ece5d24591539cfa77e7207bf9d7d4093193a
3
+ metadata.gz: 278962b344fb0863870814da49a72d359c3db946e2a391e4a7cc8e02a0af4663
4
+ data.tar.gz: 3bdd8ebd9455c297fd2a8f426c7d39aa1b7906f584de8055e32be3439ef538ef
5
5
  SHA512:
6
- metadata.gz: feb3b14f3646417e9cb8cdfdf529294d2fddfb612f46522f1c139a7576435d2e0866464bd291957652bbba6535124437f7316475c446617d69fb5ac1f26766b4
7
- data.tar.gz: 86cb60fc957737e4acf489240548d6b24634ab71e3d8fd3d2464a02ab939b62c5a907ea232a04a6e9e893ae495ac53cf58952ce6c10fbad4af79f027c66a57ad
6
+ metadata.gz: 13b95c8dae49a0f77c9aead2a101366a60f5c6bd388996b45a6caa8ff715f922ba5fde9c259fd2a7f3579d6ec165f0e772d4430884d58cdd6a999a1a4d37cfe2
7
+ data.tar.gz: 29c4391f5aa1d187753a8297a9455e43860e94f5b91860076a7fb8e4226b1f8e980a6deacf94114eb14ff5df83ccc2a87213ee7f32f63e6fb64e512a7aebe763
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- economic-rest (0.5.10)
4
+ economic-rest (0.6.0)
5
5
  activesupport
6
6
  rest-client
7
7
  savon
@@ -9,12 +9,12 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.0.1)
12
+ activesupport (6.1.3.1)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- zeitwerk (~> 2.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
18
  addressable (2.5.2)
19
19
  public_suffix (>= 2.0.2, < 4.0)
20
20
  akami (1.3.1)
@@ -22,8 +22,8 @@ GEM
22
22
  nokogiri
23
23
  ast (2.4.0)
24
24
  awesome_print (1.8.0)
25
- builder (3.2.3)
26
- concurrent-ruby (1.1.5)
25
+ builder (3.2.4)
26
+ concurrent-ruby (1.1.8)
27
27
  coveralls (0.8.23)
28
28
  json (>= 1.8, < 3)
29
29
  simplecov (~> 0.16.1)
@@ -42,10 +42,10 @@ GEM
42
42
  http-accept (1.7.0)
43
43
  http-cookie (1.0.3)
44
44
  domain_name (~> 0.5)
45
- httpi (2.4.4)
45
+ httpi (2.4.5)
46
46
  rack
47
47
  socksify
48
- i18n (1.7.0)
48
+ i18n (1.8.10)
49
49
  concurrent-ruby (~> 1.0)
50
50
  jaro_winkler (1.5.3)
51
51
  json (2.1.0)
@@ -54,22 +54,24 @@ GEM
54
54
  rake (>= 0.9.2.2)
55
55
  metaclass (0.0.4)
56
56
  method_source (0.9.2)
57
- mime-types (3.3)
57
+ mime-types (3.3.1)
58
58
  mime-types-data (~> 3.2015)
59
- mime-types-data (3.2019.1009)
60
- mini_portile2 (2.4.0)
59
+ mime-types-data (3.2021.0225)
60
+ mini_portile2 (2.5.0)
61
61
  minitest (5.11.3)
62
62
  mocha (1.9.0)
63
63
  metaclass (~> 0.0.1)
64
64
  netrc (0.11.0)
65
- nokogiri (1.10.5)
66
- mini_portile2 (~> 2.4.0)
65
+ nokogiri (1.11.3)
66
+ mini_portile2 (~> 2.5.0)
67
+ racc (~> 1.4)
67
68
  nori (2.6.0)
68
69
  parallel (1.17.0)
69
70
  parser (2.6.4.1)
70
71
  ast (~> 2.4.0)
71
72
  public_suffix (3.0.3)
72
- rack (2.0.7)
73
+ racc (1.5.2)
74
+ rack (2.2.3)
73
75
  rainbow (3.0.0)
74
76
  rake (10.5.0)
75
77
  rest-client (2.1.0)
@@ -88,7 +90,7 @@ GEM
88
90
  rubocop (>= 0.71.0)
89
91
  ruby-progressbar (1.10.1)
90
92
  safe_yaml (1.0.4)
91
- savon (2.12.0)
93
+ savon (2.12.1)
92
94
  akami (~> 1.2)
93
95
  builder (>= 2.1.2)
94
96
  gyoku (~> 1.2)
@@ -108,22 +110,22 @@ GEM
108
110
  term-ansicolor (1.7.1)
109
111
  tins (~> 1.0)
110
112
  thor (0.20.3)
111
- thread_safe (0.3.6)
112
113
  tins (1.22.1)
113
- tzinfo (1.2.5)
114
- thread_safe (~> 0.1)
114
+ tzinfo (2.0.4)
115
+ concurrent-ruby (~> 1.0)
115
116
  unf (0.1.4)
116
117
  unf_ext
117
- unf_ext (0.0.7.6)
118
+ unf_ext (0.0.7.7)
118
119
  unicode-display_width (1.6.0)
119
- wasabi (3.5.0)
120
+ wasabi (3.6.1)
121
+ addressable
120
122
  httpi (~> 2.0)
121
123
  nokogiri (>= 1.4.2)
122
124
  webmock (3.5.1)
123
125
  addressable (>= 2.3.6)
124
126
  crack (>= 0.3.2)
125
127
  hashdiff
126
- zeitwerk (2.2.2)
128
+ zeitwerk (2.4.2)
127
129
 
128
130
  PLATFORMS
129
131
  ruby
data/README.md CHANGED
@@ -65,7 +65,7 @@ copy pasta from https://restdocs.e-conomic.com/#specifying-operator-affinity
65
65
 
66
66
  ## Development
67
67
 
68
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` or 'bundle exec m' to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
68
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec m` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
69
69
 
70
70
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
71
71
 
data/lib/economic/base.rb CHANGED
@@ -75,7 +75,7 @@ module Economic
75
75
  relation_fields = relation_hash[:fields]
76
76
  begin
77
77
  arr = public_send(relation_name).map { |relation| relation.to_h(only_fields: relation_fields) }
78
- return_hash[relation_name] = arr
78
+ return_hash[relation_name] = arr unless arr.empty?
79
79
  rescue NoMethodError
80
80
  end
81
81
  else
@@ -76,7 +76,6 @@ module Economic
76
76
  end
77
77
 
78
78
  def send_request(method:, url:, payload: "", &block)
79
- url = URI.escape(url)
80
79
  if payload.strip.empty?
81
80
  RestClient::Request.execute(method: method, url: url, headers: headers, &block)
82
81
  else
@@ -29,7 +29,7 @@ module Economic
29
29
  relation :customerGroup, fields: [:customerGroupNumber]
30
30
  # field :defaultDeliveryLocation
31
31
  # field :invoices
32
- # field :layout
32
+ relation :layout, fields: [:layoutNumber]
33
33
  relation :paymentTerms, fields: [:paymentTermsNumber]
34
34
  # field :salesPerson
35
35
  # field :templates
@@ -0,0 +1,6 @@
1
+ module Economic
2
+ class Department < Base
3
+ field :name
4
+ field :departmentNumber, id: true
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ module Economic
2
+ class DepartmentRepo < Economic::BaseRepo
3
+ end
4
+ end
@@ -0,0 +1,11 @@
1
+ module Economic
2
+ class DepartmentalDistribution < Base
3
+ field :name
4
+ field :departmentalDistributionNumber, id: true
5
+ field :distributionType
6
+
7
+ relation :customer, fields: []
8
+ relation :distributions, fields: [], multiple: true
9
+ # relation :subCollections, fields: [?]
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ module Economic
2
+ class DepartmentalDistributionRepo < Economic::BaseRepo
3
+ class << self
4
+ def all(distribution: nil)
5
+ return super(url: endpoint_url(distribution)) unless distribution.nil?
6
+
7
+ super(url: endpoint_url(distribution))
8
+ end
9
+
10
+ def find(id, distribution:)
11
+ super(id, url: endpoint_url(distribution))
12
+ end
13
+
14
+ private
15
+
16
+ def endpoint_url(distribution)
17
+ return super() if distribution.nil?
18
+ return super() + "/departments" if distribution == :single_department
19
+
20
+ super() + "/distributions"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ module Economic
2
+ class Distribution < Base
3
+ field :percentage
4
+
5
+ relation :department, fields: [:departmentNumber]
6
+ end
7
+ end
@@ -24,7 +24,7 @@ module Economic
24
24
  relation :paymentTerms, fields: [:paymentTermsNumber]
25
25
  relation :pdf, fields: [:download]
26
26
  # relation :project, fields: []
27
- relation :recipient, fields: [:name, :ean]
27
+ relation :recipient, fields: []
28
28
  relation :references, fields: [:other]
29
29
  relation :lines, fields: [:lineNumber, :description, :sortKey, :quantity, :unitNetPrice, :discountPercentage, :unitCostPrice, :marginInBaseCurrency, :marginPercentage, :totalNetAmount], multiple: true
30
30
 
@@ -3,7 +3,7 @@ module Economic
3
3
  class BookedRepo < Economic::Invoices::Repo
4
4
  class << self
5
5
  def send(invoice, book_with_number: nil)
6
- response = send_request(method: :post, url: URI.escape(endpoint_url), payload: payload(invoice, book_with_number: book_with_number))
6
+ response = send_request(method: :post, url: endpoint_url, payload: payload(invoice, book_with_number: book_with_number))
7
7
 
8
8
  entry_hash = JSON.parse(response.body)
9
9
 
@@ -1,7 +1,7 @@
1
1
  module Economic
2
2
  class JournalVoucherRepo < Economic::BaseRepo
3
3
  def self.save(voucher)
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)
4
+ response = send_request(method: :post, url: "#{Economic::JournalRepo.endpoint_url}/#{voucher.journal.journalNumber}/vouchers", payload: voucher.to_h.to_json)
5
5
 
6
6
  Voucher.new(JSON.parse(response.body).first)
7
7
  end
data/lib/economic/line.rb CHANGED
@@ -11,9 +11,10 @@ module Economic
11
11
  field :marginPercentage
12
12
  field :totalNetAmount
13
13
 
14
- relation :product, fields: [:productNumber]
15
- relation :unit, fields: [:unitNumber, :name]
16
- relation :delivery, fields: [:address, :zip, :city, :country, :deliveryDate]
14
+ relation :product, fields: []
15
+ relation :unit, fields: []
16
+ relation :delivery, fields: []
17
+ relation :departmentalDistribution, fields: []
17
18
 
18
19
  def self.build_from_soap_api(data)
19
20
  # This is not instantiated with the hash, as lines are never pulled out by themselves, but always as part of
@@ -6,7 +6,7 @@ module Economic
6
6
 
7
7
  id = Economic::BaseRepo.id_to_url_formatted_id(id)
8
8
  end_point = [superclass.endpoint_url, id, "pricing", "currency-specific-sales-prices"].join("/")
9
- response = send_request(method: :get, url: URI.escape(end_point))
9
+ response = send_request(method: :get, url: end_point)
10
10
  entry_hash = JSON.parse(response.body)
11
11
  pricings = []
12
12
 
@@ -5,7 +5,7 @@ module Economic
5
5
  id ||= product_group_or_product_group_number
6
6
 
7
7
  end_point = [ProductGroupRepo.endpoint_url, id, "products"].join("/")
8
- response = send_request(method: :get, url: URI.escape(end_point))
8
+ response = send_request(method: :get, url: end_point)
9
9
  entry_hash = JSON.parse(response.body)
10
10
  products = []
11
11
 
data/lib/economic/rest.rb CHANGED
@@ -90,6 +90,12 @@ require "economic/remittance_advice"
90
90
  require "economic/payment_type"
91
91
  require "economic/payment_type_repo"
92
92
 
93
+ require "economic/department"
94
+ require "economic/department_repo"
95
+ require "economic/departmental_distribution"
96
+ require "economic/distribution"
97
+ require "economic/departmental_distribution_repo"
98
+
93
99
  require "economic/account"
94
100
 
95
101
  module Economic
@@ -1,5 +1,5 @@
1
1
  module Economic
2
2
  module Rest
3
- VERSION = "0.5.10".freeze
3
+ VERSION = "0.6.0".freeze
4
4
  end
5
5
  end
@@ -4,7 +4,7 @@ module Economic
4
4
 
5
5
  class << self
6
6
  def self
7
- response = send_request(method: :get, url: URI.escape(Economic::SelfRepo.endpoint_url))
7
+ response = send_request(method: :get, url: Economic::SelfRepo.endpoint_url)
8
8
  entry_hash = JSON.parse(response.body)
9
9
  model.new(entry_hash)
10
10
  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.5.10
4
+ version: 0.6.0
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-12-03 00:00:00.000000000 Z
11
+ date: 2021-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -241,6 +241,11 @@ files:
241
241
  - lib/economic/customer_group_repo.rb
242
242
  - lib/economic/customer_repo.rb
243
243
  - lib/economic/delivery.rb
244
+ - lib/economic/department.rb
245
+ - lib/economic/department_repo.rb
246
+ - lib/economic/departmental_distribution.rb
247
+ - lib/economic/departmental_distribution_repo.rb
248
+ - lib/economic/distribution.rb
244
249
  - lib/economic/inventory.rb
245
250
  - lib/economic/invoice.rb
246
251
  - lib/economic/invoices/booked_repo.rb
@@ -319,7 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
324
  - !ruby/object:Gem::Version
320
325
  version: '0'
321
326
  requirements: []
322
- rubygems_version: 3.0.3
327
+ rubygems_version: 3.1.2
323
328
  signing_key:
324
329
  specification_version: 4
325
330
  summary: Ruby wrapper for the e-conomic REST API, that aims at making working with