Class: Foy::API::Client::Base

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

Instance Method Summary collapse

Constructor Details

#initialize(base_url) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/foy_api_client.rb', line 8

def initialize(base_url)
  @base_url = base_url
end

Instance Method Details

#get_packages(system: system) ⇒ Object



21
22
23
24
# File 'lib/foy_api_client.rb', line 21

def get_packages(system: system)
  json_data = RestClient.get "#{@base_url}/v1/packages/#{system}.json", {:accept => :json}
  parse_collection(json_data)
end

#get_projectsObject



12
13
14
15
# File 'lib/foy_api_client.rb', line 12

def get_projects
  json_data = RestClient.get "#{@base_url}/v1/projects.json", {:accept => :json}
  parse_collection(json_data)
end

#put_packages(system: system, packages: []) ⇒ Object



26
27
28
# File 'lib/foy_api_client.rb', line 26

def put_packages(system: system, packages: [])
  RestClient.put "#{@base_url}/v1/packages/#{system}.json", {packages: packages}.to_json, {accept: :json, content_type: :json}
end

#put_project_packages(project_id: nil, packages: [], system: nil) ⇒ Object



17
18
19
# File 'lib/foy_api_client.rb', line 17

def put_project_packages(project_id: nil, packages: [], system: nil)
  RestClient.put "#{@base_url}/v1/projects/#{project_id}/packages.json", {packages: packages}.to_json, {params: {system: system}, accept: :json, content_type: :json}
end