Sha256: 09163085ab7ea2d44849627d39839fa0fde072fdcbefcbf1c67a7444896eab8c
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
require 'visdiff/config' module Visdiff class Client attr_reader :config def initialize(config=Visdiff.config) @config = config.dup end def revision(identifier=nil, images=[], description=nil) revision = Revision.new(identifier, images, description) revision.client = self yield revision if block_given? revision end def submit_revision revision post('revisions', revision: revision.attributes) end def submit_image image put("images/#{image.signature}", image: image.attributes) end private def post path, data parse(conn.post(path, request_data(data))) end def put path, data parse(conn.put(path, request_data(data))) end def request_data data {api_key: api_key}.merge(data) end def api_key config.api_key || raise("visdiff api key not configured") end def base_url "#{config.base_url}/api" end def conn config.connection end def parse response raise response.body unless response.success? JSON.parse(response.body) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
visdiff-0.0.7 | lib/visdiff/client.rb |
visdiff-0.0.6 | lib/visdiff/client.rb |
visdiff-0.0.5 | lib/visdiff/client.rb |