class Subledger::Store::Api::Store
Attributes
http[R]
Public Instance Methods
add_initial_controls_for(org)
click to toggle source
# File lib/subledger/store/api/store.rb, line 24 def add_initial_controls_for org # Server handles this functionality end
add_initial_controls_to(identity)
click to toggle source
# File lib/subledger/store/api/store.rb, line 28 def add_initial_controls_to identity # Server handles this functionality end
backup_exists?(anchor)
click to toggle source
# File lib/subledger/store/api/store.rb, line 40 def backup_exists? anchor # No endpoints for this end
create_backup(anchor)
click to toggle source
# File lib/subledger/store/api/store.rb, line 36 def create_backup anchor # No endpoints for this end
raise_unless_bucket_name_valid(args)
click to toggle source
# File lib/subledger/store/api/store.rb, line 32 def raise_unless_bucket_name_valid args # No endpoints for this end
Private Instance Methods
base_url()
click to toggle source
# File lib/subledger/store/api/store.rb, line 48 def base_url "#{SCHEME}#{DOMAIN}" end
klass_method_from(parsed_json)
click to toggle source
# File lib/subledger/store/api/store.rb, line 69 def klass_method_from parsed_json parsed_json.keys.first end
new_or_initialize(json_body, initializable)
click to toggle source
# File lib/subledger/store/api/store.rb, line 73 def new_or_initialize json_body, initializable client = initializable.client parsed_json = parse_json json_body klass_method = klass_method_from parsed_json response_hash = parsed_json[klass_method] args = Rest.to_args response_hash, client args.merge! :json => MultiJson.dump( response_hash ) if initializable.respond_to? :post_delay args.merge! :post_delay => initializable.post_delay end new_item = client.send klass_method, args if initializable.entity_name == klass_method.to_sym initializable.send :initialize, new_item.attributes else initializable = new_item end initializable end
parse_json(json_body)
click to toggle source
# File lib/subledger/store/api/store.rb, line 65 def parse_json json_body MultiJson.load json_body end
setup()
click to toggle source
# File lib/subledger/store/api/store.rb, line 52 def setup @http = Faraday.new :url => base_url do |conn| unless auth_key.nil? conn.basic_auth auth_key.id, auth_key.secret end conn.request :json conn.response :json, :content_type => /^json$/ conn.use Subledger::Store::Api::Errors::ResponseError conn.adapter Faraday.default_adapter end end