Skip to content
This repository has been archived by the owner on Dec 25, 2019. It is now read-only.
/ ok_linker Public archive

Ruby gem for Odnoklassniki's URL shortening service okey.link.

License

Notifications You must be signed in to change notification settings

bodrovis/ok_linker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OkLinker

Gem Version Build Status Code Climate

Ruby gem to work with Odnoklassniki's URL shortening service okey.link. Tested against Ruby 2.0, 2.1, 2.2 and 2.3.

Installation

Via RubyGems:

$ gem install ok_linker

Or add it to your Gemfile:

gem 'ok_linker' 

Usage

Prerequisites

First of all, you will require access to okey.link. Fill in this submission form to gain access.

After logging in, copy your API access token from the API section. This token has unlimited lifetime and has to be stored securely.

Instantiating a Client

Create a new client by typing

client = OkLinker::Client.new(opts)

or simply with

client = OkLinker.new(opts)

You can now call OkLinker's methods.

Configuration

OkLinker does not require much configuration. The only thing that you need to provide is your access token. You can either use an initializer (for example, ok_linker.rb):

OkLinker.configure do |c|
  c.access_token = 'Your token'
end

or provide it when instantiating a new client:

client = OkLinker::Client.new(access_token: 'Your token')

Calling methods

You can read more about available methods here.

OkLinker provides the following conventional methods:

shorten(url)        # Shorten a given URL

hide(url)           # Hide a URL that was previously shorten

clicks(url)         # Get clicks statistics for the given URL

urls(params)        # Get a list of shortened URLs.
                    # Allowed options:
                    ## :epp  - integer, optional. Elements per page. Default is 20.
                    ## :page - integer, optional. Page to fetch. Default is 1.

Also, you can call raw methods:

get(method, params = {}, &block)

post(method, params = {}, &block)

For example,

client.get('get-urls', page: 2)

These methods always return JSON or one of the errors listed here.

Testing

Rename .env.sample to .env and assign OKEY_LINK_KEY to your API key. This file is excluded from version control, so your token won't be exposed.

Then run

$ bundle exec rspec .

License

Licensed under the MIT License.

Copyright (c) 2016 Ilya Bodrov

About

Ruby gem for Odnoklassniki's URL shortening service okey.link.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages