kutt 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/kutt.rb +63 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7568783dd14611cb8ebc5a4267fecf13c4bddc69c6f0419c3f9f2b1aec4cab8d
|
4
|
+
data.tar.gz: 41755f6f4eaccc40275de553ae4e798fdb1a00961a9f8345f1fce06bb0c7e945
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 93fdf19e4c0272e3e67131867efac3e3853c990f01b27a1b84d471f4dc1aeb78ad5cf3cd50e427077b92a96a259772d3b88505f870a7c0dd97a7fb484b0b4ed8
|
7
|
+
data.tar.gz: 5e9b30dc90a53a3b184a2ed9259f1ba74305df4cc6455b0e2640e3d9960fa88d915ac43adb7c6c0cf66c04a8cfe2a564b1418373b7b228b7497ef8374a07d3df
|
data/lib/kutt.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Kutt
|
5
|
+
def initialize(apikey)
|
6
|
+
@base_url = 'https://kutt.it'
|
7
|
+
@headers = { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-API-Key' => apikey}
|
8
|
+
return true
|
9
|
+
end
|
10
|
+
|
11
|
+
def submit(url, customurl=nil, password=nil, reuse=false)
|
12
|
+
payload = {}
|
13
|
+
payload['target'] = url
|
14
|
+
if customurl
|
15
|
+
payload['customurl'] = customurl
|
16
|
+
end
|
17
|
+
if password
|
18
|
+
payload['password'] = password
|
19
|
+
end
|
20
|
+
if reuse
|
21
|
+
payload['reuse'] = true
|
22
|
+
end
|
23
|
+
|
24
|
+
r = HTTParty.post(@base_url+'/api/url/submit',
|
25
|
+
:headers => @headers,
|
26
|
+
:body => payload.to_json)
|
27
|
+
|
28
|
+
return r.code, r.to_hash
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete(target)
|
32
|
+
url_array = target.split("/")
|
33
|
+
id = url_array.last
|
34
|
+
|
35
|
+
payload = {'id' => id}
|
36
|
+
|
37
|
+
r = HTTParty.post(@base_url+'/api/url/deleteurl',
|
38
|
+
:headers => @headers,
|
39
|
+
:body => payload.to_json)
|
40
|
+
|
41
|
+
return r.code, r.to_hash
|
42
|
+
end
|
43
|
+
|
44
|
+
def stats(target)
|
45
|
+
url_array = target.split("/")
|
46
|
+
id = url_array.last
|
47
|
+
|
48
|
+
payload = {'id' => id}
|
49
|
+
|
50
|
+
r = HTTParty.get(@base_url+'/api/url/stats',
|
51
|
+
:headers => @headers,
|
52
|
+
:query => payload)
|
53
|
+
|
54
|
+
return r.code, r.to_hash
|
55
|
+
end
|
56
|
+
|
57
|
+
def list()
|
58
|
+
r = HTTParty.get(@base_url+'/api/url/geturls',
|
59
|
+
:headers => @headers)
|
60
|
+
|
61
|
+
return r.code, r.to_hash
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kutt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Amirali Esfandiari
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: library for url shorten service kutt.it
|
14
|
+
email: amiralinull@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/kutt.rb
|
20
|
+
homepage: http://github.com/univa64/kutt.rb/
|
21
|
+
licenses:
|
22
|
+
- GPL-3.0+
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: just a library for kutt in ruby
|
44
|
+
test_files: []
|