Class: Rebrandly::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/rebrandly/api.rb

Constant Summary collapse

API_VERSION =
'v1'
BASE_URL =
"https://api.rebrandly.com/#{API_VERSION}"

Instance Method Summary collapse

Instance Method Details

#accountObject

GET /v1/account



60
61
62
# File 'lib/rebrandly/api.rb', line 60

def 
  Creator.new(rebrandly_request(:get, 'account'))
end

#delete(id, options = {}) ⇒ Object

DELETE /v1/links/:id



39
40
41
# File 'lib/rebrandly/api.rb', line 39

def delete(id, options={})
  Link.new(rebrandly_request(:delete, "links/#{id}", options))
end

#domain(id) ⇒ Object

GET /v1/domains/:id



50
51
52
# File 'lib/rebrandly/api.rb', line 50

def domain(id)
  Domain.new(rebrandly_request(:get, "domains/#{id.to_s}"))
end

#domain_count(options = {}) ⇒ Object

GET /v1/domains/count



55
56
57
# File 'lib/rebrandly/api.rb', line 55

def domain_count(options={})
  rebrandly_request(:get, 'domains/count')['count']
end

#domains(options = {}) ⇒ Object

GET /v1/domains



44
45
46
47
# File 'lib/rebrandly/api.rb', line 44

def domains(options={})
  all_domains = rebrandly_request(:get, 'domains', options)
  all_domains.map { Domain.new(all_domains.first) }
end

GET /v1/links/:id



18
19
20
# File 'lib/rebrandly/api.rb', line 18

def link(id)
  Link.new(rebrandly_request(:get, "links/#{id.to_s}"))
end

GET /v1/links/count



23
24
25
# File 'lib/rebrandly/api.rb', line 23

def link_count(options={})
  rebrandly_request(:get, 'links/count')['count']
end

GET /v1/links



12
13
14
15
# File 'lib/rebrandly/api.rb', line 12

def links(options={})
  all_links = rebrandly_request(:get, 'links', options)
  all_links.map { |link| Link.new(link) }
end

#shorten(destination, options = {}) ⇒ Object

POST /v1/links



28
29
30
31
# File 'lib/rebrandly/api.rb', line 28

def shorten(destination, options={})
  options[:destination] = destination
  Link.new(rebrandly_request(:post, 'links', options))
end

POST /v1/links/:id



34
35
36
# File 'lib/rebrandly/api.rb', line 34

def update_link(id, options={})
  Link.new(rebrandly_request(:post, "links/#{id}", options))
end