Sha256: cf5389bd0fd885a492f37b30a6db0b42380fc37c6e280f6ba390acc50afbcee5

Contents?: true

Size: 663 Bytes

Versions: 1

Compression:

Stored size: 663 Bytes

Contents

require 'line_notify/version'
require 'net/https'

module LineNotify
  class Client
    URI = URI.parse("https://notify-api.line.me/api/notify")

    def initialize(access_token)
      @access_token = (access_token || ENV['LINE_ACCESS_TOKEN'])
    end

    def send(options)
      request = create_request(options)
      Net::HTTP.start(URI.hostname, URI.port, use_ssl: URI.scheme == "https") do |req|
        req.request(request)
      end
    end

    private
    def create_request(options)
      request = Net::HTTP::Post.new(URI)
      request["Authorization"] = "Bearer #{@access_token}"
      request.set_form_data(options)
      request
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
line_notify-1.0.0 lib/line_notify/client.rb