Class: MediumSdk::Connection::IntegrationToken
- Inherits:
-
Object
- Object
- MediumSdk::Connection::IntegrationToken
- Defined in:
- lib/medium_sdk/connection/integration_token.rb
Instance Attribute Summary collapse
-
#http ⇒ Object
Returns the value of attribute http.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ IntegrationToken
constructor
A new instance of IntegrationToken.
- #set_client ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ IntegrationToken
Returns a new instance of IntegrationToken.
9 10 11 12 13 |
# 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 |
Instance Attribute Details
#http ⇒ Object
Returns the value of attribute http.
6 7 8 |
# File 'lib/medium_sdk/connection/integration_token.rb', line 6 def http @http end |
#token ⇒ Object
Returns the value of attribute token.
7 8 9 |
# File 'lib/medium_sdk/connection/integration_token.rb', line 7 def token @token end |
Instance Method Details
#set_client ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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 |