Class: DeployGate::API::V1::Base
- Inherits:
-
Object
- Object
- DeployGate::API::V1::Base
- Defined in:
- lib/deploygate/api/v1/base.rb
Constant Summary collapse
- BASE_URL =
ENV['DG_DEVELOP_URL'] || 'https://deploygate.com'
- API_BASE_URL =
"#{BASE_URL}/api"
Instance Method Summary collapse
-
#get(path, params) ⇒ Hash
Responce parse json.
- #initialize(token = nil) ⇒ DeployGate::API::V1::Base constructor
-
#post(path, params) { ... } ⇒ Hash
Responce parse json.
Constructor Details
#initialize(token = nil) ⇒ DeployGate::API::V1::Base
10 11 12 |
# File 'lib/deploygate/api/v1/base.rb', line 10 def initialize(token = nil) @token = token end |
Instance Method Details
#get(path, params) ⇒ Hash
Returns Responce parse json.
17 18 19 20 21 22 |
# File 'lib/deploygate/api/v1/base.rb', line 17 def get(path, params) url = API_BASE_URL + path res = client.get(url, params, headers) JSON.parse(res.body) end |
#post(path, params) { ... } ⇒ Hash
Returns Responce parse json.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/deploygate/api/v1/base.rb', line 28 def post(path, params, &process_block) url = API_BASE_URL + path connection = client.post_async(url, params, headers) while true break if connection.finished? process_block.call unless process_block.nil? end io = connection.pop.content body = '' while str = io.read(40) body += str end JSON.parse(body) end |