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



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

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

POST /v1/links/:id/scripts/:script



160
161
162
# File 'lib/relinkly/api.rb', line 160

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

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



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

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

DELETE /v1/links/:id



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

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

DELETE /v1/links



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

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

DELETE /v1/links/:id/scripts/:script



165
166
167
# File 'lib/relinkly/api.rb', line 165

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



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

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

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



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

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



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(_options = {})
  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(options = {})
  all_domains = relinkly_request(:get, 'domains', options)
  all_domains.map { |domain| Domain.new(domain) }
end

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

GET /v1/links/count



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

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

GET /v1/links



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

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



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

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

GET /v1/links/:id/scripts



155
156
157
# File 'lib/relinkly/api.rb', line 155

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

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

POST /v1/links



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

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

GET /v1/links/:id/tags



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

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

POST /v1/links/:id



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

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

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

POST /v1/tags/:id



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

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

#workspaces(options = {}) ⇒ Object

GET /v1/account/workspaces



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

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