class Qiita::Sdk::Client
Constants
- API_BASE_URL
Attributes
access_token[RW]
@return [String]
Public Class Methods
new(options = {}) { |self| ... }
click to toggle source
# File lib/qiita/sdk/client.rb, line 15 def initialize(options = {}) options.each do |key, value| instance_variable_set("@#{key}", value) end yield(self) if block_given? end
Public Instance Methods
credential()
click to toggle source
# File lib/qiita/sdk/client.rb, line 22 def credential "Bearer #{@access_token}" if @access_token end
delete(path)
click to toggle source
# File lib/qiita/sdk/client.rb, line 59 def delete(path) url = endpoint + path httpclient = HTTPClient.new httpclient.delete(url) end
endpoint()
click to toggle source
# File lib/qiita/sdk/client.rb, line 65 def endpoint @endpoint ||= API_BASE_URL end
get(path, params = {})
click to toggle source
# File lib/qiita/sdk/client.rb, line 35 def get(path, params = {}) url = endpoint + path httpclient = HTTPClient.new httpclient.get(url, params, headers) end
headers()
click to toggle source
# File lib/qiita/sdk/client.rb, line 26 def headers headers = { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } headers['Authorization'] = credential if credential headers end
patch(path, params = {})
click to toggle source
# File lib/qiita/sdk/client.rb, line 41 def patch(path, params = {}) url = endpoint + path httpclient = HTTPClient.new httpclient.patch(url, params.to_json, headers) end
post(path, params = {})
click to toggle source
# File lib/qiita/sdk/client.rb, line 53 def post(path, params = {}) url = endpoint + path httpclient = HTTPClient.new httpclient.post(url, params.to_json, headers) end
put(path, params = {})
click to toggle source
# File lib/qiita/sdk/client.rb, line 47 def put(path, params = {}) url = endpoint + path httpclient = HTTPClient.new httpclient.put(url, params) end