R3c 0.0.8 → 0.0.9

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: 891785aca6c9373f5d616109a1dd8671fe54a82b
4
- data.tar.gz: 3db7c2db12dc86c51e5723451b96a646d79f4161
3
+ metadata.gz: d5fe51ccd80003667c2ad3dc0abadddab02b00b3
4
+ data.tar.gz: 959e3978652765704fb4870e599602b52d5ff4c2
5
5
  SHA512:
6
- metadata.gz: c51fc0d15f1a1f08709a2d60ca3010a28022a8578b2261daee222edb3f65b0d71db4ed126495d84e4a9c5371cac9fb9158becb9be439fabc1a7d2e7f155c5573
7
- data.tar.gz: fba8dbf911b4050dcf246627cca98972d6a5a79eda331241fbef262584d03800a372a17a8fde0e5a4d09acef35dff4c7f925da4a13239a59ef2b4d56b2105f31
6
+ metadata.gz: d178c2e801af962c6c294a03626236bf400c7355d7feca2cab6f8348c402c73c70825260600bf06ee030cd5a3df5b8d38fc4a0ff239695d96a0aa30636d2efa0
7
+ data.tar.gz: 7ea9e1b6f36030f2e08218cbacc0606602608c0db9e6eaea5a720459311b81816a088c722bd66935c5130164b594f6b090f2e11f3c24e1dd757fadc339711c3f
@@ -6,9 +6,18 @@ module R3c
6
6
 
7
7
 
8
8
 
9
- def self.upload(file, format="xml")
10
- response = execute(method: :post, url: "#{R3c::BaseEntity.site}/uploads.#{format}", file: file, :multipart => true, :content_type => 'application/octet-stream')
11
- token = JSON.parse(response)['upload']['token']
9
+ def self.upload(file)
10
+ response = nil
11
+ params= {:multipart => true, :content_type => 'application/octet-stream'}
12
+ params= set_ssl_params(params)
13
+ if !R3c::BaseEntity.user
14
+ #response = RestClient.post("#{R3c::BaseEntity.site}/uploads.json?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", file, {:multipart => true, :content_type => 'application/octet-stream'})
15
+ response = RestClient.post("#{R3c::BaseEntity.site}/uploads.json?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", file, params)
16
+ else
17
+ params = add_auth(params)
18
+ response = RestClient.post("#{R3c::BaseEntity.site}/uploads.json", file, params)
19
+ end
20
+ JSON.parse(response)['upload']['token']
12
21
  end
13
22
 
14
23
 
@@ -55,19 +64,29 @@ module R3c
55
64
 
56
65
  private
57
66
  def self.execute(params)
67
+ params = add_basic_auth(params)
68
+ params= set_ssl_params(params)
69
+ puts "rest-helper.rb->execute: params="+params.inspect.to_s
70
+ RestClient::Request.execute(params)
71
+ end
72
+
73
+ def self.add_auth(params)
58
74
  if R3c::BaseEntity.user
59
75
  params[:user]= R3c::BaseEntity.user
60
76
  params[:password]=R3c::BaseEntity.password
61
77
  else
62
78
  params[:url]= params[:url]+"?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}"
63
79
  end
64
- puts "rest-helper.rb->execute: params="+params.inspect.to_s
80
+ return params
81
+ end
82
+
83
+ def self.set_ssl_params(params)
65
84
  if R3c::BaseEntity.site.to_s.include?("https")
66
85
  params[:verify_ssl]=R3c::BaseEntity.ssl_options[:verify_mode]
67
86
  params= params.merge(R3c::BaseEntity.ssl_options)
68
- puts "rest-helper.rb->execute: params="+params.inspect.to_s
69
87
  end
70
- RestClient::Request.execute(params)
88
+ return params
71
89
  end
72
90
 
91
+
73
92
  end
@@ -1,5 +1,5 @@
1
1
  module R3c
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
4
4
 
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: R3c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paolo Freuli