Class: Relinkly::API
- Inherits:
-
Object
- Object
- Relinkly::API
- Defined in:
- lib/relinkly/api.rb
Constant Summary collapse
- API_VERSION =
'v1'- BASE_URL =
"https://api.rebrandly.com/#{API_VERSION}"
Instance Method Summary collapse
-
#account ⇒ Object
GET /v1/account.
-
#add_scripts_link(id, script, options = {}) ⇒ Object
POST /v1/links/:id/scripts/:script.
-
#add_tags_link(id, tag, options = {}) ⇒ Object
POST /v1/links/:id/tags/:tag.
-
#delete_link(id, options = {}) ⇒ Object
DELETE /v1/links/:id.
-
#delete_links(options = {}) ⇒ Object
DELETE /v1/links.
-
#delete_scripts_link(id, script, options = {}) ⇒ Object
DELETE /v1/links/:id/scripts/:script.
-
#delete_tag(id, options = {}) ⇒ Object
DELETE /v1/tags/:id.
-
#delete_tags_link(id, tag, options = {}) ⇒ Object
DELETE /v1/links/:id/tags/:tag.
-
#domain(id) ⇒ Object
GET /v1/domains/:id.
-
#domain_count(_options = {}) ⇒ Object
GET /v1/domains/count.
-
#domains(options = {}) ⇒ Object
GET /v1/domains.
-
#link(id) ⇒ Object
GET /v1/links/:id.
-
#link_count(_options = {}) ⇒ Object
GET /v1/links/count.
-
#links(options = {}) ⇒ Object
GET /v1/links.
-
#new_tag(destination, options = {}) ⇒ Object
POST /v1/tags.
-
#script(id) ⇒ Object
GET /v1/scripts/:id.
-
#script_count(_options = {}) ⇒ Object
GET /v1/scripts/count.
-
#scripts(options = {}) ⇒ Object
GET /v1/scripts.
-
#scripts_link(id, options = {}) ⇒ Object
GET /v1/links/:id/scripts.
-
#shorten(destination, options = {}) ⇒ Object
POST /v1/links.
-
#tag(id) ⇒ Object
GET /v1/tags/:id.
-
#tag_count(_options = {}) ⇒ Object
GET /v1/tags/count.
-
#tags(options = {}) ⇒ Object
GET /v1/tags.
-
#tags_link(id, options = {}) ⇒ Object
GET /v1/links/:id/tags.
-
#update_link(id, options = {}) ⇒ Object
POST /v1/links/:id.
-
#update_tag(id, options = {}) ⇒ Object
POST /v1/tags/:id.
-
#workspaces(options = {}) ⇒ Object
GET /v1/account/workspaces.
Instance Method Details
#account ⇒ Object
GET /v1/account
24 25 26 |
# File 'lib/relinkly/api.rb', line 24 def account Creator.new(relinkly_request(:get, 'account')) end |
#add_scripts_link(id, script, options = {}) ⇒ Object
POST /v1/links/:id/scripts/:script
160 161 162 |
# File 'lib/relinkly/api.rb', line 160 def add_scripts_link(id, script, = {}) Link.new(relinkly_request(:post, "/links/#{id}/scripts/#{script}", )) end |
#add_tags_link(id, tag, options = {}) ⇒ Object
POST /v1/links/:id/tags/:tag
145 146 147 |
# File 'lib/relinkly/api.rb', line 145 def (id, tag, = {}) Link.new(relinkly_request(:post, "/links/#{id}/tags/#{tag}", )) end |
#delete_link(id, options = {}) ⇒ Object
DELETE /v1/links/:id
130 131 132 |
# File 'lib/relinkly/api.rb', line 130 def delete_link(id, = {}) Link.new(relinkly_request(:delete, "links/#{id}", )) end |
#delete_links(options = {}) ⇒ Object
DELETE /v1/links
135 136 137 |
# File 'lib/relinkly/api.rb', line 135 def delete_links( = {}) Link.new(relinkly_request(:delete, 'links', )) end |
#delete_scripts_link(id, script, options = {}) ⇒ Object
DELETE /v1/links/:id/scripts/:script
165 166 167 |
# File 'lib/relinkly/api.rb', line 165 def delete_scripts_link(id, script, = {}) Link.new(relinkly_request(:delete, "/links/#{id}/scripts/#{script}", )) end |
#delete_tag(id, options = {}) ⇒ Object
DELETE /v1/tags/:id
94 95 96 |
# File 'lib/relinkly/api.rb', line 94 def delete_tag(id, = {}) Tag.new(relinkly_request(:delete, "tags/#{id}", )) end |
#delete_tags_link(id, tag, options = {}) ⇒ Object
DELETE /v1/links/:id/tags/:tag
150 151 152 |
# File 'lib/relinkly/api.rb', line 150 def (id, tag, = {}) Link.new(relinkly_request(:delete, "/links/#{id}/tags/#{tag}", )) end |
#domain(id) ⇒ Object
GET /v1/domains/:id
53 54 55 |
# File 'lib/relinkly/api.rb', line 53 def domain(id) Domain.new(relinkly_request(:get, "domains/#{id}")) end |
#domain_count(_options = {}) ⇒ Object
GET /v1/domains/count
58 59 60 |
# File 'lib/relinkly/api.rb', line 58 def domain_count( = {}) relinkly_request(:get, 'domains/count')['count'] end |
#domains(options = {}) ⇒ Object
GET /v1/domains
47 48 49 50 |
# File 'lib/relinkly/api.rb', line 47 def domains( = {}) all_domains = relinkly_request(:get, 'domains', ) all_domains.map { |domain| Domain.new(domain) } end |
#link(id) ⇒ Object
GET /v1/links/:id
109 110 111 |
# File 'lib/relinkly/api.rb', line 109 def link(id) Link.new(relinkly_request(:get, "links/#{id}")) end |
#link_count(_options = {}) ⇒ Object
GET /v1/links/count
114 115 116 |
# File 'lib/relinkly/api.rb', line 114 def link_count( = {}) relinkly_request(:get, 'links/count')['count'] end |
#links(options = {}) ⇒ Object
GET /v1/links
103 104 105 106 |
# File 'lib/relinkly/api.rb', line 103 def links( = {}) all_links = relinkly_request(:get, 'links', ) all_links.map { |link| Link.new(link) } end |
#new_tag(destination, options = {}) ⇒ Object
POST /v1/tags
83 84 85 86 |
# File 'lib/relinkly/api.rb', line 83 def new_tag(destination, = {}) [:destination] = destination Tag.new(relinkly_request(:post, 'tags', )) end |
#script(id) ⇒ Object
GET /v1/scripts/:id
180 181 182 |
# File 'lib/relinkly/api.rb', line 180 def script(id) Script.new(relinkly_request(:get, "scripts/#{id}")) end |
#script_count(_options = {}) ⇒ Object
GET /v1/scripts/count
185 186 187 |
# File 'lib/relinkly/api.rb', line 185 def script_count( = {}) relinkly_request(:get, 'scripts/count')['count'] end |
#scripts(options = {}) ⇒ Object
GET /v1/scripts
174 175 176 177 |
# File 'lib/relinkly/api.rb', line 174 def scripts( = {}) all_scripts = relinkly_request(:get, 'scripts', ) all_scripts.map { |script| Script.new(script) } end |
#scripts_link(id, options = {}) ⇒ Object
GET /v1/links/:id/scripts
155 156 157 |
# File 'lib/relinkly/api.rb', line 155 def scripts_link(id, = {}) Link.new(relinkly_request(:get, "/links/#{id}/scripts", )) end |
#shorten(destination, options = {}) ⇒ Object
POST /v1/links
119 120 121 122 |
# File 'lib/relinkly/api.rb', line 119 def shorten(destination, = {}) [:destination] = destination Link.new(relinkly_request(:post, 'links', )) end |
#tag(id) ⇒ Object
GET /v1/tags/:id
73 74 75 |
# File 'lib/relinkly/api.rb', line 73 def tag(id) Tag.new(relinkly_request(:get, "tags/#{id}")) end |
#tag_count(_options = {}) ⇒ Object
GET /v1/tags/count
78 79 80 |
# File 'lib/relinkly/api.rb', line 78 def tag_count( = {}) relinkly_request(:get, 'tags/count')['count'] end |
#tags(options = {}) ⇒ Object
GET /v1/tags
67 68 69 70 |
# File 'lib/relinkly/api.rb', line 67 def ( = {}) = relinkly_request(:get, 'tags', ) .map { |tag| Tag.new(tag) } end |
#tags_link(id, options = {}) ⇒ Object
GET /v1/links/:id/tags
140 141 142 |
# File 'lib/relinkly/api.rb', line 140 def (id, = {}) Link.new(relinkly_request(:get, "/links/#{id}/tags", )) end |
#update_link(id, options = {}) ⇒ Object
POST /v1/links/:id
125 126 127 |
# File 'lib/relinkly/api.rb', line 125 def update_link(id, = {}) Link.new(relinkly_request(:post, "links/#{id}", )) end |
#update_tag(id, options = {}) ⇒ Object
POST /v1/tags/:id
89 90 91 |
# File 'lib/relinkly/api.rb', line 89 def update_tag(id, = {}) Tag.new(relinkly_request(:post, "tags/#{id}", )) end |
#workspaces(options = {}) ⇒ Object
GET /v1/account/workspaces
33 34 35 36 |
# File 'lib/relinkly/api.rb', line 33 def workspaces( = {}) all_workspaces = relinkly_request(:get, 'workspaces', ) all_workspaces.map { |workspace| Workspace.new(workspace) } end |