Hiya
iiil.io SDK
Installation
You can add it to your Gemfile with:
$ gem install hiya
Configure
Override any of these defaults in config/initializers/clearance.rb
:
Hiya.configure do |config|
config.api_url = 'https://api.iiil.io/v1'
config.source = 'api'
end
Usage
URL - create URL short link
links = [
{ url: 'https://www.google.coom', weight: 1 }
]
Hiya::Url.new.create(links)
Image - create images short link
files = [
'/Users/username/Desktop/aaa.jpg',
'/Users/username/Desktop/bbb.png',
'/Users/username/Desktop/ccc.gif'
]
Hiya::Image.new.create(files, {
attach: {
password: '1234',
password_note: 'today',
expired_num: 300,
view_count_limit: 100
},
post: {
content: "haha\nhttps://www.google.com"
}
})
Video - create videos short link
files = [
'/Users/username/Desktop/aaa.mp4',
'/Users/username/Desktop/bbb.mp4'
]
Hiya::Video.new.create(files, {
attach: {
password: '1234',
password_note: 'today',
expired_num: 300,
view_count_limit: 100
},
post: {
content: "yoyo\nhttps://www.google.com"
}
})
Audio - create audios short link
files = [
'/Users/username/Desktop/aaa.mp3',
'/Users/username/Desktop/bbb.mp3',
'/Users/username/Desktop/ccc.mp3'
]
Hiya::Audio.new.create(files, {
attach: {
password: '1234',
password_note: 'today',
expired_num: 300,
view_count_limit: 100
},
post: {
content: "hehe\nhttps://www.google.com"
}
})
Login - get token
params = {
grant_type: 'password',
facebook_token: '<facebook_token>',
google_token: '<google_token>',
google_refresh_token: '<google_refresh_token>',
line_token: '<line_token>',
chatbot_token: '<chatbot_token>',
}
response = Hiya::Oauth.new.token(params)
puts response
{
access_token: '-qsizxNy83YTh7kdnZ7f20mKpty00-G0SidjWitGj0g',
token_type: 'Bearer',
created_at: 1688109992
}
links = [
{ url: 'https://www.google.coom', weight: 1 }
]
Hiya::Url.new(response[:token]).create(links)
Get links
Hiya::Users::Links.new(response[:token]).all
Get link
Hiya::Users::Links.new(response[:token]).find(code)
Get link analytic
Hiya::Users::Links.new(response[:token]).analytic(code)
Append files attach to link
files = [
'/Users/username/Desktop/aaa.jpg',
'/Users/username/Desktop/bbb.png',
'/Users/username/Desktop/ccc.gif'
]
Hiya::Users::Links.new(response[:token]).attach_files(code, files)
Update attach to link
params = {
attach: {
password: 'kopi',
password_note: 'こぴ / kopi',
view_count_limit: 9999
},
post: {
content: "こぴ / kopi\nhttps://youtu.be/kmPgjr0EL64"
}
}
Hiya::Users::Links.new(response[:token]).update(code, params)
Update IP info to link
params = {
ip: String: "125.227.100.100",
hostname: String: "125-227-100-100.hinet-ip.hinet.net",
city: String: "Taipei",
region: String: "Taiwan",
country: String: "TW",
loc: String: "25.0418,121.5359",
org: String: "AS3462 Data Communication Business Group",
timezone: String: "Asia/Taipei"
}
Hiya::Users::Links.new(response[:token]).update_ip_info(code, params)
Destroy link
Hiya::Users::Links.new(response[:token]).destroy(code)
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/iiil-io/hiya.
License
The gem is available as open source under the terms of the MIT License.