Class: ProoflinkConnect::Invite
- Inherits:
-
Object
- Object
- ProoflinkConnect::Invite
- Defined in:
- lib/prooflink_connect/invite.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#locale ⇒ Object
Returns the value of attribute locale.
Instance Method Summary collapse
-
#initialize(attributes, configuration = ProoflinkConnect.config) ⇒ Invite
constructor
A new instance of Invite.
- #person ⇒ Object
- #save(params = {}) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(attributes, configuration = ProoflinkConnect.config) ⇒ Invite
Returns a new instance of Invite.
10 11 12 13 |
# File 'lib/prooflink_connect/invite.rb', line 10 def initialize(attributes, configuration = ProoflinkConnect.config) @attributes = attributes.stringify_keys @configuration = configuration end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/prooflink_connect/invite.rb', line 7 def attributes @attributes end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
7 8 9 |
# File 'lib/prooflink_connect/invite.rb', line 7 def configuration @configuration end |
#locale ⇒ Object
Returns the value of attribute locale.
8 9 10 |
# File 'lib/prooflink_connect/invite.rb', line 8 def locale @locale end |
Instance Method Details
#person ⇒ Object
34 35 36 |
# File 'lib/prooflink_connect/invite.rb', line 34 def person @person ||= ProoflinkConnect::PortableContacts::Person.new(attributes) end |
#save(params = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/prooflink_connect/invite.rb', line 15 def save(params = {}) return false if created? uri = configuration.base_uri + "/invites" params.reverse_merge! "invite" => attributes, "api_key" => configuration.api_key, "locale" => locale || 'nl' response = HTTParty.post(uri, :body => params) if response.code == 200 self.attributes.merge! MultiJson.load(response.body)["entry"].stringify_keys end return created? end |
#url ⇒ Object
30 31 32 |
# File 'lib/prooflink_connect/invite.rb', line 30 def url attributes["invite_url"] if created? end |