Class: PriceHubble::Dossier
- Inherits:
-
BaseEntity
- Object
- BaseEntity
- PriceHubble::Dossier
- Defined in:
- lib/price_hubble/entity/dossier.rb
Overview
The PriceHubble dossier for a single property.
Instance Attribute Summary
Attributes inherited from BaseEntity
Instance Method Summary collapse
-
#delete(**args) ⇒ PriceHubble::Dossier, false
(also: #destroy)
Deletes the instance at the remote application and freezes this instance to reflect that no changes should be made (since they can’t be persisted).
-
#link(ttl: 365.days, locale: 'de_CH', lang: 'de', **args) ⇒ String
Create a new dossier share link.
-
#save(**args) ⇒ Boolean
Save the dossier.
Methods inherited from BaseEntity
Constructor Details
This class inherits a constructor from PriceHubble::BaseEntity
Instance Method Details
#delete(**args) ⇒ PriceHubble::Dossier, false Also known as: destroy
Deletes the instance at the remote application and freezes this instance to reflect that no changes should be made (since they can’t be persisted).
56 57 58 |
# File 'lib/price_hubble/entity/dossier.rb', line 56 def delete(**args) client.delete_dossier(self, **args) || false end |
#link(ttl: 365.days, locale: 'de_CH', lang: 'de', **args) ⇒ String
Create a new dossier share link.
67 68 69 70 71 72 73 74 75 |
# File 'lib/price_hubble/entity/dossier.rb', line 67 def link(ttl: 365.days, locale: 'de_CH', lang: 'de', **args) # Make sure the current dossier is saved before we try to generate a link return unless save(**args) # Send a "share dossier" request to the service url = client.share_dossier(self, ttl: ttl, locale: locale, **args) url += "?lang=#{lang}" if url url end |
#save(**args) ⇒ Boolean
Save the dossier.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/price_hubble/entity/dossier.rb', line 35 def save(**args) # When the current entity is already persisted, we send an update if id.present? # Skip making requests when the current entity is not dirty return true unless changed? # The current entity is dirty, so send an update request return client.update_dossier(self, **args) end # Otherwise we send a new creation request client.create_dossier(self, **args) && true end |