Class: EmailDirect::ShortUrl
- Inherits:
-
Object
- Object
- EmailDirect::ShortUrl
- Defined in:
- lib/emaildirect/short_url.rb
Overview
Represents a short url and associated functionality
Instance Attribute Summary collapse
-
#short_url ⇒ Object
readonly
Returns the value of attribute short_url.
Class Method Summary collapse
Instance Method Summary collapse
- #clicks(options = {}) ⇒ Object
- #details ⇒ Object
-
#initialize(short_url) ⇒ ShortUrl
constructor
A new instance of ShortUrl.
- #update(new_url) ⇒ Object
Constructor Details
#initialize(short_url) ⇒ ShortUrl
Returns a new instance of ShortUrl.
26 27 28 |
# File 'lib/emaildirect/short_url.rb', line 26 def initialize(short_url) @short_url = short_url end |
Instance Attribute Details
#short_url ⇒ Object (readonly)
Returns the value of attribute short_url.
24 25 26 |
# File 'lib/emaildirect/short_url.rb', line 24 def short_url @short_url end |
Class Method Details
.all(options = {}) ⇒ Object
8 9 10 11 |
# File 'lib/emaildirect/short_url.rb', line 8 def all( = {}) response = EmailDirect.get uri, :query => Hashie::Mash.new(response) end |
.create(url) ⇒ Object
13 14 15 16 17 |
# File 'lib/emaildirect/short_url.rb', line 13 def create(url) = { :Url => url } response = EmailDirect.post uri, :body => .to_json Hashie::Mash.new(response) end |
.uri ⇒ Object
19 20 21 |
# File 'lib/emaildirect/short_url.rb', line 19 def uri '/ShortUrls' end |
Instance Method Details
#clicks(options = {}) ⇒ Object
40 41 42 43 44 |
# File 'lib/emaildirect/short_url.rb', line 40 def clicks( = {}) .merge! :url => short_url response = EmailDirect.get '/ShortUrls/Clicks', :query => Hashie::Mash.new(response) end |
#details ⇒ Object
30 31 32 33 |
# File 'lib/emaildirect/short_url.rb', line 30 def details response = EmailDirect.get self.class.uri, query Hashie::Mash.new(response) end |
#update(new_url) ⇒ Object
35 36 37 38 |
# File 'lib/emaildirect/short_url.rb', line 35 def update(new_url) response = EmailDirect.put self.class.uri, query.merge(:body => new_url.to_json) Hashie::Mash.new(response) end |