Sha256: 1b0dd2590dec51b94922fceda9afb6764883e8f4cdfa7d40c075b0cb1e30450d
Contents?: true
Size: 613 Bytes
Versions: 3
Compression:
Stored size: 613 Bytes
Contents
require 'net/http' require 'uri' class ApiClient class ArgumentError < StandardError; end attr_reader :http, :uri def initialize @uri = URI.parse("https://notify-api.line.me/api/notify") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true @http = http end def message(token, message) token ||= ENV['LINE_NOTIFY_TOKEN'] raise ArgumentError if token.nil? || message.nil? req = Net::HTTP::Post.new uri req["Authorization"] = "Bearer #{token}" req.set_form_data(message: message) res = http.start { |http| http.request req } return res.body end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
line-notify-client-1.0.2 | lib/line-notify-client/api_client.rb |
line-notify-client-1.0.1 | lib/line-notify-client/api_client.rb |
line-notify-client-1.0.0 | lib/line_notify_client/api_client.rb |