Class: RdhApi

Inherits:
Object
  • Object
show all
Defined in:
lib/rdh/rdh_api.rb

Class Method Summary collapse

Class Method Details

.create(gem_name, version, dependencies) ⇒ Object



19
20
21
22
23
24
# File 'lib/rdh/rdh_api.rb', line 19

def self.create(gem_name, version, dependencies)
  body = {dependencies: dependencies, version: version}
  uri =  BASE_URI + '/api/gems/' + gem_name

  HTTParty.post(uri, :body => body.to_json, :headers => { 'Content-Type' => 'application/json' })
end

.get(gem_name, version, os) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/rdh/rdh_api.rb', line 8

def self.get(gem_name, version, os)
  uri =  BASE_URI + '/api/gems/' + gem_name
  options = {os: os, version: version}

  resp = HTTParty.get(uri, options)
  if resp.code != 200
    return {success: false, code: resp.code}
  end
  return {success: true, results: JSON.parse(resp.body), os: os}
end