class MediumSdk::Connection::IntegrationToken

Attributes

http[RW]
token[RW]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/medium_sdk/connection/integration_token.rb, line 9
def initialize(opts = {})
  @endpoint = 'https://api.medium.com/v1/'
  @token = opts[:integration_token] if opts.key? :integration_token
  set_client
end

Public Instance Methods

set_client() click to toggle source
# File lib/medium_sdk/connection/integration_token.rb, line 15
def set_client()
  headers = {
    'Host' => 'api.medium.com',
    'Authorization' => 'Bearer ' + @token,
    'Content-Type' => 'application/json',
    'Accept' => 'application/json',
    'Accept-Charset' => 'utf-8'
  }
  @http  = Faraday.new(url: @endpoint, headers: headers) do |conn|
    conn.request :multipart
    conn.request :json
    conn.response :json, content_type: 'application/json'
    conn.adapter  Faraday.default_adapter
  end
end