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
23 24 25 |
# File 'lib/relinkly/api.rb', line 23 def account Creator.new(relinkly_request(:get, 'account')) end |
#add_scripts_link(id, script, options: {}) ⇒ Object
POST /v1/links/:id/scripts/:script
159 160 161 |
# File 'lib/relinkly/api.rb', line 159 def add_scripts_link(id, script, options: {}) Link.new(relinkly_request(:post, "/links/#{id}/scripts/#{script}", )) end |
#add_tags_link(id, tag, options: {}) ⇒ Object
POST /v1/links/:id/tags/:tag
144 145 146 |
# File 'lib/relinkly/api.rb', line 144 def (id, tag, options: {}) Link.new(relinkly_request(:post, "/links/#{id}/tags/#{tag}", )) end |
#delete_link(id, options = {}) ⇒ Object
DELETE /v1/links/:id
129 130 131 |
# File 'lib/relinkly/api.rb', line 129 def delete_link(id, = {}) Link.new(relinkly_request(:delete, "links/#{id}", )) end |
#delete_links(options: {}) ⇒ Object
DELETE /v1/links
134 135 136 |
# File 'lib/relinkly/api.rb', line 134 def delete_links(options: {}) Link.new(relinkly_request(:delete, 'links', )) end |
#delete_scripts_link(id, script, options: {}) ⇒ Object
DELETE /v1/links/:id/scripts/:script
164 165 166 |
# File 'lib/relinkly/api.rb', line 164 def delete_scripts_link(id, script, options: {}) Link.new(relinkly_request(:delete, "/links/#{id}/scripts/#{script}", )) end |
#delete_tag(id, options: {}) ⇒ Object
DELETE /v1/tags/:id
93 94 95 |
# File 'lib/relinkly/api.rb', line 93 def delete_tag(id, options: {}) Tag.new(relinkly_request(:delete, "tags/#{id}", )) end |
#delete_tags_link(id, tag, options: {}) ⇒ Object
DELETE /v1/links/:id/tags/:tag
149 150 151 |
# File 'lib/relinkly/api.rb', line 149 def (id, tag, options: {}) Link.new(relinkly_request(:delete, "/links/#{id}/tags/#{tag}", )) end |
#domain(id) ⇒ Object
GET /v1/domains/:id
52 53 54 |
# File 'lib/relinkly/api.rb', line 52 def domain(id) Domain.new(relinkly_request(:get, "domains/#{id}")) end |
#domain_count(_options: {}) ⇒ Object
GET /v1/domains/count
57 58 59 |
# File 'lib/relinkly/api.rb', line 57 def domain_count(_options: {}) relinkly_request(:get, 'domains/count')['count'] end |
#domains(options: {}) ⇒ Object
GET /v1/domains
46 47 48 49 |
# File 'lib/relinkly/api.rb', line 46 def domains(options: {}) all_domains = relinkly_request(:get, 'domains', ) all_domains.map { |domain| Domain.new(domain) } end |
#link(id) ⇒ Object
GET /v1/links/:id
108 109 110 |
# File 'lib/relinkly/api.rb', line 108 def link(id) Link.new(relinkly_request(:get, "links/#{id}")) end |
#link_count(_options = {}) ⇒ Object
GET /v1/links/count
113 114 115 |
# File 'lib/relinkly/api.rb', line 113 def link_count( = {}) relinkly_request(:get, 'links/count')['count'] end |
#links(options: {}) ⇒ Object
GET /v1/links
102 103 104 105 |
# File 'lib/relinkly/api.rb', line 102 def links(options: {}) all_links = relinkly_request(:get, 'links', ) all_links.map { |link| Link.new(link) } end |
#new_tag(destination, options: {}) ⇒ Object
POST /v1/tags
82 83 84 85 |
# File 'lib/relinkly/api.rb', line 82 def new_tag(destination, options: {}) [:destination] = destination Tag.new(relinkly_request(:post, 'tags', )) end |
#script(id) ⇒ Object
GET /v1/scripts/:id
179 180 181 |
# File 'lib/relinkly/api.rb', line 179 def script(id) Script.new(relinkly_request(:get, "scripts/#{id}")) end |
#script_count(_options: {}) ⇒ Object
GET /v1/scripts/count
184 185 186 |
# File 'lib/relinkly/api.rb', line 184 def script_count(_options: {}) relinkly_request(:get, 'scripts/count')['count'] end |
#scripts(options: {}) ⇒ Object
GET /v1/scripts
173 174 175 176 |
# File 'lib/relinkly/api.rb', line 173 def scripts(options: {}) all_scripts = relinkly_request(:get, 'scripts', ) all_scripts.map { |script| Script.new(script) } end |
#scripts_link(id, options: {}) ⇒ Object
GET /v1/links/:id/scripts
154 155 156 |
# File 'lib/relinkly/api.rb', line 154 def scripts_link(id, options: {}) Link.new(relinkly_request(:get, "/links/#{id}/scripts", )) end |
#shorten(destination, options: {}) ⇒ Object
POST /v1/links
118 119 120 121 |
# File 'lib/relinkly/api.rb', line 118 def shorten(destination, options: {}) [:destination] = destination Link.new(relinkly_request(:post, 'links', )) end |
#tag(id) ⇒ Object
GET /v1/tags/:id
72 73 74 |
# File 'lib/relinkly/api.rb', line 72 def tag(id) Tag.new(relinkly_request(:get, "tags/#{id}")) end |
#tag_count(_options: {}) ⇒ Object
GET /v1/tags/count
77 78 79 |
# File 'lib/relinkly/api.rb', line 77 def tag_count(_options: {}) relinkly_request(:get, 'tags/count')['count'] end |
#tags(options: {}) ⇒ Object
GET /v1/tags
66 67 68 69 |
# File 'lib/relinkly/api.rb', line 66 def (options: {}) = relinkly_request(:get, 'tags', ) .map { |tag| Tag.new(tag) } end |
#tags_link(id, options = {}) ⇒ Object
GET /v1/links/:id/tags
139 140 141 |
# File 'lib/relinkly/api.rb', line 139 def (id, = {}) Link.new(relinkly_request(:get, "/links/#{id}/tags", )) end |
#update_link(id, options = {}) ⇒ Object
POST /v1/links/:id
124 125 126 |
# File 'lib/relinkly/api.rb', line 124 def update_link(id, = {}) Link.new(relinkly_request(:post, "links/#{id}", )) end |