Is a small app to gerenate short url via authenticated api. You can use this gem(urli_me) together
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)
Required libs to test endpoint and credential
require 'HTTParty'
require 'json'
headers = {
"key" => "YOUR key",
"pwd" => "YOUR pwd",
'Content-Type' => 'multipart/form-data'
}
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"}
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"}
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"}
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"}
HTTParty.delete("http://localhost:3000/api/links/#{id}", headers: headers)
return
{"msg":"deleted"}