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.
- checksums.yaml +4 -4
- data/lib/concourserb.rb +12 -18
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db723191998d78803efbfd8f5463107cd5cca87c
|
4
|
+
data.tar.gz: 6e51bb79b48699f7bae51d5fb3416ff52ca6d8c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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['
|
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['
|
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
|
-
|
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
|