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'

  # source: only support api/line/telegram/messenger
  config.source = 'api'
end

Usage

links = [
  { url: 'https://www.google.coom', weight: 1 }
]
Hiya::Url.new.create(links)
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"
  }
})
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"
  }
})
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', # required

  # facebook
  facebook_token: '<facebook_token>', # facebook token(String)
  # google
  google_token: '<google_token>', # google token(String)
  google_refresh_token: '<google_refresh_token>', # google refresh token(String)
  # line
  line_token: '<line_token>', # line token(String)
  # chatbot
  chatbot_token: '<chatbot_token>', # chatbot token(String)
}
response =  Hiya::Oauth.new.token(params)

puts response
{
  access_token: '-qsizxNy83YTh7kdnZ7f20mKpty00-G0SidjWitGj0g',
  token_type: 'Bearer',
  created_at: 1688109992
}

# use user token create short link
links = [
  { url: 'https://www.google.coom', weight: 1 }
]
Hiya::Url.new(response[:token]).create(links)
Hiya::Users::Links.new(response[:token]).all
Hiya::Users::Links.new(response[:token]).find(code)
Hiya::Users::Links.new(response[:token]).analytic(code)
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)
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)
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)
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.