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



62
63
64
# File 'lib/rebrandly/api.rb', line 62

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

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

DELETE /v1/links/:id



41
42
43
# File 'lib/rebrandly/api.rb', line 41

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

#domain(id) ⇒ Object

GET /v1/domains/:id



52
53
54
# File 'lib/rebrandly/api.rb', line 52

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

#domain_count(options = {}) ⇒ Object

GET /v1/domains/count



57
58
59
# File 'lib/rebrandly/api.rb', line 57

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

#domains(options = {}) ⇒ Object

GET /v1/domains



46
47
48
49
# File 'lib/rebrandly/api.rb', line 46

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

GET /v1/links/:id



15
16
17
# File 'lib/rebrandly/api.rb', line 15

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

GET /v1/links/count



20
21
22
# File 'lib/rebrandly/api.rb', line 20

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

GET /v1/links



9
10
11
12
# File 'lib/rebrandly/api.rb', line 9

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

GET /v1/links/new



25
26
27
# File 'lib/rebrandly/api.rb', line 25

def new_link(options={})
  Link.new(rebrandly_request(:get, 'links/new', options))
end

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

POST /v1/links



30
31
32
33
# File 'lib/rebrandly/api.rb', line 30

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

POST /v1/links/:id



36
37
38
# File 'lib/rebrandly/api.rb', line 36

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