elmas 3.0.1 → 3.1.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: 811521bb9a899d14a61d9cae66de40edbb39a8ea0e5b1950afa4251cf33afd73
4
- data.tar.gz: bd849be962e1a9683cd76d4d9b9d99aa12ef818238cd6cbbf7b4f44184c1b9ab
3
+ metadata.gz: b17b89ef70b1b3a09cbef79f2fb3132b80ca5da223fc9ef12dbe7aead89d5a04
4
+ data.tar.gz: a18c2b4f0820792037c561238285555de12dc9b3b623e215d31ec95ac774abb4
5
5
  SHA512:
6
- metadata.gz: 18830b61830ca08730fce161817b11c3b6754bf8b957f5596ea65774b7af35b639ceff5afba10dae746d52bb9940a39d2ca01ce821a57ae9ad9658f3f862a8ba
7
- data.tar.gz: 4c711e2d9503a04ede952a53357e7cbb20a2d8ed2091ddeab201ca663fd197fd08b56f1b09e0a6681cbcfda61ef808e38b54cef5f3705cdedd3509631ecf9d5a
6
+ metadata.gz: bf45cd2c72c8024c6ae0ec447fabd04a42512f2d47cf64ca16225d8ce2934203b7c77578c68efd4e988b0c668ee39c7efa39d7c5e142738ff209ae6c2df49386
7
+ data.tar.gz: 8c4d887c2d65f85d1f841fa4e84a8ff2df9f367fa3214fc5077c7f45dd9d96f9c29b102a8c172287265be715dc7a21359862ce0c90b62487dccb5fc1d2a2b672
@@ -1,3 +1,7 @@
1
+ ## 3.1.0
2
+ - Remove deprecated methods
3
+ - Show more insight into BadRequestExceptions
4
+
1
5
  ## 3.0.1
2
6
  - Change of bank_name to bank_account_holder_name
3
7
  - Readd journal because although not required, it should still be possible to set
@@ -9,7 +9,11 @@ module Elmas
9
9
  end
10
10
 
11
11
  def message
12
- "code #{@response.status}: #{@parsed.error_message}"
12
+ if @parsed.error_message.present?
13
+ "code #{@response.status}: #{@parsed.error_message}"
14
+ else
15
+ @response.inspect
16
+ end
13
17
  end
14
18
  end
15
19
 
@@ -15,30 +15,10 @@ require File.expand_path("../response", __FILE__)
15
15
  module Elmas
16
16
  # rubocop:disable Metrics/ModuleLength
17
17
  module OAuth
18
- def authorize(user_name, password, options = {})
19
- warn "[DEPRECATION] `authorize` is deprecated. Please implement your own authorization methods instead."
20
- agent = Mechanize.new
21
-
22
- login(agent, user_name, password, options)
23
- allow_access(agent)
24
-
25
- code = URI.unescape(agent.page.uri.query.split("=").last)
26
- OauthResponse.new(get_access_token(code))
27
- end
28
-
29
- def refresh_authorization
30
- warn "[DEPRECATION] `refresh_authorization` is deprecated. Please implement your own authorization methods instead."
31
- OauthResponse.new(get_refresh_token(refresh_token)).tap do |response|
32
- Elmas.configure do |config|
33
- config.access_token = response.access_token
34
- config.refresh_token = response.refresh_token
35
- end
36
- end
37
- end
38
-
39
18
  def authorized?
40
19
  # Do a test call, return false if 401 or any error code
41
- get("/Current/Me", no_division: true)
20
+ response = Elmas.get("/Current/Me", no_division: true)
21
+ response.results.first.present?
42
22
  rescue BadRequestException
43
23
  Elmas.error "Not yet authorized"
44
24
  return false
@@ -48,17 +28,6 @@ module Elmas
48
28
  get("/Current/Me", no_division: true).results.first.current_division
49
29
  end
50
30
 
51
- def auto_authorize
52
- warn "[DEPRECATION] `auto_authorize` is deprecated. Please implement your own authorization methods instead."
53
- Elmas.configure do |config|
54
- config.redirect_uri = ENV["REDIRECT_URI"]
55
- config.client_id = ENV["CLIENT_ID"]
56
- config.client_secret = ENV["CLIENT_SECRET"]
57
- config.access_token = Elmas.authorize(ENV["EXACT_USER_NAME"], ENV["EXACT_PASSWORD"]).access_token
58
- config.division = Elmas.authorize_division
59
- end
60
- end
61
-
62
31
  # Return URL for OAuth authorization
63
32
  def authorize_url(options = {})
64
33
  options[:response_type] ||= "code"
@@ -102,24 +71,6 @@ module Elmas
102
71
 
103
72
  private
104
73
 
105
- def login(agent, user_name, password, options)
106
- # Login
107
- agent.get(authorize_url(options)) do |page|
108
- form = page.forms.first
109
- form["UserNameField"] = user_name
110
- form["PasswordField"] = password
111
- form.click_button
112
- end
113
- end
114
-
115
- def allow_access(agent)
116
- return if agent.page.uri.to_s.include?("getpostman")
117
- return if agent.page.uri.to_s.include?(redirect_uri)
118
- form = agent.page.form_with(id: "PublicOAuth2Form")
119
- button = form.button_with(id: "AllowButton")
120
- agent.submit(form, button)
121
- end
122
-
123
74
  def authorization_params
124
75
  {
125
76
  client_id: client_id
@@ -145,9 +96,7 @@ module Elmas
145
96
  }
146
97
  end
147
98
  end
148
- end
149
99
 
150
- module Elmas
151
100
  class OauthResponse < Response
152
101
  def body
153
102
  JSON.parse(@response.body)
@@ -165,4 +114,4 @@ module Elmas
165
114
  body["refresh_token"]
166
115
  end
167
116
  end
168
- end
117
+ end
@@ -9,7 +9,8 @@ module Elmas
9
9
  rescue JSON::ParserError => e
10
10
  Elmas.error "There was an error parsing the response"
11
11
  Elmas.error "#{e.class}: #{e.message}"
12
- @error_message = "#{e.class}: #{e.message}"
12
+ @parsed_json = ""
13
+ @error_message = ""
13
14
  end
14
15
 
15
16
  def results
@@ -3,8 +3,8 @@
3
3
  module Elmas
4
4
  class Version
5
5
  MAJOR = 3
6
- MINOR = 0
7
- PATCH = 1
6
+ MINOR = 1
7
+ PATCH = 0
8
8
 
9
9
  class << self
10
10
  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: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marthyn