Class: Dagpi::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
# File 'lib/dagpirb.rb', line 7

def initialize(token)
  @token = token
  @client = Dagpi::HTTPClient.new @token
  @__version__ = VERSION
end

Instance Attribute Details

#__version__Object (readonly)

Returns the value of attribute __version__.



6
7
8
# File 'lib/dagpirb.rb', line 6

def __version__
  @__version__
end

#tokenObject (readonly)

Returns the value of attribute token.



6
7
8
# File 'lib/dagpirb.rb', line 6

def token
  @token
end

Instance Method Details

#get_data(endpoint) ⇒ Hash

Request data from Data API

Parameters:

  • endpoint: (String)

    The endpoint to request with

Returns:

  • (Hash)


17
18
19
# File 'lib/dagpirb.rb', line 17

def get_data(endpoint)
  @client.get_data(endpoint)
end

#get_image(endpoint, url) ⇒ bytes

Request image data from Image API

Parameters:

  • endpoint: (String)

    The endpoint to request with

  • url: (String)

    The image url to manipulate

Returns:

  • (bytes)


26
27
28
# File 'lib/dagpirb.rb', line 26

def get_image(endpoint, url)
  @client.get_image(endpoint, url)
end