class Pavlok::Web
Constants
- API_PATH
- HOST
Public Class Methods
call(stimulus, token)
click to toggle source
# File lib/pavlok/web.rb, line 10 def self.call(stimulus, token) attempt = self.new(stimulus, token) attempt.call end
new(stimulus, token)
click to toggle source
# File lib/pavlok/web.rb, line 15 def initialize(stimulus, token) @stimulus, @token = stimulus, token end
Public Instance Methods
call()
click to toggle source
# File lib/pavlok/web.rb, line 19 def call response = post end
client()
click to toggle source
# File lib/pavlok/web.rb, line 28 def client @client = Net::HTTP end
data()
click to toggle source
# File lib/pavlok/web.rb, line 44 def data @stimulus.data.to_json end
headers()
click to toggle source
# File lib/pavlok/web.rb, line 48 def headers { "Content-Type" => "application/json", "Authorization" => "Bearer #{@token}" } end
host()
click to toggle source
# File lib/pavlok/web.rb, line 36 def host HOST end
path()
click to toggle source
# File lib/pavlok/web.rb, line 40 def path [API_PATH, @stimulus.kind, @stimulus.value].join("/") end
post()
click to toggle source
# File lib/pavlok/web.rb, line 23 def post puts url client.post(url, data, headers) end
url()
click to toggle source
# File lib/pavlok/web.rb, line 32 def url URI([host, path].join("/")) end