Rdwu

Client for Redirect Web URL

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add rdwu

If bundler is not being used to manage dependencies, install the gem by executing:

gem install rdwu

Setup

In the environment variable set the followings

RDWU_ENABLED=true
RDWU_API_KEY=
RDWU_HOST=http://localhost:3004
RDWU_TIMEOUT_SECONDS=3

Usage

List

rdwu = Rdwu::Api.new
rdwu.list
[
  {
    "id" => "0198cf30-f234-708e-afd1-d5a96c270a97",
    "type" => "web_redirect",
    "attributes" => {
      "id" => "0198cf30-f234-708e-afd1-d5a96c270a97",
      "name" => "Test ma",
      "to_url" => "http://adawd.com",
      "is_permanent" => false,
      "is_enabled" => true,
      "expires_on" => nil,
      "external_link" => "http://localhost:3000/0198cf30-f234-708e-afd1-d5a96c270a97"
    }
  }
]

Find

rdwu = Rdwu::Api.new
rdwu.find('http://adawd.com')
{
  "id" => "0198cf30-f234-708e-afd1-d5a96c270a97",
  "type" => "web_redirect",
  "attributes" => {
    "id" => "0198cf30-f234-708e-afd1-d5a96c270a97",
    "name" => "Test ma",
    "to_url" => "http://adawd.com",
    "is_permanent" => false,
    "is_enabled" => true,
    "expires_on" => nil,
    "external_link" => "http://localhost:3000/0198cf30-f234-708e-afd1-d5a96c270a97"
  }
}

Retrieve

rdwu = Rdwu::Api.new
rdwu.retrieve('0198cf30-f234-708e-afd1-d5a96c270a97')
{
  "id" => "0198cf30-f234-708e-afd1-d5a96c270a97",
  "type" => "web_redirect",
  "attributes" => {
    "id" => "0198cf30-f234-708e-afd1-d5a96c270a97",
    "name" => "Test ma",
    "to_url" => "http://adawd.com",
    "is_permanent" => false,
    "is_enabled" => true,
    "expires_on" => nil,
    "external_link" => "http://localhost:3000/0198cf30-f234-708e-afd1-d5a96c270a97"
  }
}

QR Code By UUID

rdwu = Rdwu::Api.new
rdwu.qrcode_by_uuid('0198d708-6982-70eb-a2b9-fb710e1d7fcf')

QR Code PNG

rdwu = Rdwu::Api.new
png_blob = rdwu.qrcode_to_png(uuid)
@png_blob = "data:image/png;base64,#{png_blob}"

View

%div.text-center
  = image_tag(@png_blob, class: 'rounded qrcode-image', alt: 'QR Code')

Create

rdwu = Rdwu::Api.new
rdwu.create(
  {
    name: 'Test ma',
    to_url: 'http://adawd.com',
    is_permanent: false,
    is_enabled: true,
    expires_on: nil
  }
)

Update

rdwu = Rdwu::Api.new
rdwu.update(
  '0198cf30-f234-708e-afd1-d5a96c270a97',
  {
    name: 'Test ma',
    to_url: 'http://adawd.com',
    is_permanent: false,
    is_enabled: true,
    expires_on: nil
  }
)

Delete

rdwu = Rdwu::Api.new
rdwu.delete('0198cf30-f234-708e-afd1-d5a96c270a97')