Dendreo 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80deec797bcba45bc51d99def32ab84d15796a83e07e1219b6c379702d788ee5
4
- data.tar.gz: ba2118cdb3d05e7f0f6e875634eeffeb2354ed98355ef0df5326d6d1a1081b76
3
+ metadata.gz: d5e251ec6787004223c11a9f86927755a51e33e1593347d2fc836cff2b357904
4
+ data.tar.gz: 708399f2691f945b04c9f37956525d8d1ed2d6b40f00ab38e81d525938628464
5
5
  SHA512:
6
- metadata.gz: 6d28f4d2e4b3410911cc932d471b797509872bb3f8d1b1cb08dacec9187d31f43ac1a06c72069e5d20ab1f249c4a464331f32d42cdc935e5950a3ee79062c84a
7
- data.tar.gz: 145b8f63c3d285a33b6c2a7c98b39e423ee1d184237ec43fc9c4e0f7dd7350c160a2c95237970c9d6b39c020959fae3c9d60c8093bf07a861c829e3a726adf8d
6
+ metadata.gz: 371b50ebfe3db73d280bf4637874719572b75006633c699a2198fef68e66d502ddbdee5e988d417597fda4ff9dcef97270fdc7192fc0c47deaf5926c17927b61
7
+ data.tar.gz: c939bc7d33ddfdea8ea83dace82ec9f2eee86469bc1b02aa012700a1ff21fbae41253bac2288a1039f092d3767480b1b842660f86f04caba8c893621eefc222a
data/README.md CHANGED
@@ -121,7 +121,7 @@ Faites appel au support dendreo pour plus d'informations, ils sont très réacti
121
121
  # s'identifier en admin sur la mise à jour.)
122
122
  dendreo.participants(method: 'post', url_data: { id_participant: 1345 }, form_data: { nom: 'nouveau nom', civilite: 'M.', id_add: 2 })
123
123
 
124
- # Supprimer un participant (attention, il n'y a pas de methode 'delete' sûr tous les endpoints)
124
+ # Supprimer un participant (attention, il n'y a pas de methode 'delete' sur tous les endpoints)
125
125
  dendreo.participants(method: 'delete', url_data: { id_participant: 1345 })
126
126
 
127
127
  ```
@@ -24,7 +24,7 @@ module Dendreo
24
24
  def method_missing(method_name, *args)
25
25
  @errors = []
26
26
  @result = @request.call(
27
- http_method: args.first[:method],
27
+ http_method: args.first&.dig(:method),
28
28
  endpoint: method_name,
29
29
  args: args.first,
30
30
  )
@@ -39,7 +39,7 @@ module Dendreo
39
39
  @errors += @request.errors
40
40
  return if @errors.empty?
41
41
 
42
- raise Requests::Error.new(@errors.map(&:message).join(', '))
42
+ raise Requests::Error.new(@errors.map(&:message).uniq.join(', '))
43
43
  end
44
44
 
45
45
  def handle_init_errors
@@ -15,9 +15,10 @@ module Dendreo
15
15
 
16
16
  def call(http_method:, endpoint:, args: {})
17
17
  update_data(args)
18
- handle_call_errors(http_method, endpoint, args)
18
+ handle_call_errors(http_method, endpoint)
19
19
  execute(
20
20
  http_method,
21
+ endpoint,
21
22
  Requests::Url.new(@url, endpoint, @url_data, @api_key).complete_url,
22
23
  @form_data,
23
24
  )
@@ -26,28 +27,32 @@ module Dendreo
26
27
  private
27
28
 
28
29
  def update_data(args)
29
- @form_data = args[:form_data] || []
30
- @url_data = args[:url_data] || []
30
+ @form_data = args&.dig(:form_data) || []
31
+ @url_data = args&.dig(:url_data) || []
31
32
  end
32
33
 
33
- def execute(http_method, url, options = {})
34
+ def execute(http_method, endpoint, url, options = {})
34
35
  @request = RestClient::Request.execute(
35
36
  url: url,
36
37
  method: http_method,
37
38
  payload: options,
38
39
  )
39
40
  response_json(@request)
40
- rescue SocketError => e
41
+ rescue SocketError => _e
41
42
  errors << Requests::Error.new('Veuillez renseigner une url ex: https://pro.dendreo.com/my_company/api')
42
43
  rescue RestClient::ExceptionWithResponse => e
43
- response_json(e.response)
44
+ return response_json(e.response) if e.http_headers[:content_type] == 'application/json'
45
+
46
+ e.to_json
47
+ rescue => _e
48
+ handle_call_errors(http_method, endpoint)
44
49
  end
45
50
 
46
51
  def response_json(result)
47
52
  JSON.parse(result == '' ? '[{}]' : result)
48
53
  end
49
54
 
50
- def handle_call_errors(http_method, endpoint, args = {})
55
+ def handle_call_errors(http_method, endpoint)
51
56
  errors << Requests::Error.new(
52
57
  'Veuillez renseigner une méthode de requête ex: :post, :get, :delete'
53
58
  ) unless http_method
@@ -55,10 +60,11 @@ module Dendreo
55
60
  errors << Requests::Error.new(
56
61
  'Veuillez renseigner une méthode de requête ex: :participants'
57
62
  ) unless endpoint
63
+ return unless http_method == :post
58
64
 
59
65
  errors << Requests::Error.new(
60
- 'La data est vide sur une requête :post'
61
- ) if http_method == :post && args[:form_data].empty?
66
+ 'La data à mettre à jour (form_data:) est manquante sur une requête :post'
67
+ ) if @form_data.empty?
62
68
  end
63
69
  end
64
70
  end
@@ -1,3 +1,3 @@
1
1
  module Dendreo
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Dendreo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronan louarn
@@ -91,12 +91,6 @@ files:
91
91
  - ".rspec"
92
92
  - ".ruby-version"
93
93
  - ".travis.yml"
94
- - Dendreo-1.0.0.gem
95
- - Dendreo-1.0.1.gem
96
- - Dendreo-1.0.2.gem
97
- - Dendreo-1.0.3.gem
98
- - Dendreo-1.0.4.gem
99
- - Dendreo-1.1.0.gem
100
94
  - Gemfile
101
95
  - LICENSE.txt
102
96
  - README.md
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file