Total Complexity | 3 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | require 'faraday' |
||
5 | class IntegrationToken |
||
6 | attr_accessor :http |
||
7 | attr_accessor :token |
||
8 | |||
9 | def initialize(opts = {}) |
||
10 | @endpoint = 'https://api.medium.com/v1/' |
||
11 | @token = opts[:integration_token] if opts.key? :integration_token |
||
12 | set_client |
||
13 | end |
||
14 | |||
15 | def set_client() |
||
16 | headers = { |
||
17 | 'Host' => 'api.medium.com', |
||
18 | 'Authorization' => 'Bearer ' + @token, |
||
19 | 'Content-Type' => 'application/json', |
||
20 | 'Accept' => 'application/json', |
||
21 | 'Accept-Charset' => 'utf-8' |
||
22 | } |
||
23 | @http = Faraday.new(url: @endpoint, headers: headers) do |conn| |
||
24 | conn.request :multipart |
||
25 | conn.request :json |
||
26 | conn.response :json, content_type: 'application/json' |
||
27 | conn.adapter Faraday.default_adapter |
||
28 | end |
||
29 | end |
||
30 | |||
31 | end |
||
32 | end |
||
33 |