Class: Gumrider::Link
- Inherits:
-
Object
- Object
- Gumrider::Link
- Defined in:
- lib/gumrider.rb
Instance Attribute Summary collapse
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Returns the value of attribute description.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
-
#short_url ⇒ Object
Returns the value of attribute short_url.
-
#token ⇒ Object
Returns the value of attribute token.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(id, token, endpoint) ⇒ Link
constructor
A new instance of Link.
- #save ⇒ Object
Constructor Details
#initialize(id, token, endpoint) ⇒ Link
Returns a new instance of Link.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/gumrider.rb', line 58 def initialize(id, token, endpoint) @token = token @endpoint = endpoint if id response = Crack::JSON.parse Http.with(:Authorization => 'Basic ' + token).get endpoint + '/links/' + id if response["success"] @name = response["link"]["name"] @url = response["link"]["url"] @price = response["link"]["price"] / 100 @description = response["link"]["description"] @currency = response["link"]["currency"] @short_url = response["link"]["short_url"] @id = id end end end |
Instance Attribute Details
#currency ⇒ Object
Returns the value of attribute currency.
56 57 58 |
# File 'lib/gumrider.rb', line 56 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
56 57 58 |
# File 'lib/gumrider.rb', line 56 def description @description end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
56 57 58 |
# File 'lib/gumrider.rb', line 56 def endpoint @endpoint end |
#id ⇒ Object
Returns the value of attribute id.
56 57 58 |
# File 'lib/gumrider.rb', line 56 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
56 57 58 |
# File 'lib/gumrider.rb', line 56 def name @name end |
#price ⇒ Object
Returns the value of attribute price.
56 57 58 |
# File 'lib/gumrider.rb', line 56 def price @price end |
#short_url ⇒ Object
Returns the value of attribute short_url.
56 57 58 |
# File 'lib/gumrider.rb', line 56 def short_url @short_url end |
#token ⇒ Object
Returns the value of attribute token.
56 57 58 |
# File 'lib/gumrider.rb', line 56 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
56 57 58 |
# File 'lib/gumrider.rb', line 56 def url @url end |
Instance Method Details
#delete ⇒ Object
86 87 88 89 90 |
# File 'lib/gumrider.rb', line 86 def delete response = Crack::JSON.parse Http.with(:Authorization => 'Basic ' + @token).delete @endpoint + '/links/' + @id !!response["success"] end |
#save ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/gumrider.rb', line 78 def save if @id update else create end end |