Sha256: c84d72e4ca3382b0528285eaed43e030ab3cab822ac4cc6af9af19e4ff74f1a7
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 KB
Contents
module StratumnSdk ## # Represents a Stratumn application class Application include Request extend Request attr_accessor :url, :id, :name, :agent_info def self.load(application_name, application_location = nil) url = application_location || StratumnSdk.config[:application_url].gsub('%s', application_name) attributes = get(url) new(url, attributes['id'], attributes['name'], attributes['agentInfo']) end def initialize(url, id, name, agent_info) self.url = url self.id = id self.name = name self.agent_info = agent_info end def create_map(*args) result = post(url + '/maps', json: args) raise result['meta']['errorMessage'] if result['meta']['errorMessage'] Link.new(self, result) end def get_link(link_hash) result = get(url + '/links/' + link_hash) Link.new(self, result) end def get_map(map_id, tags = []) query = tags.empty? ? '' : "?tags=#{tags.join('&tags=')}" result = get(url + '/maps/' + map_id + query) result.map do |link| Link.new(self, link) end end def get_branches(link_hash, tags = []) query = tags.empty? ? '' : "?tags=#{tags.join('&tags=')}" result = get(url + '/branches/' + link_hash + query) result.map do |link| Link.new(self, link) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stratumn_sdk-0.2.0 | lib/stratumn_sdk/application.rb |
stratumn_sdk-0.1.0 | lib/stratumn_sdk/application.rb |