Class: StratumnSdk::Agent
- Inherits:
-
Object
- Object
- StratumnSdk::Agent
- Extended by:
- Request
- Includes:
- Request
- Defined in:
- lib/stratumn_sdk/agent.rb
Overview
Represents a Stratumn application
Instance Attribute Summary collapse
-
#agent_info ⇒ Object
Returns the value of attribute agent_info.
-
#store_info ⇒ Object
Returns the value of attribute store_info.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #create_map(*args) ⇒ Object
- #find_segments(options = {}) ⇒ Object
- #get_map_ids(options = {}) ⇒ Object
- #get_segment(link_hash) ⇒ Object
-
#initialize(url, agent_info, store_info) ⇒ Agent
constructor
A new instance of Agent.
Methods included from Request
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_info ⇒ Object
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_info ⇒ Object
Returns the value of attribute store_info.
8 9 10 |
# File 'lib/stratumn_sdk/agent.rb', line 8 def store_info @store_info end |
#url ⇒ Object
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( = {}) result = get(url + '/segments?' + URI.encode_www_form()) 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( = {}) get(url + '/maps?' + URI.encode_www_form()) end |