elmas 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Changelog.md +4 -0
- data/lib/elmas/api.rb +1 -1
- data/lib/elmas/config.rb +9 -9
- data/lib/elmas/resource.rb +2 -5
- data/lib/elmas/resources/shared_sales_attributes.rb +2 -2
- data/lib/elmas/response.rb +3 -3
- data/lib/elmas/result_set.rb +7 -7
- data/lib/elmas/sanitizer.rb +6 -0
- data/lib/elmas/uri.rb +6 -6
- data/lib/elmas/utils.rb +1 -1
- data/lib/elmas/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dab67a65bc9196c76e1536d56b590dd6a2b921f
|
4
|
+
data.tar.gz: 973eee206fdd9512efc410d01b5f7fa5c7725b19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 607279e3a029d11bff668d3b45ec0ca65f80fc4d414f73abd74ac685120386356a2ea62b79cf27cbe205afa66a4d3f15444019b6680289fffd601e37c59e4441
|
7
|
+
data.tar.gz: 6e5e1a74905fbb2f774c001982abf04a8fd78b64267a38ae8000b7b62e92942d21767fde3600350b685c170f28d90cb73b427cfde1d443a6b4d5b506d2b69bfe
|
data/.travis.yml
CHANGED
data/Changelog.md
CHANGED
data/lib/elmas/api.rb
CHANGED
data/lib/elmas/config.rb
CHANGED
@@ -19,9 +19,9 @@ module Elmas
|
|
19
19
|
].freeze
|
20
20
|
|
21
21
|
# By default, don't set a user access token
|
22
|
-
DEFAULT_ACCESS_TOKEN = ""
|
22
|
+
DEFAULT_ACCESS_TOKEN = "".freeze
|
23
23
|
|
24
|
-
DEFAULT_REFRESH_TOKEN = ""
|
24
|
+
DEFAULT_REFRESH_TOKEN = "".freeze
|
25
25
|
|
26
26
|
# The adapter that will be used to connect if none is set
|
27
27
|
#
|
@@ -29,27 +29,27 @@ module Elmas
|
|
29
29
|
DEFAULT_ADAPTER = Faraday.default_adapter
|
30
30
|
|
31
31
|
# By default, client id should be set in .env
|
32
|
-
DEFAULT_CLIENT_ID = ""
|
32
|
+
DEFAULT_CLIENT_ID = "".freeze
|
33
33
|
|
34
34
|
# By default, client secret should be set in .env
|
35
|
-
DEFAULT_CLIENT_SECRET = ""
|
35
|
+
DEFAULT_CLIENT_SECRET = "".freeze
|
36
36
|
|
37
37
|
# By default, don't set any connection options
|
38
|
-
DEFAULT_CONNECTION_OPTIONS = {}
|
38
|
+
DEFAULT_CONNECTION_OPTIONS = {}.freeze
|
39
39
|
|
40
|
-
DEFAULT_BASE_URL = "https://start.exactonline.nl"
|
40
|
+
DEFAULT_BASE_URL = "https://start.exactonline.nl".freeze
|
41
41
|
|
42
42
|
# The endpoint that will be used to connect if none is set
|
43
43
|
DEFAULT_ENDPOINT = "api/v1".freeze
|
44
44
|
|
45
45
|
# the division code you want to connect with
|
46
|
-
DEFAULT_DIVISION = ""
|
46
|
+
DEFAULT_DIVISION = "".freeze
|
47
47
|
|
48
48
|
# The response format appended to the path and sent in the 'Accept' header if none is set
|
49
49
|
#
|
50
50
|
DEFAULT_FORMAT = :json
|
51
51
|
|
52
|
-
DEFAULT_REDIRECT_URI = "https://www.getpostman.com/oauth2/callback"
|
52
|
+
DEFAULT_REDIRECT_URI = "https://www.getpostman.com/oauth2/callback".freeze
|
53
53
|
|
54
54
|
# By default, don't set user agent
|
55
55
|
DEFAULT_USER_AGENT = nil
|
@@ -58,7 +58,7 @@ module Elmas
|
|
58
58
|
VALID_FORMATS = [:json].freeze
|
59
59
|
|
60
60
|
# @private
|
61
|
-
attr_accessor *
|
61
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
62
62
|
|
63
63
|
# When this module is extended, set all configuration options to their default values
|
64
64
|
def self.extended(base)
|
data/lib/elmas/resource.rb
CHANGED
@@ -63,11 +63,8 @@ module Elmas
|
|
63
63
|
def save
|
64
64
|
attributes_to_submit = sanitize
|
65
65
|
if valid?
|
66
|
-
|
67
|
-
|
68
|
-
else
|
69
|
-
return @response = Elmas.post(base_path, params: attributes_to_submit)
|
70
|
-
end
|
66
|
+
return @response = Elmas.post(base_path, params: attributes_to_submit) unless id?
|
67
|
+
return @response = Elmas.put(basic_identifier_uri, params: attributes_to_submit)
|
71
68
|
else
|
72
69
|
Elmas.error("Invalid Resource #{self.class.name}, attributes: #{@attributes.inspect}")
|
73
70
|
Elmas::Response.new(Faraday::Response.new(status: 400, body: "Invalid Request"))
|
@@ -5,12 +5,12 @@ module Elmas
|
|
5
5
|
:description, :document, :order_date, :ordered_by_contact_person,
|
6
6
|
:tax_schedule, :order_number, :payment_condition, :payment_reference,
|
7
7
|
:remarks, :your_ref
|
8
|
-
]
|
8
|
+
].freeze
|
9
9
|
|
10
10
|
SHARED_LINE_ATTRIBUTES = [
|
11
11
|
:discount, :quantity, :amount_FC, :description, :VAT_code, :cost_center,
|
12
12
|
:cost_unit, :VAT_percentage, :unit_code, :tax_schedule, :net_price, :notes,
|
13
13
|
:pricelist, :project
|
14
|
-
]
|
14
|
+
].freeze
|
15
15
|
end
|
16
16
|
end
|
data/lib/elmas/response.rb
CHANGED
@@ -49,15 +49,15 @@ module Elmas
|
|
49
49
|
|
50
50
|
SUCCESS_CODES = [
|
51
51
|
201, 202, 203, 204, 301, 302, 303, 304
|
52
|
-
]
|
52
|
+
].freeze
|
53
53
|
|
54
54
|
ERROR_CODES = [
|
55
55
|
400, 401, 402, 403, 404, 500, 501, 502, 503
|
56
|
-
]
|
56
|
+
].freeze
|
57
57
|
|
58
58
|
UNAUTHORIZED_CODES = [
|
59
59
|
400, 401, 402, 403
|
60
|
-
]
|
60
|
+
].freeze
|
61
61
|
|
62
62
|
private
|
63
63
|
|
data/lib/elmas/result_set.rb
CHANGED
@@ -5,13 +5,13 @@ module Elmas
|
|
5
5
|
def initialize(parsed_response)
|
6
6
|
@parsed_response = parsed_response
|
7
7
|
|
8
|
-
if @parsed_response.results
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
@records = if @parsed_response.results
|
9
|
+
@parsed_response.results.map do |attributes|
|
10
|
+
resource_class.send(:new, attributes)
|
11
|
+
end
|
12
|
+
else
|
13
|
+
[resource_class.send(:new, @parsed_response.result)]
|
14
|
+
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def next_page
|
data/lib/elmas/sanitizer.rb
CHANGED
@@ -16,7 +16,10 @@ module Elmas
|
|
16
16
|
to_submit
|
17
17
|
end
|
18
18
|
|
19
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
20
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
19
21
|
def sanitize_relationship(value)
|
22
|
+
# rubocop:disable Style/GuardClause
|
20
23
|
if value.is_a?(Elmas::Resource)
|
21
24
|
return value.id # Turn relation into ID
|
22
25
|
elsif value.is_a?(Array)
|
@@ -30,7 +33,10 @@ module Elmas
|
|
30
33
|
else
|
31
34
|
return value
|
32
35
|
end
|
36
|
+
# rubocop:enable Style/GuardClause
|
33
37
|
end
|
38
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
39
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
34
40
|
|
35
41
|
def sanitize_date_time(value)
|
36
42
|
value.strftime("%Y-%m-%d")
|
data/lib/elmas/uri.rb
CHANGED
@@ -9,11 +9,11 @@ module Elmas
|
|
9
9
|
options.each do |option|
|
10
10
|
send("apply_#{option}".to_sym)
|
11
11
|
end
|
12
|
-
if options.include?(:id)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
uri = if options.include?(:id)
|
13
|
+
URI("#{base_path}(guid'#{id}')")
|
14
|
+
else
|
15
|
+
URI(base_path)
|
16
|
+
end
|
17
17
|
uri.query = URI.encode_www_form(@query)
|
18
18
|
uri
|
19
19
|
end
|
@@ -73,7 +73,7 @@ module Elmas
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def apply_select
|
76
|
-
@query << ["$select",
|
76
|
+
@query << ["$select", @select.map { |s| Utils.camelize(s) }.join(",")] if @select
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/lib/elmas/utils.rb
CHANGED
data/lib/elmas/version.rb
CHANGED