breim / short_url

Authenticated short url generator via api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Short Url

By Chiligumvideos

Is a small app to gerenate short url via authenticated api. You can use this gem(urli_me) together

Instalation

Clone repo

git clone https://github.com/chiligumdev/short_url

Install dependencies

bundle install

Install figaro and configure domain (check application.yml.example)

figaro install

Create database

rake db:migrate && rake db:migrate

Create a user and generate credentials.

Update user to use api

$ rails console
User.last.update(disabled: false)

Endpoints

Required libs to test endpoint and credential

require 'HTTParty'
require 'json'

headers = {
	"key" => "YOUR key",
	"pwd" => "YOUR pwd",
	'Content-Type' => 'multipart/form-data'
}

[GET] Get Links

HTTParty.get("http://localhost:3000/api/links", headers: headers)

return

{"id"=>48, "original_url"=>"http://google.com/", "short_url"=>"http://urlcurta.com/324cce", "token"=>"324cce", "created_at"=>"2017-05-23T23:22:33.347Z"}

[POST] Create Links

HTTParty.post('http://localhost:3000/api/links', :query => {
	link: {
		original_url: 'http://google.com/'
	}},
  headers: headers)

return

{"id":67,"original_url":"http://google.com/","short_url":"https://shor_url.com/7df540","token":"7df540","created_at":"2017-05-24T22:54:47.234Z"}

[GET] Get Link

Pass token as param

HTTParty.get("http://localhost:3000/api/links/7df540", headers: headers)

return

{"id":67,"original_url":"http://google.com/","short_url":"https://shor_url.com/7df540","token":"7df540","created_at":"2017-05-24T22:54:47.234Z"}

[PATCH] Update Link

Pass token as param

HTTParty.patch("http://localhost:3000/api/links/7df540", :query => {
	link: {
		original_url: 'http://gmail.com/'
	}},
headers: headers)

return

{"id":67,"original_url":"http://gmail.com/","short_url":"https://shor_url.com/7df540","token":"7df540","created_at":"2017-05-24T22:54:47.234Z"}

[DELETE] Delete Link

HTTParty.delete("http://localhost:3000/api/links/#{id}", headers: headers)

return

{"msg":"deleted"}

About

Authenticated short url generator via api


Languages

Language:Ruby 78.3%Language:HTML 16.8%Language:CSS 3.3%Language:JavaScript 1.6%