Class: Medium::Users

Inherits:
Object
  • Object
show all
Defined in:
lib/medium/users.rb

Overview

Users class is used to interact with the Users API endpoint of Medium

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Medium::Users

Initialize a new Medium::Users client

Parameters:

  • client (#get)

    The network client to use while retrieving data from the Users resource.



10
11
12
# File 'lib/medium/users.rb', line 10

def initialize(client)
  @client = client
end

Instance Method Details

#meHash

Returns details of the user who has granted permission to the application.

Returns:

  • (Hash)

    The response is a User object within a data envelope. Example response:

    HTTP/1.1 200 OK
    Content-Type: application/json; charset=utf-8
    {
      "data": {
        "id": "123456789exampleid",
        "username": "kkirsche",
        "name": "Kevin Kirsche",
        "url": "https://medium.com/@kkirsche",
        "imageUrl": "https://images.medium.com/somewhere.png"
      }
    }
    


31
32
33
34
# File 'lib/medium/users.rb', line 31

def me
  response = @client.get 'me'
  Medium::Client.validate response
end