Class: EmailDirect::ShortUrl

Inherits:
Object
  • Object
show all
Defined in:
lib/emaildirect/short_url.rb

Overview

Represents a short url and associated functionality

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_urlObject (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(options = {})
  response = EmailDirect.get uri, :query => options
  Hashie::Mash.new(response)
end

.create(url) ⇒ Object



13
14
15
16
17
# File 'lib/emaildirect/short_url.rb', line 13

def create(url)
  options = { :Url => url }
  response = EmailDirect.post uri, :body => options.to_json
  Hashie::Mash.new(response)
end

.uriObject



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(options = {})
  options.merge! :url => short_url
  response = EmailDirect.get '/ShortUrls/Clicks', :query => options
  Hashie::Mash.new(response)
end

#detailsObject



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