Sha256: e066b12889b1d7d61cf0ccccd5656837ef279e5e1a20dcdd4edaeef72b297631
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module Slapi class Client def initialize(base_url, access_token = nil) @base_url = base_url @access_token = access_token @authentication = Slapi::Authentication.new(@base_url) @content_type = 'application/x-www-form-urlencoded' @request_header = { 'Authorization' => "Bearer #{@access_token}", 'Content-Type' => @content_type, 'Accept' => 'application/json', } url = URI.parse("#{@base_url}") @https = Net::HTTP.new(url.host, url.port) @https.use_ssl = true end def authenticate!(client_id, client_secret) @authentication.authenticate!(client_id, client_secret) @access_token = @authentication.access_token @request_header = { 'Authorization' => "Bearer #{@access_token}", 'Content-Type' => 'x-www-form-urlencoded', 'Accept' => 'application/json', } end def get(path, params = "") url = URI.parse("#{@base_url}/#{path}?#{params}") response = @https.get(url, @request_header) JSON.parse(response.body) end def post(path, params = "") # TODO 実装 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slapi-0.1.1 | lib/slapi/client.rb |