Class: Relinkly::API

Inherits:
Object
  • Object
show all
Defined in:
lib/relinkly/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



17
18
19
# File 'lib/relinkly/api.rb', line 17

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

DELETE /v1/links/:id



111
112
113
# File 'lib/relinkly/api.rb', line 111

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

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

DELETE /v1/tags/:id



77
78
79
# File 'lib/relinkly/api.rb', line 77

def delete_tag(id, options = {})
  Tag.new(relinkly_request(:delete, "tags/#{id}", options))
end

#domain(id) ⇒ Object

GET /v1/domains/:id



38
39
40
# File 'lib/relinkly/api.rb', line 38

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

#domain_count(_options = {}) ⇒ Object

GET /v1/domains/count



43
44
45
# File 'lib/relinkly/api.rb', line 43

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

#domains(options = {}) ⇒ Object

GET /v1/domains



32
33
34
35
# File 'lib/relinkly/api.rb', line 32

def domains(options = {})
  all_domains = relinkly_request(:get, 'domains', options)
  all_domains.map { |domain| Domain.new(domain) }
end

GET /v1/links/:id



90
91
92
# File 'lib/relinkly/api.rb', line 90

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

GET /v1/links/count



95
96
97
# File 'lib/relinkly/api.rb', line 95

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

GET /v1/links



84
85
86
87
# File 'lib/relinkly/api.rb', line 84

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

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

POST /v1/tags



66
67
68
69
# File 'lib/relinkly/api.rb', line 66

def new_tag(destination, options = {})
  options[:destination] = destination
  Tag.new(relinkly_request(:post, 'tags', options))
end

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

POST /v1/links



100
101
102
103
# File 'lib/relinkly/api.rb', line 100

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

#tag(id) ⇒ Object

GET /v1/tags/:id



56
57
58
# File 'lib/relinkly/api.rb', line 56

def tag(id)
  Tag.new(relinkly_request(:get, "tags/#{id}"))
end

#tag_count(_options = {}) ⇒ Object

GET /v1/tags/count



61
62
63
# File 'lib/relinkly/api.rb', line 61

def tag_count(_options = {})
  relinkly_request(:get, 'tags/count')['count']
end

#tags(options = {}) ⇒ Object

GET /v1/tags



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

def tags(options = {})
  all_tags = relinkly_request(:get, 'tags', options)
  all_tags.map { |tag| Tag.new(tag) }
end


115
116
117
# File 'lib/relinkly/api.rb', line 115

def tags_link(id, options = {})
  Link.new(relinkly_request(:get, "/links/#{id}/tags", options))
end

POST /v1/links/:id



106
107
108
# File 'lib/relinkly/api.rb', line 106

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

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

POST /v1/tags/:id



72
73
74
# File 'lib/relinkly/api.rb', line 72

def update_tag(id, options = {})
  Tag.new(relinkly_request(:post, "tags/#{id}", options))
end

#workspaces(options = {}) ⇒ Object

GET /v1/account/workspaces



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

def workspaces(options = {})
  all_workspaces = relinkly_request(:get, 'account/workspaces', options)
  all_workspaces.map { |workspace| Workspace.new(workspace) }
end