Sha256: de06d18cc946b735d2d34edd2f4509597c44d47cc3b75c86099461aa1d3f6dd5
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
require 'faraday' require 'json' require 'hashie' module Atlas module Api class Client def initialize(options = {}) @api_endpoint = options[:api_endpoint] @auth_token = options[:auth_token] end # Builds # ------------------------------------------------------------------------ def builds(options = {}) get("/builds", options) end def build(id, options = {}) get("/builds/#{id}", options) end def create_build(options) post("/builds", options) end # Build Formats # ------------------------------------------------------------------------ def update_build_format(uuid, options = {}) put("/build_formats/#{uuid}", options) end # HTTP methods # ------------------------------------------------------------------------ def get(path, options = {}) request :get, path, options end def post(path, options = {}) request :post, path, options end def put(path, options = {}) request :put, path, options end def delete(path, options = {}) request :delete, path, options end def agent @agent ||= Faraday.new(@api_endpoint, { params: { auth_token: @auth_token }}) end private def request(method, path, options) @last_response = response = agent.send(method, URI.encode(path), options) Hashie::Mash.new(JSON.parse(response.body)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
atlas-api-0.0.1 | lib/atlas-api/client.rb |