Class: StratumnSdk::Agent

Inherits:
Object
  • Object
show all
Extended by:
Request
Includes:
Request
Defined in:
lib/stratumn_sdk/agent.rb

Overview

Represents a Stratumn application

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Request

get, post

Constructor Details

#initialize(url, agent_info, store_info) ⇒ Agent

Returns a new instance of Agent.



18
19
20
21
22
# File 'lib/stratumn_sdk/agent.rb', line 18

def initialize(url, agent_info, store_info)
  self.url = url
  self.agent_info = agent_info
  self.store_info = store_info
end

Instance Attribute Details

#agent_infoObject

Returns the value of attribute agent_info.



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

def agent_info
  @agent_info
end

#store_infoObject

Returns the value of attribute store_info.



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

def store_info
  @store_info
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.load(url) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/stratumn_sdk/agent.rb', line 10

def self.load(url)
  attributes = get(url)

  new(url,
      attributes['agentInfo'],
      attributes['storeInfo'])
end

Instance Method Details

#create_map(*args) ⇒ Object



24
25
26
27
28
# File 'lib/stratumn_sdk/agent.rb', line 24

def create_map(*args)
  result = post(url + '/segments', json: args)

  Segment.new(self, result)
end

#find_segments(options = {}) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/stratumn_sdk/agent.rb', line 34

def find_segments(options = {})
  result = get(url + '/segments?' + URI.encode_www_form(options))

  result.map do |link|
    Segment.new(self, link)
  end
end

#get_map_ids(options = {}) ⇒ Object



30
31
32
# File 'lib/stratumn_sdk/agent.rb', line 30

def get_map_ids(options = {})
  get(url + '/maps?' + URI.encode_www_form(options))
end

#get_segment(link_hash) ⇒ Object



42
43
44
45
46
# File 'lib/stratumn_sdk/agent.rb', line 42

def get_segment(link_hash)
  result = get(url + '/segments/' + link_hash)

  Segment.new(self, result)
end