Class: Remitano::Client::Collection
- Inherits:
-
Object
- Object
- Remitano::Client::Collection
- Defined in:
- lib/remitano/client/collection.rb
Direct Known Subclasses
ActionConfirmations, CoinCollection, FiatCollection, PublicOffers
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#path ⇒ Object
Returns the value of attribute path.
-
#resource_name ⇒ Object
Returns the value of attribute resource_name.
Instance Method Summary collapse
- #all ⇒ Object
- #create(params = {}) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(config:) ⇒ Collection
constructor
A new instance of Collection.
- #update(id, params = {}) ⇒ Object
Constructor Details
#initialize(config:) ⇒ Collection
Returns a new instance of Collection.
6 7 8 9 10 11 |
# File 'lib/remitano/client/collection.rb', line 6 def initialize(config:) @config = config name = self.class.name.underscore.split("/").last self.resource_name = name.singularize self.path = "/#{name}" end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/remitano/client/collection.rb', line 4 def config @config end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/remitano/client/collection.rb', line 3 def path @path end |
#resource_name ⇒ Object
Returns the value of attribute resource_name.
3 4 5 |
# File 'lib/remitano/client/collection.rb', line 3 def resource_name @resource_name end |
Instance Method Details
#all ⇒ Object
13 14 15 |
# File 'lib/remitano/client/collection.rb', line 13 def all config.net.new(config: config).get(self.path).execute end |
#create(params = {}) ⇒ Object
17 18 19 |
# File 'lib/remitano/client/collection.rb', line 17 def create(params = {}) config.net.new(config: config).post(self.path, { self.resource_name => params }).execute end |
#get(id) ⇒ Object
21 22 23 |
# File 'lib/remitano/client/collection.rb', line 21 def get(id) config.net.new(config: config).get("#{self.path}/#{id}").execute end |
#update(id, params = {}) ⇒ Object
25 26 27 |
# File 'lib/remitano/client/collection.rb', line 25 def update(id, params = {}) config.net.new(config: config).patch("#{self.path}/#{id}", { self.resource_name => params }).execute end |