class Manifestly::Entity::ChildEndpoint
Public Class Methods
get(id, parent)
click to toggle source
# File lib/manifestly/entity/endpoint.rb, line 109 def self.get(id, parent) response = client.get("#{location(parent)}/#{id}") json_entity = JSON.parse(response[:body], symbolize_names: true)[singular_endpoint_target.to_sym] new(parent, json_entity) end
list(parent, **params)
click to toggle source
# File lib/manifestly/entity/endpoint.rb, line 103 def self.list(parent, **params) response = client.get(location(parent), params: params) json_entities = JSON.parse(response[:body], symbolize_names: true)[endpoint_target] json_entities.map { |it| new(parent, it) } end
location(parent)
click to toggle source
# File lib/manifestly/entity/endpoint.rb, line 99 def self.location(parent) "#{parent.location}/#{parent.id}/#{endpoint_target}" end
new(parent, data = {})
click to toggle source
Calls superclass method
Manifestly::Entity::Base::new
# File lib/manifestly/entity/endpoint.rb, line 88 def initialize(parent, data = {}) raise "invalid #{parent_class}" unless parent.is_a?(parent_class) @parent = parent super(data) end
parent_class()
click to toggle source
# File lib/manifestly/entity/endpoint.rb, line 84 def self.parent_class raise 'Must specify parent_class' end
Public Instance Methods
delete(path: location)
click to toggle source
# File lib/manifestly/entity/endpoint.rb, line 120 def delete(path: location) client.delete("#{path}/#{id}") nil end
location()
click to toggle source
# File lib/manifestly/entity/endpoint.rb, line 95 def location self.class.location(@parent) end
parent_class()
click to toggle source
# File lib/manifestly/entity/endpoint.rb, line 80 def parent_class self.class.parent_class end
update(path: location)
click to toggle source
# File lib/manifestly/entity/endpoint.rb, line 115 def update(path: location) client.put("#{path}/#{id}", params: to_h) self end