concourserb 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/concourserb.rb +12 -18
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28051c1b07a2adc7639bf5d6810609fb66219fd6
4
- data.tar.gz: 7c6b58482f0236015d1b4207650468a314f103ad
3
+ metadata.gz: db723191998d78803efbfd8f5463107cd5cca87c
4
+ data.tar.gz: 6e51bb79b48699f7bae51d5fb3416ff52ca6d8c9
5
5
  SHA512:
6
- metadata.gz: 5b1294773444f09f07e3a7ed0ff6a1bb70b15e6fdaa556e170fe98a86469ebc4df88860b196a4a6db94d573184e19844a2dc2bd856d3a5a4ce399647577835b6
7
- data.tar.gz: 05ca20b6f76a4d5670ae0c9bc6db34c14a120957314a04deb4305aac6ee6379cdfab0b607778a24cac979265a5b1e246b2db8a90c0e57be54cfeb71a9a88d67b
6
+ metadata.gz: fa729b277a0c4f9bb41fc68755d12ff80c127a8bed54d710b7e46ae2197c2850ea41687f62304001a63bfa3dee742a36a00f8d5dee4eef280c8607bedff06b5e
7
+ data.tar.gz: ad3f8d9c51c602a8cc46243d18b6956bd3cdf7971b601a7174a540cd92a7d9d4e20a225a10ff0155336003684b28a2540b35e088857d29d26ae3658d69dc73fa
data/lib/concourserb.rb CHANGED
@@ -48,37 +48,31 @@ class Concourserb
48
48
  return true
49
49
  end
50
50
 
51
- def req(url)
51
+ def req(url, http_verb="GET", post_data={})
52
52
  http = Net::HTTP.new(URI.parse(@url).host, URI.parse(@url).port)
53
53
  http.use_ssl = true
54
- request = Net::HTTP::Get.new(url)
54
+ if http_verb.eql?('GET')
55
+ request = Net::HTTP::Get.new(url)
56
+ elsif http_verb.eql?('POST')
57
+ request = Net::HTTP::Post.new(url)
58
+ request.set_form_data(post_data)
59
+ else
60
+ raise "http_verb not implemented: #{http_verb}"
61
+ end
55
62
  request['Content-Type'] = 'application/json'
56
- request['Cookie'] = "ATC-Authorization=Bearer #{@ATC_auth}"
63
+ request['Authorization'] = "Bearer #{@ATC_auth}"
57
64
  response = http.request(request)
58
65
  if response.code == 401
59
66
  # we got bad auth, so get a new token
60
67
  auth()
61
- request['Cookie'] = "ATC-Authorization=Bearer #{@ATC_auth}"
68
+ request['Authorization'] = "Bearer #{@ATC_auth}"
62
69
  response = http.request(request)
63
70
  end
64
71
  return JSON.parse(response.body)
65
72
  end
66
73
 
67
74
  def post(url, post_data={})
68
- http = Net::HTTP.new(URI.parse(@url).host, URI.parse(@url).port)
69
- http.use_ssl = true
70
- request = Net::HTTP::Post.new(url)
71
- request.set_form_data(post_data)
72
- request['Content-Type'] = 'application/json'
73
- request['Cookie'] = "ATC-Authorization=Bearer #{@ATC_auth}"
74
- response = http.request(request)
75
- if response.code == 401
76
- # we got bad auth, so get a new token
77
- auth()
78
- request['Cookie'] = "ATC-Authorization=Bearer #{@ATC_auth}"
79
- response = http.request(request)
80
- end
81
- return JSON.parse(response.body)
75
+ return req(url, 'POST')
82
76
  end
83
77
 
84
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concourserb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Arwine