Sha256: 8360c9c5e1f6761c5859b68ac442af0ccf2523db46811c0649b91478834c88c3

Contents?: true

Size: 574 Bytes

Versions: 1

Compression:

Stored size: 574 Bytes

Contents

require_relative "version"
require_relative "url"
require "httparty"

module BlinkShortener  
  class AccessToken
    def initialize(email, password)
      @email = email
      @password = password
      @url = URL::ACCESS_TOKEN_URL
    end

    def get_token
      response = HTTParty.post(@url, body: {email: @email, password: @password}.to_json)
      case response["success"]
      when 0
        raise "Invalid Authentication: Blink email or password incorrect"
      when 1
        response["access_token"]
      end
    rescue => ex
      raise ex
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blink_shortener-0.1.7 lib/blink_shortener/access_token.rb