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"
- BASE_HEADERS =
[ ['X-DEPLOYGATE-CLIENT-ID', "cli/#{::DeployGate::VERSION_CODE}"], ['X-DEPLOYGATE-CLIENT-VERSION-NAME', ::DeployGate::VERSION], ].freeze
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
14 15 16 |
# File 'lib/deploygate/api/v1/base.rb', line 14 def initialize(token = nil) @token = token end |
Instance Method Details
#get(path, params) ⇒ Hash
Returns Responce parse json.
21 22 23 24 25 26 |
# File 'lib/deploygate/api/v1/base.rb', line 21 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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/deploygate/api/v1/base.rb', line 32 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 |