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



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

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

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}", options))
end

POST /v1/links/:id/tags/:tag



144
145
146
# File 'lib/relinkly/api.rb', line 144

def add_tags_link(id, tag, options: {})
  Link.new(relinkly_request(:post, "/links/#{id}/tags/#{tag}", options))
end

DELETE /v1/links/:id



129
130
131
# File 'lib/relinkly/api.rb', line 129

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

DELETE /v1/links



134
135
136
# File 'lib/relinkly/api.rb', line 134

def delete_links(options: {})
  Link.new(relinkly_request(:delete, 'links', options))
end

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}", options))
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}", options))
end

DELETE /v1/links/:id/tags/:tag



149
150
151
# File 'lib/relinkly/api.rb', line 149

def delete_tags_link(id, tag, options: {})
  Link.new(relinkly_request(:delete, "/links/#{id}/tags/#{tag}", options))
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', options)
  all_domains.map { |domain| Domain.new(domain) }
end

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

GET /v1/links/count



113
114
115
# File 'lib/relinkly/api.rb', line 113

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

GET /v1/links



102
103
104
105
# File 'lib/relinkly/api.rb', line 102

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



82
83
84
85
# File 'lib/relinkly/api.rb', line 82

def new_tag(destination, options: {})
  options[:destination] = destination
  Tag.new(relinkly_request(:post, 'tags', options))
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', options)
  all_scripts.map { |script| Script.new(script) }
end

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", options))
end

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

POST /v1/links



118
119
120
121
# File 'lib/relinkly/api.rb', line 118

def shorten(destination, options: {})
  options[:destination] = destination
  Link.new(relinkly_request(:post, 'links', options))
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 tags(options: {})
  all_tags = relinkly_request(:get, 'tags', options)
  all_tags.map { |tag| Tag.new(tag) }
end

GET /v1/links/:id/tags



139
140
141
# File 'lib/relinkly/api.rb', line 139

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

POST /v1/links/:id



124
125
126
# File 'lib/relinkly/api.rb', line 124

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

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

POST /v1/tags/:id



88
89
90
# File 'lib/relinkly/api.rb', line 88

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

#workspaces(options: {}) ⇒ Object

GET /v1/account/workspaces



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

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