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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10abfebcd17a54de33628c1e48170981b30e5345
4
- data.tar.gz: 7c67ccf52b8231b059cb44b80f045fd6f343e7f0
3
+ metadata.gz: 1dab67a65bc9196c76e1536d56b590dd6a2b921f
4
+ data.tar.gz: 973eee206fdd9512efc410d01b5f7fa5c7725b19
5
5
  SHA512:
6
- metadata.gz: c20a92ba86f300be0a92861a8bc7e1e96ec415e0829cd86d99e39ade4f7732f3ad6a237379dfadaebf5c06e61b97ec4b12e7f268a91220589ba067bd36911a4e
7
- data.tar.gz: 680ef9d45f1140fb40b3ce151ed1a6c9a5af780c641def387039e57b4d7b9865a205315a499de4b49afe5cbf450e40e545ae4e25b2a3063d04931a55f8dcd32b
6
+ metadata.gz: 607279e3a029d11bff668d3b45ec0ca65f80fc4d414f73abd74ac685120386356a2ea62b79cf27cbe205afa66a4d3f15444019b6680289fffd601e37c59e4441
7
+ data.tar.gz: 6e5e1a74905fbb2f774c001982abf04a8fd78b64267a38ae8000b7b62e92942d21767fde3600350b685c170f28d90cb73b427cfde1d443a6b4d5b506d2b69bfe
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
3
+ - 2.2.3
4
4
  cache: bundler
data/Changelog.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.2.2
2
+
3
+ - Fix rubocop issues and specs
4
+
1
5
  ## 2.2.1
2
6
 
3
7
  - Fix date sanitizing (608883148a367d2388b9daa9b454ac6b2dbbf10d)
data/lib/elmas/api.rb CHANGED
@@ -6,7 +6,7 @@ module Elmas
6
6
  # @private
7
7
  class API
8
8
  # @private
9
- attr_accessor *(Config::VALID_OPTIONS_KEYS)
9
+ attr_accessor *Config::VALID_OPTIONS_KEYS
10
10
 
11
11
  # Creates a new API
12
12
  def initialize(options = {})
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 *(VALID_OPTIONS_KEYS)
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)
@@ -63,11 +63,8 @@ module Elmas
63
63
  def save
64
64
  attributes_to_submit = sanitize
65
65
  if valid?
66
- if id?
67
- return @response = Elmas.put(basic_identifier_uri, params: attributes_to_submit)
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
@@ -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
 
@@ -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
- @records = @parsed_response.results.map do |attributes|
10
- resource_class.send(:new, attributes)
11
- end
12
- else
13
- @records = [resource_class.send(:new, @parsed_response.result)]
14
- end
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
@@ -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
- uri = URI("#{base_path}(guid'#{id}')")
14
- else
15
- uri = URI(base_path)
16
- end
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", (@select.map { |s| Utils.camelize(s) }.join(","))] if @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
@@ -41,7 +41,7 @@ module Elmas
41
41
  end
42
42
 
43
43
  def self.parse_key(key)
44
- "VATCode" if key.downcase == "vat_code"
44
+ "VATCode" if key.casecmp "vat_code"
45
45
  Utils.camelize(key)
46
46
  end
47
47
  end
data/lib/elmas/version.rb CHANGED
@@ -2,7 +2,7 @@ module Elmas
2
2
  class Version
3
3
  MAJOR = 2
4
4
  MINOR = 2
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  class << self
8
8
  def to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elmas
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marthyn